Skip to content

Commit

Permalink
Add localdb e2e tests from (un)publishing of VS
Browse files Browse the repository at this point in the history
  • Loading branch information
forus authored and alisman committed Jul 18, 2024
1 parent f28e5a0 commit c3ef88d
Show file tree
Hide file tree
Showing 2 changed files with 124 additions and 10 deletions.
2 changes: 2 additions & 0 deletions end-to-end-test/local/runtime-config/portal.properties
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,8 @@ session.service.url=
# session.service.user=user
# session.service.password=pass

session.endpoint.publisher-api-key=SECRETKEY

# disabled tabs, | delimited
# possible values: cancer_types_summary, mutual_exclusivity, plots, mutations, co_expression, enrichments, survival, network, download, bookmark, IGV
disabled_tabs=
Expand Down
132 changes: 122 additions & 10 deletions end-to-end-test/local/specs/virtual-study.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ const studyEs0Summary = CBIOPORTAL_URL + '/study/summary?id=study_es_0';

describe('Virtual Study life cycle', function() {
const vsTitle = 'Test VS ' + Date.now();
let link;
let vsId;
const X_PUBLISHER_API_KEY = 'SECRETKEY';

it('Login and navigate to the study_es_0 study summary page', function() {
goToUrlAndSetLocalStorage(studyEs0Summary, true);
});
Expand All @@ -18,7 +22,7 @@ describe('Virtual Study life cycle', function() {
shareVSBtn.waitForClickable();
shareVSBtn.click();
});
it('Provid the title and save', function() {
it('Provide the title and save', function() {
const modalDialog = $('.modal-dialog');
modalDialog.waitForDisplayed();
const titleInput = modalDialog.$('input#sniglet');
Expand All @@ -29,31 +33,139 @@ describe('Virtual Study life cycle', function() {
saveBtn.click();
modalDialog.$('.text-success').waitForDisplayed();
const linkInput = modalDialog.$('input[type="text"]');
const link = linkInput.getValue();
link = linkInput.getValue();
assert.ok(
link.startsWith('http'),
'The value should be link, but was ' + link
);
vsId = link
.split('?')[1]
.split('&')
.map(paramEqValue => paramEqValue.split('='))
.find(([key, value]) => key === 'id')[1];
assert.ok(vsId, 'Virtual Study ID has not to be empty');
});
it('See the VS in My Virtual Studies section on the landing page', function() {
goToUrlAndSetLocalStorage(CBIOPORTAL_URL, true);
const myVirtualStudies = $(
'//*[text()="My Virtual Studies"]/ancestor::ul[1]'
const vsSection = $(`//*[text()="${vsTitle}"]/ancestor::ul[1]`);
vsSection.waitForDisplayed();
const sectionTitle = vsSection.$('li label span');
assert.equal(sectionTitle.getText(), 'My Virtual Studies');
});
it('Publish the VS', function() {
const result = browser.executeAsync(
function(cbioUrl, vsId, key, done) {
const url = cbioUrl + '/api/public_virtual_studies/' + vsId;
const headers = new Headers();
headers.append('X-PUBLISHER-API-KEY', key);
fetch(url, {
method: 'POST',
headers: headers,
})
.then(response => {
done({
success: response.ok,
message: 'HTTP Status: ' + response.status,
});
})
.catch(error => {
done({ success: false, message: error.message });
});
},
CBIOPORTAL_URL,
vsId,
X_PUBLISHER_API_KEY
);
myVirtualStudies.waitForDisplayed();
const vsRow = myVirtualStudies.$(
`//*[text()="${vsTitle}"]/ancestor::li[1]`
assert.ok(result.success, result.message);
});
it('See the VS in Public Virtual Studies section on the landing page', function() {
goToUrlAndSetLocalStorage(CBIOPORTAL_URL, true);
const vsSection = $(`//*[text()="${vsTitle}"]/ancestor::ul[1]`);
vsSection.waitForDisplayed();
const sectionTitle = vsSection.$('li label span');
assert.equal(sectionTitle.getText(), 'Public Virtual Studies');
});
it('Re-publish the VS specifying PubMed ID and type of cancer', function() {
const result = browser.executeAsync(
function(cbioUrl, vsId, key, done) {
const headers = new Headers();
headers.append('X-PUBLISHER-API-KEY', key);
fetch(
cbioUrl +
'/api/public_virtual_studies/' +
vsId +
'?pmid=28783718&typeOfCancerId=aca',
{
method: 'POST',
headers: headers,
}
)
.then(response => {
done({
success: response.ok,
message: 'HTTP Status: ' + response.status,
});
})
.catch(error => {
done({ success: false, message: error.message });
});
},
CBIOPORTAL_URL,
vsId,
X_PUBLISHER_API_KEY
);
assert.ok(result.success, result.message);
});
it('See the VS in the Adrenocortical Adenoma section with PubMed link', function() {
goToUrlAndSetLocalStorage(CBIOPORTAL_URL, true);
const vsRow = $(`//*[text()="${vsTitle}"]/ancestor::li[1]`);
const vsSection = vsRow.parentElement();
vsSection.waitForDisplayed();
const sectionTitle = vsSection.$('li label span');
assert.equal(sectionTitle.getText(), 'Adrenocortical Adenoma');
//has PubMed link
assert.ok(vsRow.$('.fa-book').isExisting());
});
it('Un-publish the VS', function() {
const result = browser.executeAsync(
function(cbioUrl, vsId, key, done) {
const headers = new Headers();
headers.append('X-PUBLISHER-API-KEY', key);
fetch(cbioUrl + '/api/public_virtual_studies/' + vsId, {
method: 'DELETE',
headers: headers,
})
.then(response => {
done({
success: response.ok,
message: 'HTTP Status: ' + response.status,
});
})
.catch(error => {
done({ success: false, message: error.message });
});
},
CBIOPORTAL_URL,
vsId,
X_PUBLISHER_API_KEY
);
assert.ok(result.success, result.message);
});

it('Removing the VS', function() {
goToUrlAndSetLocalStorage(CBIOPORTAL_URL, true);
const vsRow = $(`//*[text()="${vsTitle}"]/ancestor::li[1]`);
vsRow.waitForDisplayed();

const removeBtn = vsRow.$('.fa-trash');
removeBtn.click();
});
it('The VS dissapred from the landing page', function() {

it('The VS disappears from the landing page', function() {
goToUrlAndSetLocalStorage(CBIOPORTAL_URL, true);
$('[data-test="cancerTypeListContainer"]').waitForDisplayed();
const vsRow = $(`//*[text()="${vsTitle}"]`);
const vsRowTitle = $(`//*[text()="${vsTitle}"]`);
browser.pause(100);
assert.ok(!vsRow.isExisting());
assert.ok(!vsRowTitle.isExisting());
});
});

0 comments on commit c3ef88d

Please sign in to comment.