Skip to content

Commit

Permalink
Fix/discoverypagetestdata (#1061)
Browse files Browse the repository at this point in the history
* Fix discovery page test data

* wait longer for study to show up on page

* try waiting for 2 minutes before launching discovery page

* fix data

* retrying study lookup

* fix retry

* fix retry

* fix

* fix

* fix data
  • Loading branch information
haraprasadj authored Dec 3, 2024
1 parent f512910 commit 3df3ef7
Show file tree
Hide file tree
Showing 6 changed files with 122 additions and 416 deletions.
25 changes: 23 additions & 2 deletions services/portal/discovery/discoveryQuestions.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
const { sleepMS } = require('../../../utils/apiUtil.js');
const props = require('./discoveryProps.js');
const tasks = require('./discoveryTasks.js');

const I = actor();

Expand All @@ -11,7 +13,26 @@ module.exports = {
I.seeElement(props.readyCue, 30);
},

isStudyFound(studyId) {
I.seeElement(props.studyLocator(studyId), 30);
async isStudyFound(studyId) {
const retries = 10; // Number of retries
const delayInMs = 30000; // Delay between retries in milliseconds

for (let attempt = 1; attempt <= retries; attempt++) {
const visibleElements = await I.grabNumberOfVisibleElements(props.studyLocator(studyId));

if (visibleElements > 0) {
console.log(`Study found on attempt ${attempt}`);
return true; // Exit the loop if the element is found
} else {
console.log(`Attempt ${attempt} failed. Retrying in ${delayInMs / 1000} seconds...`);
if (attempt < retries) {
await sleepMS(delayInMs); // Wait before retrying
tasks.goToPage(); // Refresh discovery page
} else {
console.error('Study not found after maximum retries.');
throw new Error('Study not found.');
}
}
}
},
};
1 change: 0 additions & 1 deletion suites/apis/aggMDSTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ I.cache = {};
const testDataFiles = new DataTable(['studyFilePath']);
testDataFiles.add(['test-data/aggMDSTest/study1.json']);
testDataFiles.add(['test-data/aggMDSTest/study2.json']);
testDataFiles.add(['test-data/aggMDSTest/study3.json']);

Data(testDataFiles).Scenario('Create, edit and delete aggregate metadata record', async ({
mds, users, current,
Expand Down
16 changes: 8 additions & 8 deletions suites/portal/discoveryPageTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ const { expect } = require('chai');
const { output } = require('codeceptjs');
const { Bash } = require('../../utils/bash.js');
const fs = require('fs');
const { sleepMS } = require('../../utils/apiUtil.js');

const bash = new Bash();
const I = actor();
Expand Down Expand Up @@ -86,7 +87,7 @@ Scenario('Publish a study, search and export to workspace @requires-indexd @requ
output.print('--- Perform tag search');
discovery.do.tagSearch('TESTING', 'AUTOTEST Tag');
I.saveScreenshot('2_clicked_tag.png');
discovery.ask.isStudyFound(I.cache.studyId);
await discovery.ask.isStudyFound(I.cache.studyId);

// Advanced search
// I.refreshPage();
Expand All @@ -100,24 +101,23 @@ Scenario('Publish a study, search and export to workspace @requires-indexd @requ
I.wait(2);
discovery.do.textSearch('[AUTOTEST Title]');
I.saveScreenshot('4_entered_text.png');
discovery.ask.isStudyFound(I.cache.studyId);
await discovery.ask.isStudyFound(I.cache.studyId);

output.print('--- Perform text search');
I.refreshPage();
I.wait(2);
discovery.do.textSearch('[AUTOTEST Summary]');
I.saveScreenshot('5_entered_text.png');
discovery.ask.isStudyFound(I.cache.studyId);
await discovery.ask.isStudyFound(I.cache.studyId);

output.print('--- Open study in workspace');
discovery.do.openInWorkspace(I.cache.studyId);
I.saveScreenshot('6_open_in_workspace.png');
I.waitInUrl('/workspace', 120);

// --- Disabled the validation since workspaces are failing to launch in jenkins envs ---
// await workspace.do.launchWorkspace('(Tutorial) Bacpac Synthetic Data Analysis Notebook');
await workspace.do.launchWorkspace('(Tutorial) Bacpac Synthetic Data Analysis Notebook');

// output.print('--- Run `gen3 drs-pull object` in a new Python3 notebook');
// await workspace.do.runCommandinPythonNotebook(`!gen3 drs-pull object --object_id ${I.cache.did}`);
// I.saveScreenshot('7_run_drs_pull_in_notebook.png');
output.print('--- Run `gen3 drs-pull object` in a new Python3 notebook');
await workspace.do.runCommandinPythonNotebook(`!gen3 drs-pull object --object_id ${I.cache.did}`);
I.saveScreenshot('7_run_drs_pull_in_notebook.png');
});
9 changes: 7 additions & 2 deletions test-data/aggMDSTest/study1.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,11 @@
}],
"authz": "/open",
"sites": 3,
"summary": "[AUTOTEST Summary] The BACPAC Research Program, Data Integration, Algorithm Development, and Operations Management Center (DAC) will bring cohesion to research performed by the participating Mechanistic Research Centers, Technology Research Sites, and Phase 2 Clinical Trials Centers. DAC Investigators will share their vision and provide scientific leadership and organizational support to the BACPAC Consortium. The research plan consists of supporting design and conduct of clinical trials with precision interventions that focus on identifying the best treatments for individual patients. The DAC will enhance collaboration and research progress with experienced leadership, innovative design and analysis methodologies, comprehensive research operations support, a state-of-the-art data management and integration system, and superior administrative support. This integrated structure will set the stage for technology assessments, solicitation of patient input and utilities, and the evaluation of high-impact interventions through the innovative design and sound execution of clinical trials, leading to effective personalized treatment approaches for patients with chronic lower back pain.",
"summary": "[AUTOTEST Summary] Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Donec quam felis, ultricies nec, pellentesque eu, pretium quis, sem. Nulla consequat massa quis enim",
"location": "Chapel Hill, Nc",
"subjects": 150,
"__manifest": [],
"study_name": "BACPAC Research Consortium",
"study_type": "Other",
"institutions": "University Of North Carolina Chapel Hill",
"year_awarded": 2019,
"investigators": "Love, Pascale",
Expand All @@ -24,6 +23,12 @@
"key": "Research Focus Area",
"value": "AUTOTEST Filter"
}],
"minimal_info": {
"study_name": "[AUTOTEST Title] Testing Aggregate Metadata Service",
"study_description": "Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Donec quam felis, ultricies nec, pellentesque eu, pretium quis, sem. Nulla consequat massa quis enim",
"alternative_study_name": "Donec pede justo, fringilla vel, aliquet nec, vulputate eget, arcu",
"alternative_study_description": "In enim justo, rhoncus ut, imperdiet a, venenatis vitae, justo. Nullam dictum felis eu pede mollis pretium. Integer tincidunt. Cras dapibus. Vivamus elementum semper nisi. Aenean vulputate eleifend tellus. Aenean leo ligula, porttitor eu, consequat vitae, eleifend ac, enim."
},
"research_program": "Back Pain Consortium Research Program",
"research_question": "To inform a precision medicine approach to cLBP.",
"study_description": "Observational",
Expand Down
Loading

0 comments on commit 3df3ef7

Please sign in to comment.