Skip to content

Commit

Permalink
Merge pull request #196 from MetaCell/testfix
Browse files Browse the repository at this point in the history
Testfix
  • Loading branch information
jrmartin authored Jan 9, 2024
2 parents c6c9738 + 5b87be8 commit 5dc3f9c
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 16 deletions.
60 changes: 45 additions & 15 deletions __tests__/e2e.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ describe("SDS Viewer e2e Test: Sparc Dataset", () => {
await page.waitForSelector(selectors.EMPTY_DATASET_VIEWER_SELECTOR);
});


test("Home Page", async () => {
await page.waitForSelector(selectors.EMPTY_DATASET_VIEWER_SELECTOR);

Expand All @@ -56,24 +57,24 @@ describe("SDS Viewer e2e Test: Sparc Dataset", () => {
customSnapshotIdentifier: 'Home Page'
});


});


test('Choose from SPARC Dataset List', async () => {
test('Choose SPARC Dataset List', async () => {

console.log('Opening SPARC Datasets')

await page.waitForSelector(selectors.LOAD_BUTTONS_SELECTOR)

const load_dataset_button = await page.$$(selectors.LOAD_BUTTONS_SELECTOR)

for (var i = 0; i < load_dataset_button.length; i++) {
load_dataset_button[1].click()
load_dataset_button[0].click()

}

await page.waitForSelector(selectors.DATASET_LIST_SELECTOR)
await page.waitForSelector(selectors.DATASET_ITEM_SELECTOR)
await page.waitForTimeout(ONE_SECOND * 3)
await page.waitForSelector(selectors.DATASET_LIST_SELECTOR, {timeout: 60000})
await page.waitForSelector(selectors.DATASET_ITEM_SELECTOR, {timeout: 60000})
await page.waitForSelector(selectors.DONE_BUTTON_SELECTOR, { disabled: true })
const sparc_dataset_counts = await page.$$eval(selectors.DATASET_COUNT_NUMBER_SELECTOR, sparc_dataset_counts => {
return sparc_dataset_counts.map(sparc_dataset_count => sparc_dataset_count.innerHTML);
Expand Down Expand Up @@ -107,8 +108,15 @@ describe("SDS Viewer e2e Test: Sparc Dataset", () => {
const folder_lenght = folder.length

expect(folder_lenght).toBe(1)

await page.waitForTimeout(3000)
await page.waitForSelector(selectors.OPEN_FOLDER_BUTTON_SELECTOR)
await page.click(selectors.OPEN_FOLDER_BUTTON_SELECTOR)
await page.waitForSelector(selectors.SUBFOLDERS_SELECTOR)
await page.waitForTimeout(3000)

const folder_after_click = await page.$$(selectors.LOADED_DATASET_SELECTOR)
const folder_lenght_after_click = folder_after_click.length
expect(folder_lenght_after_click).toBeGreaterThan(folder_lenght)

const data_folders = await page.$$eval(selectors.LOADED_DATASET_SELECTOR, data_folders => {
return data_folders.map(data_folder => data_folder.innerHTML);
Expand All @@ -119,9 +127,14 @@ describe("SDS Viewer e2e Test: Sparc Dataset", () => {
expect(data_folders).toContain('derivative')
expect(data_folders).toContain('subjects.xlsx')

})

await console.log('... taking snapshot ...')
expect(await page.screenshot())
.toMatchImageSnapshot({
...SNAPSHOT_OPTIONS,
customSnapshotIdentifier: 'Dataset Loaded'
});

})

test('Load another SPARC Dataset', async () => {

Expand All @@ -130,7 +143,7 @@ describe("SDS Viewer e2e Test: Sparc Dataset", () => {
const load_dataset_button = await page.$$(selectors.LOAD_BUTTONS_SELECTOR)

for (var i = 0; i < load_dataset_button.length; i++) {
load_dataset_button[1].click()
load_dataset_button[0].click()

}

Expand All @@ -152,13 +165,20 @@ describe("SDS Viewer e2e Test: Sparc Dataset", () => {
console.log('Dataset loaded')

await page.waitForSelector(selectors.GRAPH_SELECTOR)
await page.waitForTimeout(ONE_MINUTE * 1.5)
await page.waitForTimeout(10000)
const folder = await page.$$(selectors.LOADED_DATASET_SELECTOR)
const folder_lenght = folder.length

expect(folder_lenght).toBe(2)
})

await console.log('... taking snapshot ...')
expect(await page.screenshot())
.toMatchImageSnapshot({
...SNAPSHOT_OPTIONS,
customSnapshotIdentifier: '2 Datasets Loaded'
});

})

test('Open Dataset through its ID', async () => {

Expand All @@ -180,9 +200,16 @@ describe("SDS Viewer e2e Test: Sparc Dataset", () => {

expect(data_ids[0]).toBe(DATASET_ID)

await console.log('... taking snapshot ...')
expect(await page.screenshot())
.toMatchImageSnapshot({
...SNAPSHOT_OPTIONS,
customSnapshotIdentifier: 'Dataset Loaded'
});

})

//SDS Viewer has a bug on this section
// No Longer applicable
test.skip('Load Dataset through URL', async () => {
await page.goto(DEV_URL)
await page.waitForSelector(selectors.EMPTY_DATASET_LIST_SELECTOR);
Expand All @@ -203,7 +230,7 @@ describe("SDS Viewer e2e Test: Sparc Dataset", () => {

})

//SDS Viewer has a bug on this section
// No Longer applicable
test.skip('Load Dataset from Local System', async () => {
await page.goto(DEV_URL)
await page.waitForSelector(selectors.EMPTY_DATASET_LIST_SELECTOR);
Expand Down Expand Up @@ -253,4 +280,7 @@ describe("SDS Viewer e2e Test: Sparc Dataset", () => {
})


})
})



3 changes: 2 additions & 1 deletion __tests__/selectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@ export const DATASET_COUNT_NUMBER_SELECTOR = 'p[class="MuiTypography-root MuiTyp
export const SPARC_DATASET_LIST_SELECTOR = 'li[class="MuiListItem-root dataset_item MuiListItem-gutters"]';
export const ENABLED_DONE_BUTTON_SELECTOR = 'button[class="MuiButtonBase-root MuiButton-root MuiButton-contained MuiButton-containedPrimary MuiButton-disableElevation MuiButton-fullWidth"]';
export const LOADED_DATASET_SELECTOR = 'p[class="MuiTypography-root labelText MuiTypography-body2"]';
export const GRAPH_SELECTOR = '#graph-2d';
export const GRAPH_SELECTOR = '.graph-view';
export const OPEN_FOLDER_BUTTON_SELECTOR = 'span[class="MuiTypography-root labelCaption MuiTypography-caption MuiTypography-colorInherit"]';
export const SUBFOLDERS_SELECTOR = 'ul[class="MuiCollapse-root MuiTreeItem-group MuiCollapse-entered"]'
export const FELINE_DATASET_IMG_SELECTOR = 'img[alt="Feline brainstem neuron extracellular potential recordings"]';
export const DATA_ID_SELECTOR = 'h6[class="MuiTypography-root breadcrumb_selected MuiTypography-subtitle2"]';
export const URL_UPLOADER_SELECTOR = '#url-uploader';
Expand Down
Binary file added __tests__/snapshots/2 Datasets Loaded-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added __tests__/snapshots/Dataset Loaded-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 5dc3f9c

Please sign in to comment.