diff --git a/tests/frontend/e2e/jest-puppeteer.config.js b/tests/frontend/e2e/jest-puppeteer.config.js deleted file mode 100644 index ecef8e7c..00000000 --- a/tests/frontend/e2e/jest-puppeteer.config.js +++ /dev/null @@ -1,11 +0,0 @@ -module.exports = { - launch: { - headless: 'new', - defaultViewport: { - width: 1300, - height: 1024 - }, - timeout: 120000 - }, - exitOnPageError: false, -} \ No newline at end of file diff --git a/tests/frontend/e2e/jest.config.js b/tests/frontend/e2e/jest.config.js index 89e7ae66..3c4fc3e9 100644 --- a/tests/frontend/e2e/jest.config.js +++ b/tests/frontend/e2e/jest.config.js @@ -1,6 +1,6 @@ module.exports = { verbose: true, - preset: "jest-puppeteer", + // preset: "jest-puppeteer", testRegex : "(tests/Test.*|(\\.|/)(test|spec))\\.[jt]sx?$", setupFilesAfterEnv: ['./tests/setupTests.js'], }; \ No newline at end of file diff --git a/tests/frontend/e2e/package.json b/tests/frontend/e2e/package.json index a92e4ee4..aa2a0a6b 100644 --- a/tests/frontend/e2e/package.json +++ b/tests/frontend/e2e/package.json @@ -4,15 +4,19 @@ "description": "NetPyNe UI tests", "license": "unlicensed", "scripts": { - "test": "jest --verbose Tut#1_smoke && jest --verbose ExperimentManager_Tut#1", + "test": "sleep 60 && npm run simple_tutorials_test && npm run complex_tutorials_test && npm run features_test", + "puppeteer_test": "jest --verbose", + "simple_tutorials_test": "sleep 60 && jest --verbose Tut#1_smoke Tut#2_smoke Tut#4_smoke", + "complex_tutorials_test": "jest --verbose Tut#3a_smoke Tut#3b_smoke Tut#3c_smoke", + "features_test": "jest --verbose ControlPanel SaveOpenFile RxD EEG_and_Dipole_Tut#1 ExperimentManager_Tut#1", "EEG_Dipole_test": "jest --verbose EEG_and_Dipole_Tut#1 ", "Experiment_Manager_test": "jest --verbose ExperimentManager_Tut#1 ", - "Tutorial_1_test":"jest --verbose Tut#1_smoke ", - "Tutorial_2_test":"jest --verbose Tut#2_smoke ", - "Tutorial_3A_test":"jest --verbose Tut#3a_smoke ", - "Tutorial_3B_test":"jest --verbose Tut#3b_smoke ", - "Tutorial_3C_test":"jest --verbose Tut#3c_smoke ", - "Tutorial_4_test":"jest --verbose Tut#4_smoke ", + "Tutorial_1_test": "jest --verbose Tut#1_smoke ", + "Tutorial_2_test": "jest --verbose Tut#2_smoke ", + "Tutorial_3A_test": "jest --verbose Tut#3a_smoke ", + "Tutorial_3B_test": "jest --verbose Tut#3b_smoke ", + "Tutorial_3C_test": "jest --verbose Tut#3c_smoke ", + "Tutorial_4_test": "jest --verbose Tut#4_smoke ", "Control_Panel_test": "jest --verbose ControlPanel ", "Save_Open_File_test": "jest --verbose SaveOpenFile", "RxD_test": "jest --verbose RxD", @@ -50,4 +54,4 @@ ] } } -} +} \ No newline at end of file diff --git a/tests/frontend/e2e/tests/ControlPanel.test.js b/tests/frontend/e2e/tests/ControlPanel.test.js index c3a8e3e9..0beb63f3 100644 --- a/tests/frontend/e2e/tests/ControlPanel.test.js +++ b/tests/frontend/e2e/tests/ControlPanel.test.js @@ -1,5 +1,6 @@ //IMPORTS: import 'expect-puppeteer'; +import puppeteer from 'puppeteer'; import { click } from './utils'; import { toMatchImageSnapshot } from 'jest-image-snapshot' expect.extend({ toMatchImageSnapshot }) @@ -30,55 +31,76 @@ const PASSWORD = 'testpassword' //TESTS: jest.setTimeout(300000); - +let browser_control_panel; +let control_panel_page; describe('Test for the Control Panel - color picker', () => { beforeAll(async () => { - await page.goto(baseURL); - await page.waitForSelector(selectors.LOGIN_PAGE_SELECTOR); - await page.waitForSelector(selectors.USERNAME_SELECTOR) - await expect(page) - .toFill(selectors.USERNAME_SELECTOR, USERNAME, { timeout: TIMEOUT }); - - await page.waitForSelector(selectors.PASSWORD_SELECTOR) - await expect(page) - .toFill(selectors.PASSWORD_SELECTOR, PASSWORD, { timeout: TIMEOUT }); - - await page.click(selectors.LOGIN_BUTTON_SELECTOR) - - await page.waitForFunction(() => { - let el = document.querySelector('#loading-spinner'); - return el == null || el.clientHeight === 0; - }, { timeout: TIMEOUT }); + browser_control_panel = await puppeteer.launch( + { + headless: 'new', + args: ['--no-sandbox', '--disable-setuid-sandbox'], + defaultViewport: { + width: 1300, + height: 1024 + }, + } + ); + control_panel_page = await browser_control_panel.newPage(); + await control_panel_page.goto(baseURL); + if (baseURL.includes('test.netpyne.metacell.us')) { + console.log('Logging in as test user ...') + await control_panel_page.waitForSelector(selectors.LOGIN_PAGE_SELECTOR); + await control_panel_page.waitForSelector(selectors.USERNAME_SELECTOR) + await expect(control_panel_page) + .toFill(selectors.USERNAME_SELECTOR, USERNAME, { timeout: TIMEOUT }); + + await control_panel_page.waitForSelector(selectors.PASSWORD_SELECTOR) + await expect(control_panel_page) + .toFill(selectors.PASSWORD_SELECTOR, PASSWORD, { timeout: TIMEOUT }); + + await control_panel_page.click(selectors.LOGIN_BUTTON_SELECTOR) + // Wait for initial loading spinner to disappear + await control_panel_page.waitForFunction(() => { + let el = document.querySelector('#loading-spinner'); + return el == null || el.clientHeight === 0; + }, { timeout: TIMEOUT }); + console.log('Logged in successfully') + } }); + afterAll(async () => { + // Close the browser instance after all tests have run + await browser_control_panel.close(); + }); + it('Open new page', async () => { console.log('Opening a new NetPyNE page') - await page.on("dialog", dialog => + await control_panel_page.on("dialog", dialog => dialog.accept()); - await page.waitForSelector(selectors.SELECT_CELL_BUTTON_SELECTOR, { timeout: TIMEOUT * 6, visible: true }) - await page.waitForSelector(selectors.FILE_TAB_SELECTOR, { timeout: PAGE_WAIT * 3 }) - await page.waitForTimeout(PAGE_WAIT) - await page.click(selectors.FILE_TAB_SELECTOR) - await page.waitForSelector(selectors.NEW_FILE_SELECTOR, { timeout: PAGE_WAIT * 3 }) - await page.waitForTimeout(PAGE_WAIT) - await page.click(selectors.NEW_FILE_SELECTOR) - await page.waitForTimeout(PAGE_WAIT) - await page.waitForSelector(selectors.CONFIRM_NEW_PAGE_SELECTOR) - await page.click(selectors.CONFIRM_NEW_PAGE_SELECTOR) - await page.waitForTimeout(PAGE_WAIT * 2) - - await page.waitForFunction(() => { + await control_panel_page.waitForSelector(selectors.SELECT_CELL_BUTTON_SELECTOR, { timeout: TIMEOUT * 6, visible: true }) + await control_panel_page.waitForSelector(selectors.FILE_TAB_SELECTOR, { timeout: PAGE_WAIT * 3 }) + await control_panel_page.waitForTimeout(PAGE_WAIT) + await control_panel_page.click(selectors.FILE_TAB_SELECTOR) + await control_panel_page.waitForSelector(selectors.NEW_FILE_SELECTOR, { timeout: PAGE_WAIT * 3 }) + await control_panel_page.waitForTimeout(PAGE_WAIT) + await control_panel_page.click(selectors.NEW_FILE_SELECTOR) + await control_panel_page.waitForTimeout(PAGE_WAIT) + await control_panel_page.waitForSelector(selectors.CONFIRM_NEW_PAGE_SELECTOR) + await control_panel_page.click(selectors.CONFIRM_NEW_PAGE_SELECTOR) + await control_panel_page.waitForTimeout(PAGE_WAIT * 2) + + await control_panel_page.waitForFunction(() => { let el = document.querySelector('#loading-spinner'); return el == null || el.clientHeight === 0; }, { timeout: TIMEOUT }); - await page.waitForSelector(selectors.SELECT_CELL_BUTTON_SELECTOR, { timeout: TIMEOUT * 10 }) + await control_panel_page.waitForSelector(selectors.SELECT_CELL_BUTTON_SELECTOR, { timeout: TIMEOUT * 10 }) console.log('Page opened successfully') @@ -86,18 +108,19 @@ describe('Test for the Control Panel - color picker', () => { it('Load Tutorial#2', async () => { - await page.waitForTimeout(PAGE_WAIT * 2) - await page.waitForSelector(selectors.SELECT_CELL_BUTTON_SELECTOR, { timeout: TIMEOUT }) - await page.waitForTimeout(PAGE_WAIT) - await page.click(selectors.TUTORIALS_BUTTON_SELECTOR, { timeout: TIMEOUT }) + await control_panel_page.waitForTimeout(PAGE_WAIT * 2) + await control_panel_page.waitForSelector(selectors.SELECT_CELL_BUTTON_SELECTOR, { timeout: TIMEOUT }) + await control_panel_page.waitForTimeout(PAGE_WAIT) + await control_panel_page.waitForSelector(selectors.TUTORIALS_BUTTON_SELECTOR, { timeout: TIMEOUT }) + await control_panel_page.click(selectors.TUTORIALS_BUTTON_SELECTOR, { timeout: TIMEOUT }) console.log('Loading Tutorial #2') - - await page.click(selectors.TUTORIAL_2_SELECTOR, { timeout: TIMEOUT }) - await page.waitForTimeout(PAGE_WAIT) - await page.waitForSelector(selectors.PYR_2_CELL_SELECTOR) - await page.waitForSelector(selectors.INT_CELL_SELECTOR) - await page.waitForTimeout(PAGE_WAIT) + await control_panel_page.waitForSelector(selectors.TUTORIAL_2_SELECTOR, { timeout: TIMEOUT }) + await control_panel_page.click(selectors.TUTORIAL_2_SELECTOR, { timeout: TIMEOUT }) + await control_panel_page.waitForTimeout(PAGE_WAIT) + await control_panel_page.waitForSelector(selectors.PYR_2_CELL_SELECTOR) + await control_panel_page.waitForSelector(selectors.INT_CELL_SELECTOR) + await control_panel_page.waitForTimeout(PAGE_WAIT) console.log('Tutorial #2 loaded successfully') @@ -106,22 +129,22 @@ describe('Test for the Control Panel - color picker', () => { it('Create network', async () => { - await page.waitForSelector(selectors.MODEL_BUTTON_SELECTOR) - await page.click(selectors.MODEL_BUTTON_SELECTOR, { timeout: TIMEOUT }); - await page.waitForSelector(selectors.CREATE_NETWORK_SELECTOR) - await page.click(selectors.CREATE_NETWORK_SELECTOR, { timeout: TIMEOUT }); + await control_panel_page.waitForSelector(selectors.MODEL_BUTTON_SELECTOR) + await control_panel_page.click(selectors.MODEL_BUTTON_SELECTOR, { timeout: TIMEOUT }); + await control_panel_page.waitForSelector(selectors.CREATE_NETWORK_SELECTOR) + await control_panel_page.click(selectors.CREATE_NETWORK_SELECTOR, { timeout: TIMEOUT }); console.log('Create network') - await page.waitForSelector(selectors.DISABLED_RASTER_PLOT_SELECTOR, { timeout: TIMEOUT * 3 }) + await control_panel_page.waitForSelector(selectors.DISABLED_RASTER_PLOT_SELECTOR, { timeout: TIMEOUT * 3 }) console.log('Network created successfully') - await page.waitForTimeout(PAGE_WAIT) + await control_panel_page.waitForTimeout(PAGE_WAIT) console.log('... taking snapshot ...'); - await page.waitForTimeout(PAGE_WAIT); - expect(await page.screenshot()) + await control_panel_page.waitForTimeout(PAGE_WAIT); + expect(await control_panel_page.screenshot()) .toMatchImageSnapshot({ ...SNAPSHOT_OPTIONS, customSnapshotIdentifier: 'Tutorial#2 Network' @@ -132,11 +155,11 @@ describe('Test for the Control Panel - color picker', () => { console.log('Opening Control Panel') - await page.waitForSelector(selectors.CONTROL_PANEL_TAB_SELECTOR) - await page.click(selectors.CONTROL_PANEL_TAB_SELECTOR) - await page.waitForSelector(selectors.NETWORKS_IN_CONTROL_PANEL_SELECTOR) + await control_panel_page.waitForSelector(selectors.CONTROL_PANEL_TAB_SELECTOR) + await control_panel_page.click(selectors.CONTROL_PANEL_TAB_SELECTOR) + await control_panel_page.waitForSelector(selectors.NETWORKS_IN_CONTROL_PANEL_SELECTOR) - const network_items = (await page.$$(selectors.NETWORK_ITEMS_CONTROL_PANEL_SELECTOR)).length; + const network_items = (await control_panel_page.$$(selectors.NETWORK_ITEMS_CONTROL_PANEL_SELECTOR)).length; await expect(network_items).toEqual(3) console.log('Control Panel displayed successfully') @@ -147,10 +170,10 @@ describe('Test for the Control Panel - color picker', () => { console.log('Randomize Main Level network color') - await page.waitForTimeout(PAGE_WAIT * 3) - await page.waitForSelector(selectors.CONTROL_PANEL_TABLE_SELECTOR) + await control_panel_page.waitForTimeout(PAGE_WAIT * 3) + await control_panel_page.waitForSelector(selectors.CONTROL_PANEL_TABLE_SELECTOR) - const primary_level_colors = await page.$$eval(selectors.COLOR_RECT_SELECTOR, primary_level_colors => { + const primary_level_colors = await control_panel_page.$$eval(selectors.COLOR_RECT_SELECTOR, primary_level_colors => { return primary_level_colors.map(primary_level_color => primary_level_color.outerHTML); }); @@ -158,22 +181,22 @@ describe('Test for the Control Panel - color picker', () => { expect(primary_level_colors[0]).toEqual(primary_level_colors[1]) expect(primary_level_colors[1]).toEqual(primary_level_colors[2]) - await page.waitForTimeout(PAGE_WAIT) + await control_panel_page.waitForTimeout(PAGE_WAIT) - const rows = await page.$$(selectors.CONTROL_PANEL_NETWORK_ROWS_SELECTOR) + const rows = await control_panel_page.$$(selectors.CONTROL_PANEL_NETWORK_ROWS_SELECTOR) for (var i = 0; i < rows.length; i++) { await rows[0].hover() } - const buttons = await page.$$(selectors.COLOR_CONTROL_BUTTONS_SELECTOR) + const buttons = await control_panel_page.$$(selectors.COLOR_CONTROL_BUTTONS_SELECTOR) for (var i = 0; i < buttons.length; i++) { await buttons[1].click() } - await page.waitForTimeout(PAGE_WAIT) + await control_panel_page.waitForTimeout(PAGE_WAIT) - const rndm_primary_level_colors = await page.$$eval(selectors.COLOR_RECT_SELECTOR, rndm_primary_level_colors => { + const rndm_primary_level_colors = await control_panel_page.$$eval(selectors.COLOR_RECT_SELECTOR, rndm_primary_level_colors => { return rndm_primary_level_colors.map(rndm_primary_level_color => rndm_primary_level_color.outerHTML); }); @@ -182,22 +205,22 @@ describe('Test for the Control Panel - color picker', () => { console.log('Main Network color randomized successfully') - await page.waitForTimeout(PAGE_WAIT) + await control_panel_page.waitForTimeout(PAGE_WAIT) }) it('Randomize Sub level E network color', async () => { console.log('Randomize Sub Level E network color') - - const rows = await page.$$(selectors.CONTROL_PANEL_NETWORK_ROWS_SELECTOR) + await control_panel_page.waitForSelector(selectors.CONTROL_PANEL_NETWORK_ROWS_SELECTOR, { timeout: TIMEOUT }) + const rows = await control_panel_page.$$(selectors.CONTROL_PANEL_NETWORK_ROWS_SELECTOR) for (var i = 0; i < rows.length; i++) { await rows[1].click() await rows[1].hover() } - await page.waitForTimeout(PAGE_WAIT) + await control_panel_page.waitForTimeout(PAGE_WAIT) - const second_level_colors = await page.$$eval(selectors.COLOR_RECT_SELECTOR, second_level_colors => { + const second_level_colors = await control_panel_page.$$eval(selectors.COLOR_RECT_SELECTOR, second_level_colors => { return second_level_colors.map(second_level_color => second_level_color.outerHTML); }); @@ -206,15 +229,15 @@ describe('Test for the Control Panel - color picker', () => { expect(second_level_colors[2]).toEqual(second_level_colors[3]) - const buttons = await page.$$(selectors.COLOR_CONTROL_BUTTONS_SELECTOR) + const buttons = await control_panel_page.$$(selectors.COLOR_CONTROL_BUTTONS_SELECTOR) for (var i = 0; i < buttons.length; i++) { await buttons[2].click() } - await page.waitForTimeout(PAGE_WAIT * 2) + await control_panel_page.waitForTimeout(PAGE_WAIT * 2) - const second_level_colors_after_rndm = await page.$$eval(selectors.COLOR_RECT_SELECTOR, second_level_colors_after_rndm => { + const second_level_colors_after_rndm = await control_panel_page.$$eval(selectors.COLOR_RECT_SELECTOR, second_level_colors_after_rndm => { return second_level_colors_after_rndm.map(second_level_color_after_rndm => second_level_color_after_rndm.outerHTML); }); @@ -224,7 +247,7 @@ describe('Test for the Control Panel - color picker', () => { console.log('E Network color randomized successfully') - await page.waitForTimeout(PAGE_WAIT * 3) + await control_panel_page.waitForTimeout(PAGE_WAIT * 3) }) @@ -232,58 +255,58 @@ describe('Test for the Control Panel - color picker', () => { it('Pick a color for the sublevel I netowrk', async () => { console.log('Selecting a color for the I network') - - const rows = await page.$$(selectors.CONTROL_PANEL_NETWORK_ROWS_SELECTOR) + await control_panel_page.waitForSelector(selectors.CONTROL_PANEL_NETWORK_ROWS_SELECTOR, { timeout: TIMEOUT }) + const rows = await control_panel_page.$$(selectors.CONTROL_PANEL_NETWORK_ROWS_SELECTOR) for (var i = 0; i < rows.length; i++) { await rows[1].click() } - await page.waitForTimeout(PAGE_WAIT) + await control_panel_page.waitForTimeout(PAGE_WAIT) - const rows_ = await page.$$(selectors.CONTROL_PANEL_NETWORK_ROWS_SELECTOR) + const rows_ = await control_panel_page.$$(selectors.CONTROL_PANEL_NETWORK_ROWS_SELECTOR) for (var i = 0; i < rows_.length; i++) { await rows_[2].click() } - await page.waitForTimeout(PAGE_WAIT) + await control_panel_page.waitForTimeout(PAGE_WAIT) - const network_colors = await page.$$eval(selectors.COLOR_RECT_SELECTOR, network_colors => { + const network_colors = await control_panel_page.$$eval(selectors.COLOR_RECT_SELECTOR, network_colors => { return network_colors.map(network_color => network_color.outerHTML); }); expect(network_colors[3]).toEqual(network_colors[4]) expect(network_colors[3]).toEqual(network_colors[2]) - await page.waitForTimeout(PAGE_WAIT * 3) + await control_panel_page.waitForTimeout(PAGE_WAIT * 3) - const buttons = await page.$$(selectors.COLOR_CONTROL_BUTTONS_SELECTOR) + const buttons = await control_panel_page.$$(selectors.COLOR_CONTROL_BUTTONS_SELECTOR) for (var i = 0; i < buttons.length; i++) { await buttons[4].click() } - await page.waitForTimeout(PAGE_WAIT) + await control_panel_page.waitForTimeout(PAGE_WAIT) - const list_bounds = await page.$(selectors.NETWORKS_IN_CONTROL_PANEL_SELECTOR); - const rect = await page.evaluate((list_bounds) => { + const list_bounds = await control_panel_page.$(selectors.NETWORKS_IN_CONTROL_PANEL_SELECTOR); + const rect = await control_panel_page.evaluate((list_bounds) => { const { top, left, bottom, right } = list_bounds.getBoundingClientRect(); return { top, left, bottom, right }; }, list_bounds); - await page.waitForTimeout(PAGE_WAIT) - await page.mouse.click(Math.round(rect.right) - 40, Math.round(rect.bottom) + 40) - await page.waitForTimeout(PAGE_WAIT * 2) + await control_panel_page.waitForTimeout(PAGE_WAIT) + await control_panel_page.mouse.click(Math.round(rect.right) - 40, Math.round(rect.bottom) + 40) + await control_panel_page.waitForTimeout(PAGE_WAIT * 2) - const rows_after_colouring_I = await page.$$(selectors.CONTROL_PANEL_NETWORK_ROWS_SELECTOR) + const rows_after_colouring_I = await control_panel_page.$$(selectors.CONTROL_PANEL_NETWORK_ROWS_SELECTOR) for (var i = 0; i < rows_after_colouring_I.length; i++) { await rows_after_colouring_I[2].click() } - const network_colors_after_colouring_I = await page.$$eval(selectors.COLOR_RECT_SELECTOR, network_colors_after_colouring_I => { + const network_colors_after_colouring_I = await control_panel_page.$$eval(selectors.COLOR_RECT_SELECTOR, network_colors_after_colouring_I => { return network_colors_after_colouring_I.map(network_color_after_colouring_I => network_color_after_colouring_I.outerHTML); }); - await page.waitForTimeout(PAGE_WAIT) + await control_panel_page.waitForTimeout(PAGE_WAIT) expect(network_colors_after_colouring_I[2]).toEqual(network_colors_after_colouring_I[3]) expect(network_colors_after_colouring_I[2]).toEqual(network_colors_after_colouring_I[4]) @@ -294,16 +317,16 @@ describe('Test for the Control Panel - color picker', () => { it('Filter results from the Control panel', async () => { - await page.waitForTimeout(PAGE_WAIT) + await control_panel_page.waitForTimeout(PAGE_WAIT) console.log('Filtering results') - await page.waitForTimeout(selectors.CONTROL_PANEL_FILTER_SELECTOR, {timeout: PAGE_WAIT}) - await page.type(selectors.CONTROL_PANEL_FILTER_SELECTOR, 'E') + await control_panel_page.waitForSelector(selectors.CONTROL_PANEL_FILTER_SELECTOR, {timeout: PAGE_WAIT}) + await control_panel_page.type(selectors.CONTROL_PANEL_FILTER_SELECTOR, 'E') - await page.waitForTimeout(PAGE_WAIT) - await page.waitForSelector(selectors.NETWORKS_IN_CONTROL_PANEL_SELECTOR) + await control_panel_page.waitForTimeout(PAGE_WAIT) + await control_panel_page.waitForSelector(selectors.NETWORKS_IN_CONTROL_PANEL_SELECTOR) - const network_items = (await page.$$(selectors.NETWORK_ITEMS_CONTROL_PANEL_SELECTOR)).length; + const network_items = (await control_panel_page.$$(selectors.NETWORK_ITEMS_CONTROL_PANEL_SELECTOR)).length; await expect(network_items).toEqual(3) console.log('Results filtered successfully') diff --git a/tests/frontend/e2e/tests/EEG_and_Dipole_Tut#1.test.js b/tests/frontend/e2e/tests/EEG_and_Dipole_Tut#1.test.js index 8157091e..26f79b93 100644 --- a/tests/frontend/e2e/tests/EEG_and_Dipole_Tut#1.test.js +++ b/tests/frontend/e2e/tests/EEG_and_Dipole_Tut#1.test.js @@ -1,5 +1,6 @@ //IMPORTS: import 'expect-puppeteer'; +import puppeteer from 'puppeteer'; import { click } from './utils'; import { toMatchImageSnapshot } from 'jest-image-snapshot' expect.extend({ toMatchImageSnapshot }) @@ -36,27 +37,48 @@ const PASSWORD = 'testpassword' //TESTS: jest.setTimeout(300000); +let browser_EEG_Dipole; +let EEG_Dipole_page; beforeAll(async () => { - await page.goto(baseURL); - await page.waitForSelector(selectors.LOGIN_PAGE_SELECTOR); - await page.waitForSelector(selectors.USERNAME_SELECTOR) - await expect(page) - .toFill(selectors.USERNAME_SELECTOR, USERNAME, { timeout: TIMEOUT }); - - await page.waitForSelector(selectors.PASSWORD_SELECTOR) - await expect(page) - .toFill(selectors.PASSWORD_SELECTOR, PASSWORD, { timeout: TIMEOUT }); - - await page.click(selectors.LOGIN_BUTTON_SELECTOR) - // Wait for initial loading spinner to disappear - await page.waitForFunction(() => { - let el = document.querySelector('#loading-spinner'); - return el == null || el.clientHeight === 0; - }, { timeout: TIMEOUT }); -}); + browser_EEG_Dipole = await puppeteer.launch( + { + headless: 'new', + args: ['--no-sandbox', '--disable-setuid-sandbox'], + defaultViewport: { + width: 1300, + height: 1024 + }, + } + ); + EEG_Dipole_page = await browser_EEG_Dipole.newPage(); + await EEG_Dipole_page.goto(baseURL); + if (baseURL.includes('test.netpyne.metacell.us')) { + console.log('Logging in as test user ...') + await EEG_Dipole_page.waitForSelector(selectors.LOGIN_PAGE_SELECTOR); + await EEG_Dipole_page.waitForSelector(selectors.USERNAME_SELECTOR) + await expect(EEG_Dipole_page) + .toFill(selectors.USERNAME_SELECTOR, USERNAME, { timeout: TIMEOUT }); + + await EEG_Dipole_page.waitForSelector(selectors.PASSWORD_SELECTOR) + await expect(EEG_Dipole_page) + .toFill(selectors.PASSWORD_SELECTOR, PASSWORD, { timeout: TIMEOUT }); + + await EEG_Dipole_page.click(selectors.LOGIN_BUTTON_SELECTOR) + // Wait for initial loading spinner to disappear + await EEG_Dipole_page.waitForFunction(() => { + let el = document.querySelector('#loading-spinner'); + return el == null || el.clientHeight === 0; + }, { timeout: TIMEOUT }); + console.log('Logged in successfully') + } +}); +afterAll(async () => { + // Close the browser instance after all tests have run + await browser_EEG_Dipole.close(); + }); describe('EEG and Dipole Plot Test using Tutorial#1', () => { @@ -64,27 +86,27 @@ describe('EEG and Dipole Plot Test using Tutorial#1', () => { console.log('Opening a new NetPyNE page') - await page.on("dialog", dialog => + await EEG_Dipole_page.on("dialog", dialog => dialog.accept()); - await page.waitForSelector(selectors.SELECT_CELL_BUTTON_SELECTOR, { timeout: TIMEOUT * 6, visible: true }) - await page.waitForSelector(selectors.FILE_TAB_SELECTOR, { timeout: PAGE_WAIT * 3 }) - await page.waitForTimeout(PAGE_WAIT) - await page.click(selectors.FILE_TAB_SELECTOR) - await page.waitForSelector(selectors.NEW_FILE_SELECTOR, { timeout: PAGE_WAIT * 3 }) - await page.waitForTimeout(PAGE_WAIT) - await page.click(selectors.NEW_FILE_SELECTOR) - await page.waitForTimeout(PAGE_WAIT) - await page.waitForSelector(selectors.CONFIRM_NEW_PAGE_SELECTOR) - await page.click(selectors.CONFIRM_NEW_PAGE_SELECTOR) - await page.waitForTimeout(PAGE_WAIT * 2) - - await page.waitForFunction(() => { + await EEG_Dipole_page.waitForSelector(selectors.SELECT_CELL_BUTTON_SELECTOR, { timeout: TIMEOUT * 6, visible: true }) + await EEG_Dipole_page.waitForSelector(selectors.FILE_TAB_SELECTOR, { timeout: PAGE_WAIT * 3 }) + await EEG_Dipole_page.waitForTimeout(PAGE_WAIT) + await EEG_Dipole_page.click(selectors.FILE_TAB_SELECTOR) + await EEG_Dipole_page.waitForSelector(selectors.NEW_FILE_SELECTOR, { timeout: PAGE_WAIT * 3 }) + await EEG_Dipole_page.waitForTimeout(PAGE_WAIT) + await EEG_Dipole_page.click(selectors.NEW_FILE_SELECTOR) + await EEG_Dipole_page.waitForTimeout(PAGE_WAIT) + await EEG_Dipole_page.waitForSelector(selectors.CONFIRM_NEW_PAGE_SELECTOR) + await EEG_Dipole_page.click(selectors.CONFIRM_NEW_PAGE_SELECTOR) + await EEG_Dipole_page.waitForTimeout(PAGE_WAIT * 2) + + await EEG_Dipole_page.waitForFunction(() => { let el = document.querySelector('#loading-spinner'); return el == null || el.clientHeight === 0; }, { timeout: TIMEOUT }); - await page.waitForSelector(selectors.SELECT_CELL_BUTTON_SELECTOR, { timeout: TIMEOUT * 10 }) + await EEG_Dipole_page.waitForSelector(selectors.SELECT_CELL_BUTTON_SELECTOR, { timeout: TIMEOUT * 10 }) console.log('Page opened successfully') @@ -93,15 +115,15 @@ describe('EEG and Dipole Plot Test using Tutorial#1', () => { it('Load Tutorial#1', async () => { - await page.waitForTimeout(PAGE_WAIT * 3) - await page.waitForSelector(selectors.SELECT_CELL_BUTTON_SELECTOR, { timeout: TIMEOUT * 2 }) - await page.waitForTimeout(PAGE_WAIT * 2) - await page.click(selectors.TUTORIALS_BUTTON_SELECTOR, { timeout: TIMEOUT }) + await EEG_Dipole_page.waitForTimeout(PAGE_WAIT * 3) + await EEG_Dipole_page.waitForSelector(selectors.SELECT_CELL_BUTTON_SELECTOR, { timeout: TIMEOUT * 2 }) + await EEG_Dipole_page.waitForTimeout(PAGE_WAIT * 2) + await EEG_Dipole_page.click(selectors.TUTORIALS_BUTTON_SELECTOR, { timeout: TIMEOUT }) await console.log('Loading Tutorial #1') - await page.click(selectors.TUTORIAL_1_SELECTOR, { timeout: TIMEOUT }) - await page.waitForSelector(selectors.PYR_CELL_SELECTOR) - await page.waitForTimeout(PAGE_WAIT) + await EEG_Dipole_page.click(selectors.TUTORIAL_1_SELECTOR, { timeout: TIMEOUT }) + await EEG_Dipole_page.waitForSelector(selectors.PYR_CELL_SELECTOR) + await EEG_Dipole_page.waitForTimeout(PAGE_WAIT) }) @@ -110,40 +132,40 @@ describe('EEG and Dipole Plot Test using Tutorial#1', () => { await console.log('Setting Recording configuration') - await page.waitForSelector(selectors.CONFIGURATION_TAB_SELECTOR) - await page.click(selectors.CONFIGURATION_TAB_SELECTOR) + await EEG_Dipole_page.waitForSelector(selectors.CONFIGURATION_TAB_SELECTOR) + await EEG_Dipole_page.click(selectors.CONFIGURATION_TAB_SELECTOR) - await page.waitForSelector(selectors.RECORDING_CONFIGURATION_TAB_SELECTOR) - await page.click(selectors.RECORDING_CONFIGURATION_TAB_SELECTOR) - await page.waitForTimeout(PAGE_WAIT) + await EEG_Dipole_page.waitForSelector(selectors.RECORDING_CONFIGURATION_TAB_SELECTOR) + await EEG_Dipole_page.click(selectors.RECORDING_CONFIGURATION_TAB_SELECTOR) + await EEG_Dipole_page.waitForTimeout(PAGE_WAIT) - await page.waitForSelector(selectors.TRACES_TO_RECORD_SELECTOR) - await page.waitForTimeout(PAGE_WAIT) - await page.waitForSelector(selectors.DIPOLE_LFPYKIT_SELECTOR) + await EEG_Dipole_page.waitForSelector(selectors.TRACES_TO_RECORD_SELECTOR) + await EEG_Dipole_page.waitForTimeout(PAGE_WAIT) + await EEG_Dipole_page.waitForSelector(selectors.DIPOLE_LFPYKIT_SELECTOR) // await expect(page).toClick(selectors.DIPOLE_LFPYKIT_SELECTOR) - await page.waitForTimeout(PAGE_WAIT) - await page.click(selectors.DIPOLE_LFPYKIT_SELECTOR) - await page.waitForTimeout(PAGE_WAIT) + await EEG_Dipole_page.waitForTimeout(PAGE_WAIT) + await EEG_Dipole_page.click(selectors.DIPOLE_LFPYKIT_SELECTOR) + await EEG_Dipole_page.waitForTimeout(PAGE_WAIT) }) it('Create network', async () => { - await page.waitForSelector(selectors.MODEL_BUTTON_SELECTOR) - await page.click(selectors.MODEL_BUTTON_SELECTOR, { timeout: TIMEOUT }); - await page.waitForSelector(selectors.CREATE_NETWORK_SELECTOR) - await page.click(selectors.CREATE_NETWORK_SELECTOR, { timeout: TIMEOUT }); + await EEG_Dipole_page.waitForSelector(selectors.MODEL_BUTTON_SELECTOR) + await EEG_Dipole_page.click(selectors.MODEL_BUTTON_SELECTOR, { timeout: TIMEOUT }); + await EEG_Dipole_page.waitForSelector(selectors.CREATE_NETWORK_SELECTOR) + await EEG_Dipole_page.click(selectors.CREATE_NETWORK_SELECTOR, { timeout: TIMEOUT }); await console.log('Create network') - await page.waitForSelector(selectors.DISABLED_EEG_PLOT_SELECTOR, { timeout: TIMEOUT * 3 }) - await page.waitForSelector(selectors.DISABLED_DIPOLE_PLOT_SELECTOR, { timeout: TIMEOUT * 3 }) + await EEG_Dipole_page.waitForSelector(selectors.DISABLED_EEG_PLOT_SELECTOR, { timeout: TIMEOUT * 3 }) + await EEG_Dipole_page.waitForSelector(selectors.DISABLED_DIPOLE_PLOT_SELECTOR, { timeout: TIMEOUT * 3 }) - await page.waitForTimeout(PAGE_WAIT) + await EEG_Dipole_page.waitForTimeout(PAGE_WAIT) await console.log('... taking snapshot ...'); - await page.waitForTimeout(PAGE_WAIT); - expect(await page.screenshot()) + await EEG_Dipole_page.waitForTimeout(PAGE_WAIT); + expect(await EEG_Dipole_page.screenshot()) .toMatchImageSnapshot({ ...SNAPSHOT_OPTIONS, customSnapshotIdentifier: 'Tutorial#1 Network' @@ -152,35 +174,35 @@ describe('EEG and Dipole Plot Test using Tutorial#1', () => { it('Simulate network', async () => { - await page.waitForSelector(selectors.SIMULATE_BUTTON_SELECTOR) - await page.click(selectors.SIMULATE_BUTTON_SELECTOR, { timeout: TIMEOUT }); + await EEG_Dipole_page.waitForSelector(selectors.SIMULATE_BUTTON_SELECTOR) + await EEG_Dipole_page.click(selectors.SIMULATE_BUTTON_SELECTOR, { timeout: TIMEOUT }); await console.log('Simulate network') - await page.waitForSelector(selectors.SIMULATION_PAGE_SELECTOR, { timeout: TIMEOUT * 2 }); + await EEG_Dipole_page.waitForSelector(selectors.SIMULATION_PAGE_SELECTOR, { timeout: TIMEOUT * 2 }); - await page.waitForSelector(selectors.RASTER_PLOT_SELECTOR, { timeout: TIMEOUT * 5 }) - await page.waitForSelector(selectors.EEG_PLOT_SELECTOR, { timeout: TIMEOUT * 5 }) - await page.waitForSelector(selectors.DIPOLE_PLOT_SELECTOR, { timeout: TIMEOUT * 5 }) + await EEG_Dipole_page.waitForSelector(selectors.RASTER_PLOT_SELECTOR, { timeout: TIMEOUT * 5 }) + await EEG_Dipole_page.waitForSelector(selectors.EEG_PLOT_SELECTOR, { timeout: TIMEOUT * 5 }) + await EEG_Dipole_page.waitForSelector(selectors.DIPOLE_PLOT_SELECTOR, { timeout: TIMEOUT * 5 }) }); it('Dipole Plot', async () => { - await page.waitForTimeout(PAGE_WAIT * 2); - await page.click(selectors.DIPOLE_PLOT_SELECTOR) - await page.waitForSelector(selectors.CANVAS_SELECTOR, { timeout: TIMEOUT }) + await EEG_Dipole_page.waitForTimeout(PAGE_WAIT * 2); + await EEG_Dipole_page.click(selectors.DIPOLE_PLOT_SELECTOR) + await EEG_Dipole_page.waitForSelector(selectors.CANVAS_SELECTOR, { timeout: TIMEOUT }) await console.log('View Dipole Plot ...') - await page.waitForTimeout(PAGE_WAIT * 20); - await page.click(selectors.CONNECTIONS_PLOT_SELECTOR, { timeout: TIMEOUT }) - await page.waitForTimeout(PAGE_WAIT); - await page.click(selectors.DIPOLE_PLOT_SELECTOR) - await page.waitForSelector(selectors.CANVAS_SELECTOR, { timeout: TIMEOUT }) - await page.waitForTimeout(PAGE_WAIT * 3); + await EEG_Dipole_page.waitForTimeout(PAGE_WAIT * 20); + await EEG_Dipole_page.click(selectors.CONNECTIONS_PLOT_SELECTOR, { timeout: TIMEOUT }) + await EEG_Dipole_page.waitForTimeout(PAGE_WAIT); + await EEG_Dipole_page.click(selectors.DIPOLE_PLOT_SELECTOR) + await EEG_Dipole_page.waitForSelector(selectors.CANVAS_SELECTOR, { timeout: TIMEOUT }) + await EEG_Dipole_page.waitForTimeout(PAGE_WAIT * 3); await console.log('... taking snapshot ...'); - expect(await page.screenshot()) + expect(await EEG_Dipole_page.screenshot()) .toMatchImageSnapshot({ ...SNAPSHOT_OPTIONS, customSnapshotIdentifier: 'Dipole Plot' @@ -190,21 +212,21 @@ describe('EEG and Dipole Plot Test using Tutorial#1', () => { it('EEG Plot', async () => { - await page.waitForTimeout(PAGE_WAIT * 2); - await page.click(selectors.EEG_PLOT_SELECTOR) - await page.waitForSelector(selectors.CANVAS_SELECTOR, { timeout: TIMEOUT }) + await EEG_Dipole_page.waitForTimeout(PAGE_WAIT * 2); + await EEG_Dipole_page.click(selectors.EEG_PLOT_SELECTOR) + await EEG_Dipole_page.waitForSelector(selectors.CANVAS_SELECTOR, { timeout: TIMEOUT }) await console.log('View EEG Plot ...') - await page.waitForTimeout(PAGE_WAIT * 25); - await page.click(selectors.CONNECTIONS_PLOT_SELECTOR, { timeout: TIMEOUT }) - await page.waitForTimeout(PAGE_WAIT * 2); - await page.click(selectors.EEG_PLOT_SELECTOR) - await page.waitForSelector(selectors.CANVAS_SELECTOR, { timeout: TIMEOUT }) - await page.waitForTimeout(PAGE_WAIT * 3); + await EEG_Dipole_page.waitForTimeout(PAGE_WAIT * 25); + await EEG_Dipole_page.click(selectors.CONNECTIONS_PLOT_SELECTOR, { timeout: TIMEOUT }) + await EEG_Dipole_page.waitForTimeout(PAGE_WAIT * 2); + await EEG_Dipole_page.click(selectors.EEG_PLOT_SELECTOR) + await EEG_Dipole_page.waitForSelector(selectors.CANVAS_SELECTOR, { timeout: TIMEOUT }) + await EEG_Dipole_page.waitForTimeout(PAGE_WAIT * 3); await console.log('... taking snapshot ...'); - expect(await page.screenshot()) + expect(await EEG_Dipole_page.screenshot()) .toMatchImageSnapshot({ ...SNAPSHOT_OPTIONS, customSnapshotIdentifier: 'EEG Plot' diff --git a/tests/frontend/e2e/tests/ExperimentManager_Tut#1.test.js b/tests/frontend/e2e/tests/ExperimentManager_Tut#1.test.js index f7eae3f2..e6f1cfb6 100644 --- a/tests/frontend/e2e/tests/ExperimentManager_Tut#1.test.js +++ b/tests/frontend/e2e/tests/ExperimentManager_Tut#1.test.js @@ -1,5 +1,6 @@ //IMPORTS: import 'expect-puppeteer'; +import puppeteer from 'puppeteer'; import { click } from './utils'; import { toMatchImageSnapshot } from 'jest-image-snapshot' expect.extend({ toMatchImageSnapshot }) @@ -35,55 +36,76 @@ const PASSWORD = 'testpassword' //TESTS: jest.setTimeout(300000); - +let browser_experiment_manager; +let experiment_manager_page; describe('Experiment Manager test using Tut#1', () => { beforeAll(async () => { - await page.goto(baseURL); - await page.waitForSelector(selectors.LOGIN_PAGE_SELECTOR); - await page.waitForSelector(selectors.USERNAME_SELECTOR) - await expect(page) - .toFill(selectors.USERNAME_SELECTOR, USERNAME, { timeout: TIMEOUT }); - - await page.waitForSelector(selectors.PASSWORD_SELECTOR) - await expect(page) - .toFill(selectors.PASSWORD_SELECTOR, PASSWORD, { timeout: TIMEOUT }); - - await page.click(selectors.LOGIN_BUTTON_SELECTOR) - // Wait for initial loading spinner to disappear - await page.waitForFunction(() => { - let el = document.querySelector('#loading-spinner'); - return el == null || el.clientHeight === 0; - }, { timeout: TIMEOUT }); + browser_experiment_manager = await puppeteer.launch( + { + headless: 'new', + args: ['--no-sandbox', '--disable-setuid-sandbox'], + defaultViewport: { + width: 1300, + height: 1024 + }, + } + ); + experiment_manager_page = await browser_experiment_manager.newPage(); + await experiment_manager_page.goto(baseURL); + if (baseURL.includes('test.netpyne.metacell.us')) { + console.log('Logging in as test user ...') + await experiment_manager_page.waitForSelector(selectors.LOGIN_PAGE_SELECTOR); + await experiment_manager_page.waitForSelector(selectors.USERNAME_SELECTOR) + await expect(experiment_manager_page) + .toFill(selectors.USERNAME_SELECTOR, USERNAME, { timeout: TIMEOUT }); + + await experiment_manager_page.waitForSelector(selectors.PASSWORD_SELECTOR) + await expect(experiment_manager_page) + .toFill(selectors.PASSWORD_SELECTOR, PASSWORD, { timeout: TIMEOUT }); + + await experiment_manager_page.click(selectors.LOGIN_BUTTON_SELECTOR) + // Wait for initial loading spinner to disappear + await experiment_manager_page.waitForFunction(() => { + let el = document.querySelector('#loading-spinner'); + return el == null || el.clientHeight === 0; + }, { timeout: TIMEOUT }); + console.log('Logged in successfully') + } }); + afterAll(async () => { + // Close the browser instance after all tests have run + await browser_experiment_manager.close(); + }); + it('Open new page', async () => { console.log('Opening a new NetPyNE page') - await page.on("dialog", dialog => + await experiment_manager_page.on("dialog", dialog => dialog.accept()); - await page.waitForSelector(selectors.SELECT_CELL_BUTTON_SELECTOR, { timeout: TIMEOUT * 6, visible: true }) - await page.waitForSelector(selectors.FILE_TAB_SELECTOR, { timeout: PAGE_WAIT * 3 }) - await page.waitForTimeout(PAGE_WAIT) - await page.click(selectors.FILE_TAB_SELECTOR) - await page.waitForSelector(selectors.NEW_FILE_SELECTOR, { timeout: PAGE_WAIT * 3 }) - await page.waitForTimeout(PAGE_WAIT) - await page.click(selectors.NEW_FILE_SELECTOR) - await page.waitForTimeout(PAGE_WAIT) - await page.waitForSelector(selectors.CONFIRM_NEW_PAGE_SELECTOR) - await page.click(selectors.CONFIRM_NEW_PAGE_SELECTOR) - await page.waitForTimeout(PAGE_WAIT * 2) - - await page.waitForFunction(() => { + await experiment_manager_page.waitForSelector(selectors.SELECT_CELL_BUTTON_SELECTOR, { timeout: TIMEOUT * 6, visible: true }) + await experiment_manager_page.waitForSelector(selectors.FILE_TAB_SELECTOR, { timeout: PAGE_WAIT * 3 }) + await experiment_manager_page.waitForTimeout(PAGE_WAIT) + await experiment_manager_page.click(selectors.FILE_TAB_SELECTOR) + await experiment_manager_page.waitForSelector(selectors.NEW_FILE_SELECTOR, { timeout: PAGE_WAIT * 3 }) + await experiment_manager_page.waitForTimeout(PAGE_WAIT) + await experiment_manager_page.click(selectors.NEW_FILE_SELECTOR) + await experiment_manager_page.waitForTimeout(PAGE_WAIT) + await experiment_manager_page.waitForSelector(selectors.CONFIRM_NEW_PAGE_SELECTOR) + await experiment_manager_page.click(selectors.CONFIRM_NEW_PAGE_SELECTOR) + await experiment_manager_page.waitForTimeout(PAGE_WAIT * 2) + + await experiment_manager_page.waitForFunction(() => { let el = document.querySelector('#loading-spinner'); return el == null || el.clientHeight === 0; }, { timeout: TIMEOUT }); - await page.waitForSelector(selectors.SELECT_CELL_BUTTON_SELECTOR, { timeout: TIMEOUT * 10 }) + await experiment_manager_page.waitForSelector(selectors.SELECT_CELL_BUTTON_SELECTOR, { timeout: TIMEOUT * 10 }) console.log('Page opened successfully') @@ -91,16 +113,16 @@ describe('Experiment Manager test using Tut#1', () => { it('Load Tutorial#1', async () => { - await page.waitForTimeout(PAGE_WAIT * 2) - await page.waitForSelector(selectors.SELECT_CELL_BUTTON_SELECTOR, { timeout: TIMEOUT }) - await page.waitForTimeout(PAGE_WAIT) - await click(page, selectors.TUTORIALS_BUTTON_SELECTOR, { timeout: TIMEOUT }) + await experiment_manager_page.waitForTimeout(PAGE_WAIT * 2) + await experiment_manager_page.waitForSelector(selectors.SELECT_CELL_BUTTON_SELECTOR, { timeout: TIMEOUT }) + await experiment_manager_page.waitForTimeout(PAGE_WAIT) + await click(experiment_manager_page, selectors.TUTORIALS_BUTTON_SELECTOR, { timeout: TIMEOUT }) console.log('Tutorial #1') - await click(page, selectors.TUTORIAL_1_SELECTOR, { timeout: TIMEOUT }) - await page.waitForTimeout(PAGE_WAIT) - await page.waitForSelector(selectors.PYR_CELL_SELECTOR) - await page.waitForTimeout(PAGE_WAIT) + await click(experiment_manager_page, selectors.TUTORIAL_1_SELECTOR, { timeout: TIMEOUT }) + await experiment_manager_page.waitForTimeout(PAGE_WAIT) + await experiment_manager_page.waitForSelector(selectors.PYR_CELL_SELECTOR) + await experiment_manager_page.waitForTimeout(PAGE_WAIT) }) @@ -108,20 +130,20 @@ describe('Experiment Manager test using Tut#1', () => { it('Create network', async () => { - await page.waitForSelector(selectors.MODEL_BUTTON_SELECTOR) - await click(page, selectors.MODEL_BUTTON_SELECTOR, { timeout: TIMEOUT }); - await page.waitForSelector(selectors.CREATE_NETWORK_SELECTOR) - await click(page, selectors.CREATE_NETWORK_SELECTOR, { timeout: TIMEOUT }); + await experiment_manager_page.waitForSelector(selectors.MODEL_BUTTON_SELECTOR) + await click(experiment_manager_page, selectors.MODEL_BUTTON_SELECTOR, { timeout: TIMEOUT }); + await experiment_manager_page.waitForSelector(selectors.CREATE_NETWORK_SELECTOR) + await click(experiment_manager_page, selectors.CREATE_NETWORK_SELECTOR, { timeout: TIMEOUT }); console.log('Create network') - await page.waitForSelector(selectors.DISABLED_RASTER_PLOT_SELECTOR, { timeout: TIMEOUT * 3 }) + await experiment_manager_page.waitForSelector(selectors.DISABLED_RASTER_PLOT_SELECTOR, { timeout: TIMEOUT * 3 }) - await page.waitForTimeout(PAGE_WAIT) + await experiment_manager_page.waitForTimeout(PAGE_WAIT) console.log('... taking snapshot ...'); - await page.waitForTimeout(PAGE_WAIT); - expect(await page.screenshot()) + await experiment_manager_page.waitForTimeout(PAGE_WAIT); + expect(await experiment_manager_page.screenshot()) .toMatchImageSnapshot({ ...SNAPSHOT_OPTIONS, customSnapshotIdentifier: 'Tutorial#1 Network' @@ -132,69 +154,69 @@ describe('Experiment Manager test using Tut#1', () => { console.log('Setting up experiment') - await page.waitForSelector(selectors.EXPERIMENT_MANAGER_TAB_SELECTOR) - await page.click(selectors.EXPERIMENT_MANAGER_TAB_SELECTOR) - await page.waitForSelector(selectors.CREATE_NEW_EXPERIMENT_SELECTOR) - await page.click(selectors.CREATE_NEW_EXPERIMENT_SELECTOR) - - await page.waitForSelector(selectors.CREATE_NEW_EXPERIMENT_POPUP_SELECTOR) - await page.click(selectors.CONFIRM_SELECTOR) - await page.waitForSelector(selectors.EXPERIMENT_NAME_SELECTOR) + await experiment_manager_page.waitForSelector(selectors.EXPERIMENT_MANAGER_TAB_SELECTOR) + await experiment_manager_page.click(selectors.EXPERIMENT_MANAGER_TAB_SELECTOR) + await experiment_manager_page.waitForSelector(selectors.CREATE_NEW_EXPERIMENT_SELECTOR) + await experiment_manager_page.click(selectors.CREATE_NEW_EXPERIMENT_SELECTOR) - await expect(page).toFill(selectors.EXPERIMENT_NAME_SELECTOR, 'Test Experiment') - await page.waitForTimeout(PAGE_WAIT); + await experiment_manager_page.waitForSelector(selectors.CREATE_NEW_EXPERIMENT_POPUP_SELECTOR) + await experiment_manager_page.click(selectors.CONFIRM_SELECTOR) + await experiment_manager_page.waitForSelector(selectors.EXPERIMENT_NAME_SELECTOR, { timeout: TIMEOUT , visible: true}) + await experiment_manager_page.waitForTimeout(PAGE_WAIT); + await expect(experiment_manager_page).toFill(selectors.EXPERIMENT_NAME_SELECTOR, 'Test Experiment') + await experiment_manager_page.waitForTimeout(PAGE_WAIT); + await experiment_manager_page.waitForSelector(selectors.PARAMETER_SELECTION_SELECTOR) + await experiment_manager_page.click(selectors.PARAMETER_SELECTION_SELECTOR) - await page.click(selectors.PARAMETER_SELECTION_SELECTOR) - - await page.evaluate(() => { + await experiment_manager_page.evaluate(() => { let parameter = document.querySelectorAll('li[class="MuiAutocomplete-option"]'); for (var i = 0; i < parameter.length; i++) { parameter[i].innerHTML.includes("numCells") && parameter[i].click(); } }); - await page.waitForTimeout(PAGE_WAIT); - - const inputFromValue = await page.$eval('#undefined-from', el => el.value); - await page.click(selectors.FROM_VALUE_SELECTOR); + await experiment_manager_page.waitForTimeout(PAGE_WAIT); + await experiment_manager_page.waitForSelector(selectors.FROM_VALUE_SELECTOR); + const inputFromValue = await experiment_manager_page.$eval('#undefined-from', el => el.value); + await experiment_manager_page.click(selectors.FROM_VALUE_SELECTOR); for (let i = 0; i < inputFromValue.length; i++) { - await page.keyboard.press('Backspace'); + await experiment_manager_page.keyboard.press('Backspace'); } - await page.type(selectors.FROM_VALUE_SELECTOR, '1') - - const inputToValue = await page.$eval('#undefined-to', el => el.value); - await page.click(selectors.TO_VALUE_SELECTOR); + await experiment_manager_page.type(selectors.FROM_VALUE_SELECTOR, '1') + await experiment_manager_page.waitForSelector(selectors.TO_VALUE_SELECTOR); + const inputToValue = await experiment_manager_page.$eval('#undefined-to', el => el.value); + await experiment_manager_page.click(selectors.TO_VALUE_SELECTOR); for (let i = 0; i < inputToValue.length; i++) { - await page.keyboard.press('Backspace'); + await experiment_manager_page.keyboard.press('Backspace'); } - await page.type(selectors.TO_VALUE_SELECTOR, '4') - - const inputStepValue = await page.$eval('#undefined-step', el => el.value); - await page.click(selectors.STEP_VALUE_SELECTOR); + await experiment_manager_page.type(selectors.TO_VALUE_SELECTOR, '4') + await experiment_manager_page.waitForSelector(selectors.STEP_VALUE_SELECTOR); + const inputStepValue = await experiment_manager_page.$eval('#undefined-step', el => el.value); + await experiment_manager_page.click(selectors.STEP_VALUE_SELECTOR); for (let i = 0; i < inputStepValue.length; i++) { - await page.keyboard.press('Backspace'); + await experiment_manager_page.keyboard.press('Backspace'); } - await page.type(selectors.STEP_VALUE_SELECTOR, '1') + await experiment_manager_page.type(selectors.STEP_VALUE_SELECTOR, '1') - await page.waitForTimeout(PAGE_WAIT); + await experiment_manager_page.waitForTimeout(PAGE_WAIT); + await experiment_manager_page.waitForSelector(selectors.CREATE_EXPERIMENT_BUTTON_SELECTOR) + await experiment_manager_page.click(selectors.CREATE_EXPERIMENT_BUTTON_SELECTOR) - await page.click(selectors.CREATE_EXPERIMENT_BUTTON_SELECTOR) + await experiment_manager_page.waitForSelector(selectors.EXPERIMENT_TABLE_HEADER_SELECTOR) + await experiment_manager_page.waitForTimeout(PAGE_WAIT); - await page.waitForSelector(selectors.EXPERIMENT_TABLE_HEADER_SELECTOR) - await page.waitForTimeout(PAGE_WAIT); - - const experiment_name = await page.evaluate(() => { + const experiment_name = await experiment_manager_page.evaluate(() => { document.querySelector('h6[class="MuiTypography-root experimentHead MuiTypography-h6"]').textContent }); - const experimentName = await page.$eval('th[class="MuiTableCell-root MuiTableCell-body"]', el => el.innerText.trim()); - await page.waitForTimeout(PAGE_WAIT); + const experimentName = await experiment_manager_page.$eval('th[class="MuiTableCell-root MuiTableCell-body"]', el => el.innerText.trim()); + await experiment_manager_page.waitForTimeout(PAGE_WAIT); expect(experimentName).toBe('Test_Experiment') - await page.waitForTimeout(PAGE_WAIT); + await experiment_manager_page.waitForTimeout(PAGE_WAIT); console.log('Experiment created') @@ -202,25 +224,25 @@ describe('Experiment Manager test using Tut#1', () => { it('Simulate All conditions', async () => { - await page.waitForSelector(selectors.MODEL_BUTTON_SELECTOR) - await click(page, selectors.MODEL_BUTTON_SELECTOR, { timeout: TIMEOUT }); - await page.waitForSelector(selectors.SIMULATE_NETWORK_SELECTOR) - await click(page, selectors.SIMULATE_NETWORK_SELECTOR, { timeout: TIMEOUT }); + await experiment_manager_page.waitForSelector(selectors.MODEL_BUTTON_SELECTOR) + await click(experiment_manager_page, selectors.MODEL_BUTTON_SELECTOR, { timeout: TIMEOUT }); + await experiment_manager_page.waitForSelector(selectors.SIMULATE_NETWORK_SELECTOR) + await click(experiment_manager_page, selectors.SIMULATE_NETWORK_SELECTOR, { timeout: TIMEOUT }); console.log('Simulating all conditions') - await page.waitForSelector(selectors.SIMULATE_POPUP_SELECTOR) - await page.click(selectors.SIMULATE_POPUP_SELECTOR) - await page.waitForSelector(selectors.CONFIRM_SIMULATE_SELECTOR) - await page.click(selectors.CONFIRM_SIMULATE_SELECTOR) + await experiment_manager_page.waitForSelector(selectors.SIMULATE_POPUP_SELECTOR) + await experiment_manager_page.click(selectors.SIMULATE_POPUP_SELECTOR) + await experiment_manager_page.waitForSelector(selectors.CONFIRM_SIMULATE_SELECTOR) + await experiment_manager_page.click(selectors.CONFIRM_SIMULATE_SELECTOR) - await page.waitForTimeout(PAGE_WAIT); + await experiment_manager_page.waitForTimeout(PAGE_WAIT); - await page.waitForSelector(selectors.CONFIRM_EXPERIMENT_STARTED_SELECTOR) - await page.click(selectors.CONFIRM_EXPERIMENT_STARTED_SELECTOR) + await experiment_manager_page.waitForSelector(selectors.CONFIRM_EXPERIMENT_STARTED_SELECTOR) + await experiment_manager_page.click(selectors.CONFIRM_EXPERIMENT_STARTED_SELECTOR) - await page.waitForSelector(selectors.SIMULATION_PAGE_SELECTOR, { timeout: TIMEOUT * 2 }); - await page.waitForSelector(selectors.SIMULATION_LOADER_SELECTOR, { hidden: false, timeout: TIMEOUT * 5 }) - await page.waitForSelector(selectors.SIMULATION_LOADER_SELECTOR, { hidden: true, timeout: TIMEOUT * 10 }) + await experiment_manager_page.waitForSelector(selectors.SIMULATION_PAGE_SELECTOR, { timeout: TIMEOUT * 2 }); + await experiment_manager_page.waitForSelector(selectors.SIMULATION_LOADER_SELECTOR, { hidden: false, timeout: TIMEOUT * 5 }) + await experiment_manager_page.waitForSelector(selectors.SIMULATION_LOADER_SELECTOR, { hidden: true, timeout: TIMEOUT * 10 }) console.log('Experiment Simulation finished') }); @@ -228,43 +250,43 @@ describe('Experiment Manager test using Tut#1', () => { it('Check Experiment Condition #1', async () => { console.log('Checking experiment condition #1') + await experiment_manager_page.waitForSelector(selectors.BACK_TO_EDIT_SELECTOR) + await experiment_manager_page.click(selectors.BACK_TO_EDIT_SELECTOR) - await page.click(selectors.BACK_TO_EDIT_SELECTOR) - - await page.waitForTimeout(PAGE_WAIT * 2) + await experiment_manager_page.waitForTimeout(PAGE_WAIT * 2) - await page.waitForSelector(selectors.CELL_TYPES_TAB_SELECTOR) - await page.click(selectors.CELL_TYPES_TAB_SELECTOR) + await experiment_manager_page.waitForSelector(selectors.CELL_TYPES_TAB_SELECTOR) + await experiment_manager_page.click(selectors.CELL_TYPES_TAB_SELECTOR) - await page.evaluate(() => { + await experiment_manager_page.evaluate(() => { let sections = document.querySelectorAll('div[class="MuiButtonBase-root MuiListItem-root makeStyles-selected-23 MuiListItem-dense MuiListItem-button"]'); for (var i = 0; i < sections.length; i++) { sections[i].textContent.includes("Experiment Manager") && sections[i].click(); } }); - await page.waitForTimeout(PAGE_WAIT) + await experiment_manager_page.waitForTimeout(PAGE_WAIT) - await page.waitForSelector(selectors.EXPERIMENT_TABLE_SELECTOR) - await page.click(selectors.CREATED_EXPERIMENT_SELECTOR) + await experiment_manager_page.waitForSelector(selectors.EXPERIMENT_TABLE_SELECTOR) + await experiment_manager_page.click(selectors.CREATED_EXPERIMENT_SELECTOR) - await page.waitForSelector(selectors.EXPERIMENT_CONDIIONS_ROW_SELECTOR) + await experiment_manager_page.waitForSelector(selectors.EXPERIMENT_CONDIIONS_ROW_SELECTOR) - await page.evaluate(() => { + await experiment_manager_page.evaluate(() => { let results = document.querySelectorAll('button[title="Explore results"]'); for (var i = 0; i < results.length; i++) { results[0].innerHTML.includes("label") && results[0].click(); } }); - await page.waitForSelector(selectors.CONFIRM_SELECTOR) - await page.click(selectors.CONFIRM_SELECTOR) - await page.waitForTimeout(PAGE_WAIT) + await experiment_manager_page.waitForSelector(selectors.CONFIRM_SELECTOR) + await experiment_manager_page.click(selectors.CONFIRM_SELECTOR) + await experiment_manager_page.waitForTimeout(PAGE_WAIT) console.log('... taking snapshot ...'); - await page.waitForTimeout(PAGE_WAIT); - expect(await page.screenshot()) + await experiment_manager_page.waitForTimeout(PAGE_WAIT); + expect(await experiment_manager_page.screenshot()) .toMatchImageSnapshot({ ...SNAPSHOT_OPTIONS, customSnapshotIdentifier: 'Experiment Condition #1' @@ -279,25 +301,25 @@ describe('Experiment Manager test using Tut#1', () => { console.log('Checking experiment condition #2') - await page.waitForTimeout(PAGE_WAIT) - await page.click(selectors.BACK_TO_EDIT_SELECTOR) + await experiment_manager_page.waitForTimeout(PAGE_WAIT) + await experiment_manager_page.click(selectors.BACK_TO_EDIT_SELECTOR) - await page.waitForTimeout(PAGE_WAIT * 3) + await experiment_manager_page.waitForTimeout(PAGE_WAIT * 3) - await page.evaluate(() => { + await experiment_manager_page.evaluate(() => { let results = document.querySelectorAll('button[title="Explore results"]'); for (var i = 0; i < results.length; i++) { results[1].innerHTML.includes("label") && results[1].click(); } }); - await page.waitForSelector(selectors.CONFIRM_SELECTOR) - await page.click(selectors.CONFIRM_SELECTOR) - await page.waitForTimeout(PAGE_WAIT) + await experiment_manager_page.waitForSelector(selectors.CONFIRM_SELECTOR) + await experiment_manager_page.click(selectors.CONFIRM_SELECTOR) + await experiment_manager_page.waitForTimeout(PAGE_WAIT) console.log('... taking snapshot ...'); - await page.waitForTimeout(PAGE_WAIT); - expect(await page.screenshot()) + await experiment_manager_page.waitForTimeout(PAGE_WAIT); + expect(await experiment_manager_page.screenshot()) .toMatchImageSnapshot({ ...SNAPSHOT_OPTIONS, customSnapshotIdentifier: 'Experiment Condition #2' @@ -310,25 +332,26 @@ describe('Experiment Manager test using Tut#1', () => { console.log('Checking experiment condition #3') - await page.waitForTimeout(PAGE_WAIT) - await page.click(selectors.BACK_TO_EDIT_SELECTOR) + await experiment_manager_page.waitForTimeout(PAGE_WAIT) + await experiment_manager_page.waitForSelector(selectors.BACK_TO_EDIT_SELECTOR) + await experiment_manager_page.click(selectors.BACK_TO_EDIT_SELECTOR) - await page.waitForTimeout(PAGE_WAIT * 3) + await experiment_manager_page.waitForTimeout(PAGE_WAIT * 3) - await page.evaluate(() => { + await experiment_manager_page.evaluate(() => { let results = document.querySelectorAll('button[title="Explore results"]'); for (var i = 0; i < results.length; i++) { results[2].innerHTML.includes("label") && results[2].click(); } }); - await page.waitForSelector(selectors.CONFIRM_SELECTOR) - await page.click(selectors.CONFIRM_SELECTOR) - await page.waitForTimeout(PAGE_WAIT) + await experiment_manager_page.waitForSelector(selectors.CONFIRM_SELECTOR) + await experiment_manager_page.click(selectors.CONFIRM_SELECTOR) + await experiment_manager_page.waitForTimeout(PAGE_WAIT) console.log('... taking snapshot ...'); - await page.waitForTimeout(PAGE_WAIT); - expect(await page.screenshot()) + await experiment_manager_page.waitForTimeout(PAGE_WAIT); + expect(await experiment_manager_page.screenshot()) .toMatchImageSnapshot({ ...SNAPSHOT_OPTIONS, customSnapshotIdentifier: 'Experiment Condition #3' @@ -341,26 +364,27 @@ describe('Experiment Manager test using Tut#1', () => { console.log('Deleting experiment') - await page.waitForTimeout(PAGE_WAIT) - await page.click(selectors.BACK_TO_EDIT_SELECTOR) - - await page.waitForTimeout(PAGE_WAIT) + await experiment_manager_page.waitForTimeout(PAGE_WAIT) + await experiment_manager_page.waitForSelector(selectors.BACK_TO_EDIT_SELECTOR) + await experiment_manager_page.click(selectors.BACK_TO_EDIT_SELECTOR) - await page.click(selectors.EDIT_EXPERIMENT_BACK_SELECTOR) + await experiment_manager_page.waitForTimeout(PAGE_WAIT) + await experiment_manager_page.waitForSelector(selectors.EDIT_EXPERIMENT_BACK_SELECTOR) + await experiment_manager_page.click(selectors.EDIT_EXPERIMENT_BACK_SELECTOR) - await page.waitForTimeout(PAGE_WAIT) + await experiment_manager_page.waitForTimeout(PAGE_WAIT) - await page.evaluate(() => { + await experiment_manager_page.evaluate(() => { let results = document.querySelectorAll('button[class="MuiButtonBase-root MuiButton-root MuiButton-text experimentIcon"]'); for (var i = 0; i < results.length; i++) { results[1].innerHTML.includes("label") && results[1].click(); } }); - await page.waitForSelector(selectors.CONFIRM_SELECTOR) - await page.click(selectors.CONFIRM_SELECTOR) + await experiment_manager_page.waitForSelector(selectors.CONFIRM_SELECTOR) + await experiment_manager_page.click(selectors.CONFIRM_SELECTOR) - await page.waitForFunction(() => !document.querySelector('tr[class="MuiTableRow-root"]')); + await experiment_manager_page.waitForFunction(() => !document.querySelector('tr[class="MuiTableRow-root"]')); }) diff --git a/tests/frontend/e2e/tests/RxD.test.js b/tests/frontend/e2e/tests/RxD.test.js index fa8cefd8..bbbc03b3 100644 --- a/tests/frontend/e2e/tests/RxD.test.js +++ b/tests/frontend/e2e/tests/RxD.test.js @@ -1,5 +1,6 @@ //IMPORTS: import 'expect-puppeteer'; +import puppeteer from 'puppeteer'; import { toMatchImageSnapshot } from 'jest-image-snapshot' expect.extend({ toMatchImageSnapshot }) const path = require('path'); @@ -22,7 +23,7 @@ const SNAPSHOT_OPTIONS = { ssim: 'fast', }, failureThresholdType: 'percent', - failureThreshold: 0.05 + failureThreshold: 0.5 }; @@ -38,53 +39,75 @@ const PASSWORD = 'testpassword' //TESTS: jest.setTimeout(600000); +let browser_RxD; +let RxD_page; describe('RxD testing', () => { beforeAll(async () => { - await page.goto(baseURL); - await page.waitForSelector(selectors.LOGIN_PAGE_SELECTOR); - await page.waitForSelector(selectors.USERNAME_SELECTOR) - await expect(page) - .toFill(selectors.USERNAME_SELECTOR, USERNAME, { timeout: TIMEOUT }); - - await page.waitForSelector(selectors.PASSWORD_SELECTOR) - await expect(page) - .toFill(selectors.PASSWORD_SELECTOR, PASSWORD, { timeout: TIMEOUT }); - - await page.click(selectors.LOGIN_BUTTON_SELECTOR) - - await page.waitForFunction(() => { - let el = document.querySelector('#loading-spinner'); - return el == null || el.clientHeight === 0; - }, { timeout: TIMEOUT }); + browser_RxD = await puppeteer.launch( + { + headless: 'new', + args: ['--no-sandbox', '--disable-setuid-sandbox'], + defaultViewport: { + width: 1300, + height: 1024 + }, + } + ); + RxD_page = await browser_RxD.newPage(); + await RxD_page.goto(baseURL); + if (baseURL.includes('test.netpyne.metacell.us')) { + console.log('Logging in as test user ...') + await RxD_page.waitForSelector(selectors.LOGIN_PAGE_SELECTOR); + await RxD_page.waitForSelector(selectors.USERNAME_SELECTOR) + await expect(RxD_page) + .toFill(selectors.USERNAME_SELECTOR, USERNAME, { timeout: TIMEOUT }); + + await RxD_page.waitForSelector(selectors.PASSWORD_SELECTOR) + await expect(RxD_page) + .toFill(selectors.PASSWORD_SELECTOR, PASSWORD, { timeout: TIMEOUT }); + + await RxD_page.click(selectors.LOGIN_BUTTON_SELECTOR) + // Wait for initial loading spinner to disappear + await RxD_page.waitForFunction(() => { + let el = document.querySelector('#loading-spinner'); + return el == null || el.clientHeight === 0; + }, { timeout: TIMEOUT }); + console.log('Logged in successfully') + } }); + afterAll(async () => { + // Close the browser instance after all tests have run + await browser_RxD.close(); + }); + it('Open new page', async () => { console.log('Opening a new NetPyNE page ...') - await page.on("dialog", dialog => + await RxD_page.on("dialog", dialog => dialog.accept()); - await page.waitForSelector(selectors.SELECT_CELL_BUTTON_SELECTOR, { timeout: TIMEOUT * 6, visible: true }) - await page.waitForSelector(selectors.FILE_TAB_SELECTOR, { timeout: PAGE_WAIT * 3 }) - await page.waitForTimeout(PAGE_WAIT) - await page.click(selectors.FILE_TAB_SELECTOR) - await page.waitForSelector(selectors.NEW_FILE_SELECTOR, { timeout: PAGE_WAIT * 3 }) - await page.waitForTimeout(PAGE_WAIT) - await page.click(selectors.NEW_FILE_SELECTOR) - await page.waitForTimeout(PAGE_WAIT) - await page.waitForSelector(selectors.CONFIRM_NEW_PAGE_SELECTOR) - await page.click(selectors.CONFIRM_NEW_PAGE_SELECTOR) - await page.waitForTimeout(PAGE_WAIT * 3) - - await page.waitForFunction(() => { + await RxD_page.waitForSelector(selectors.SELECT_CELL_BUTTON_SELECTOR, { timeout: TIMEOUT * 6, visible: true }) + await RxD_page.waitForSelector(selectors.FILE_TAB_SELECTOR, { timeout: PAGE_WAIT * 3 }) + await RxD_page.waitForTimeout(PAGE_WAIT) + await RxD_page.click(selectors.FILE_TAB_SELECTOR) + await RxD_page.waitForSelector(selectors.NEW_FILE_SELECTOR, { timeout: PAGE_WAIT * 3 }) + await RxD_page.waitForTimeout(PAGE_WAIT) + await RxD_page.click(selectors.NEW_FILE_SELECTOR) + await RxD_page.waitForTimeout(PAGE_WAIT) + await RxD_page.waitForSelector(selectors.CONFIRM_NEW_PAGE_SELECTOR) + await RxD_page.click(selectors.CONFIRM_NEW_PAGE_SELECTOR) + await RxD_page.waitForTimeout(PAGE_WAIT * 3) + + await RxD_page.waitForFunction(() => { let el = document.querySelector('#loading-spinner'); return el == null || el.clientHeight === 0; }, { timeout: TIMEOUT * 3 }); - await page.waitForSelector(selectors.SELECT_CELL_BUTTON_SELECTOR, { timeout: TIMEOUT * 10 }) + await RxD_page.waitForSelector(selectors.SELECT_CELL_BUTTON_SELECTOR, { timeout: TIMEOUT * 10 }) console.log('Page opened successfully') @@ -92,19 +115,19 @@ describe('RxD testing', () => { it('Load Tutorial 3b', async () => { - await page.waitForTimeout(PAGE_WAIT * 2) - await page.waitForSelector('#selectCellButton', { timeout: TIMEOUT }) + await RxD_page.waitForTimeout(PAGE_WAIT * 2) + await RxD_page.waitForSelector('#selectCellButton', { timeout: TIMEOUT }) console.log('Loading Tutorial #3b ...') - await page.waitForTimeout(PAGE_WAIT) - await page.waitForSelector(selectors.TUTORIALS_BUTTON_SELECTOR, { timeout: TIMEOUT }) - await page.click(selectors.TUTORIALS_BUTTON_SELECTOR, { timeout: TIMEOUT }) - await page.waitForSelector(selectors.TUTORIAL_3B_SELECTOR, { timeout: TIMEOUT }) - await page.click(selectors.TUTORIAL_3B_SELECTOR, { timeout: TIMEOUT }) - await page.waitForSelector('#E') - await page.waitForSelector('#I') - await page.waitForTimeout(PAGE_WAIT) + await RxD_page.waitForTimeout(PAGE_WAIT) + await RxD_page.waitForSelector(selectors.TUTORIALS_BUTTON_SELECTOR, { timeout: TIMEOUT }) + await RxD_page.click(selectors.TUTORIALS_BUTTON_SELECTOR, { timeout: TIMEOUT }) + await RxD_page.waitForSelector(selectors.TUTORIAL_3B_SELECTOR, { timeout: TIMEOUT }) + await RxD_page.click(selectors.TUTORIAL_3B_SELECTOR, { timeout: TIMEOUT }) + await RxD_page.waitForSelector('#E') + await RxD_page.waitForSelector('#I') + await RxD_page.waitForTimeout(PAGE_WAIT) console.log('Tutorial loaded') @@ -113,26 +136,26 @@ describe('RxD testing', () => { it('Create and Simulate Network', async () => { - await page.waitForSelector(selectors.MODEL_BUTTON_SELECTOR) - await page.click(selectors.MODEL_BUTTON_SELECTOR); - await page.waitForSelector(selectors.CREATE_NETWORK_SELECTOR) - await page.click(selectors.CREATE_NETWORK_SELECTOR, { timeout: TIMEOUT }); + await RxD_page.waitForSelector(selectors.MODEL_BUTTON_SELECTOR) + await RxD_page.click(selectors.MODEL_BUTTON_SELECTOR); + await RxD_page.waitForSelector(selectors.CREATE_NETWORK_SELECTOR) + await RxD_page.click(selectors.CREATE_NETWORK_SELECTOR, { timeout: TIMEOUT }); console.log('Creating network ...') - await page.waitForTimeout(PAGE_WAIT * 3) + await RxD_page.waitForTimeout(PAGE_WAIT * 3) - await page.waitForSelector('div[title="3D Representation"][aria-disabled="false"]') - await page.waitForSelector(selectors.MODEL_BUTTON_SELECTOR, { timeout: TIMEOUT }); - await page.click(selectors.MODEL_BUTTON_SELECTOR, { timeout: TIMEOUT }); - await page.waitForSelector(selectors.SIMULATE_NETWORK_SELECTOR, { timeout: TIMEOUT }); - await page.click(selectors.SIMULATE_NETWORK_SELECTOR, { timeout: TIMEOUT }); + await RxD_page.waitForSelector('div[title="3D Representation"][aria-disabled="false"]') + await RxD_page.waitForSelector(selectors.MODEL_BUTTON_SELECTOR, { timeout: TIMEOUT }); + await RxD_page.click(selectors.MODEL_BUTTON_SELECTOR, { timeout: TIMEOUT }); + await RxD_page.waitForSelector(selectors.SIMULATE_NETWORK_SELECTOR, { timeout: TIMEOUT }); + await RxD_page.click(selectors.SIMULATE_NETWORK_SELECTOR, { timeout: TIMEOUT }); console.log('Simulating network ...') - await page.waitForSelector('div[title="Raster plot"][aria-disabled="false"]', { timeout: TIMEOUT * 3 }) - await page.waitForSelector('div[title="RxD concentration plot"][aria-disabled="false"]', { timeout: TIMEOUT * 3 }) + await RxD_page.waitForSelector('div[title="Raster plot"][aria-disabled="false"]', { timeout: TIMEOUT * 3 }) + await RxD_page.waitForSelector('div[title="RxD concentration plot"][aria-disabled="false"]', { timeout: TIMEOUT * 3 }) - await page.waitForTimeout(PAGE_WAIT) + await RxD_page.waitForTimeout(PAGE_WAIT) console.log('Network created and simulated') @@ -141,52 +164,52 @@ describe('RxD testing', () => { it('Check RxD Plot', async () => { console.log('Opening the RxD plot ...') - await page.waitForSelector('div[title="RxD concentration plot"][aria-disabled="false"]', { timeout: TIMEOUT * 3 }) - await page.click('div[title="RxD concentration plot"][aria-disabled="false"]') - await page.waitForSelector('div.flexlayout__tabset') + await RxD_page.waitForSelector('div[title="RxD concentration plot"][aria-disabled="false"]', { timeout: TIMEOUT * 3 }) + await RxD_page.click('div[title="RxD concentration plot"][aria-disabled="false"]') + await RxD_page.waitForSelector('div.flexlayout__tabset') console.log('... taking snapshot ...'); - await page.waitForTimeout(PAGE_WAIT); - expect(await page.screenshot()) + await RxD_page.waitForTimeout(PAGE_WAIT); + expect(await RxD_page.screenshot()) .toMatchImageSnapshot({ ...SNAPSHOT_OPTIONS, customSnapshotIdentifier: 'RxD Plot' }); - await page.waitForTimeout(PAGE_WAIT); + await RxD_page.waitForTimeout(PAGE_WAIT); console.log('Plot displayed') }) it('Check LFP Time Series Plot', async () => { console.log('Opening the LFP TS plot ...') - await page.waitForSelector('div[title="LFP Time Series Plot"][aria-disabled="false"]', { timeout: TIMEOUT * 3 }) - await page.click('div[title="LFP Time Series Plot"][aria-disabled="false"]') - await page.waitForSelector('div.flexlayout__tabset') + await RxD_page.waitForSelector('div[title="LFP Time Series Plot"][aria-disabled="false"]', { timeout: TIMEOUT * 3 }) + await RxD_page.click('div[title="LFP Time Series Plot"][aria-disabled="false"]') + await RxD_page.waitForSelector('div.flexlayout__tabset') console.log('... taking snapshot ...'); - await page.waitForTimeout(PAGE_WAIT); - expect(await page.screenshot()) + await RxD_page.waitForTimeout(PAGE_WAIT); + expect(await RxD_page.screenshot()) .toMatchImageSnapshot({ ...SNAPSHOT_OPTIONS, customSnapshotIdentifier: 'LFP Time Series Plot Before change' }); - await page.waitForTimeout(PAGE_WAIT); + await RxD_page.waitForTimeout(PAGE_WAIT); console.log('Plot displayed') }) it('Check LFP PSD Plot', async () => { console.log('Opening the LFP PSD plot ...') - await page.waitForSelector('div[title="LFP PSD Plot"][aria-disabled="false"]', { timeout: TIMEOUT * 3 }) - await page.click('div[title="LFP PSD Plot"][aria-disabled="false"]') - await page.waitForSelector('div.flexlayout__tabset') + await RxD_page.waitForSelector('div[title="LFP PSD Plot"][aria-disabled="false"]', { timeout: TIMEOUT * 3 }) + await RxD_page.click('div[title="LFP PSD Plot"][aria-disabled="false"]') + await RxD_page.waitForSelector('div.flexlayout__tabset') console.log('... taking snapshot ...'); - await page.waitForTimeout(PAGE_WAIT); - expect(await page.screenshot()) + await RxD_page.waitForTimeout(PAGE_WAIT); + expect(await RxD_page.screenshot()) .toMatchImageSnapshot({ ...SNAPSHOT_OPTIONS, customSnapshotIdentifier: 'LFP PSD Plot Before change' }); - await page.waitForTimeout(PAGE_WAIT); + await RxD_page.waitForTimeout(PAGE_WAIT); console.log('Plot displayed') }) @@ -194,12 +217,12 @@ describe('RxD testing', () => { it('Go back to Edit', async () => { console.log('Going back to Edit ...') - await page.waitForSelector('.MuiButtonBase-root.MuiButton-root.MuiButton-contained') - await page.evaluate(() => { + await RxD_page.waitForSelector('.MuiButtonBase-root.MuiButton-root.MuiButton-contained') + await RxD_page.evaluate(() => { [...document.querySelectorAll('.MuiButtonBase-root.MuiButton-root.MuiButton-contained')].find(element => element.innerText === "BACK TO EDIT").click(); }); - await page.waitForSelector('#E') - await page.waitForSelector('#I') + await RxD_page.waitForSelector('#E') + await RxD_page.waitForSelector('#I') console.log('Edit mode displayed') }) @@ -207,13 +230,13 @@ describe('RxD testing', () => { it('Open RxD Tab ', async () => { console.log('Opening RxD tab ...') - await page.waitForSelector('div[title="Reaction-Diffusion"]') - await page.click('div[title="Reaction-Diffusion"]') + await RxD_page.waitForSelector('div[title="Reaction-Diffusion"]') + await RxD_page.click('div[title="Reaction-Diffusion"]') - await page.waitForSelector('#simple-tabpanel-0') + await RxD_page.waitForSelector('#simple-tabpanel-0') //TO CHANGE - const regions_text = await page.$$eval('#simple-tabpanel-0', regions_text => { + const regions_text = await RxD_page.$$eval('#simple-tabpanel-0', regions_text => { return regions_text.map(regions_text => regions_text.innerText) }) @@ -226,14 +249,14 @@ describe('RxD testing', () => { it('Change RxD Configuration', async () => { console.log('Opening RxD config ...') - await page.waitForSelector('#simple-tabpanel-1') - await page.click('#simple-tab-1') + await RxD_page.waitForSelector('#simple-tabpanel-1') + await RxD_page.click('#simple-tab-1') - await page.waitForSelector('button[aria-selected="true"][id = "simple-tab-1"]') + await RxD_page.waitForSelector('button[aria-selected="true"][id = "simple-tab-1"]') - await page.waitForSelector('#ip3') + await RxD_page.waitForSelector('#ip3') console.log('Species tab opened') - await page.waitForTimeout(PAGE_WAIT) + await RxD_page.waitForTimeout(PAGE_WAIT) }) @@ -241,23 +264,23 @@ describe('RxD testing', () => { console.log('Increasing IP3 concentration ...') - await page.waitForSelector('#ip3') - await page.click('#ip3') - await page.waitForTimeout(PAGE_WAIT) - await page.waitForSelector('#netParamsrxdParamsspeciesip3regions') - await page.waitForSelector('#netParamsrxdParamsspeciesip3d') - await page.waitForSelector('#netParamsrxdParamsspeciesip3charge') - await page.waitForSelector('#netParamsrxdParamsspeciesip3initial') - await page.waitForTimeout(PAGE_WAIT) - await page.click('#netParamsrxdParamsspeciesip3initial') - await page.keyboard.press('Backspace'); - await page.keyboard.press('Backspace'); - await page.keyboard.press('Backspace'); - await page.type('#netParamsrxdParamsspeciesip3initial', '2') - await page.waitForTimeout(PAGE_WAIT) - await page.click('#netParamsrxdParamsspeciesip3charge') - await page.waitForTimeout(PAGE_WAIT) - await page.waitForSelector('#netParamsrxdParamsspeciesip3initial[value = "2"]') + await RxD_page.waitForSelector('#ip3') + await RxD_page.click('#ip3') + await RxD_page.waitForTimeout(PAGE_WAIT) + await RxD_page.waitForSelector('#netParamsrxdParamsspeciesip3regions') + await RxD_page.waitForSelector('#netParamsrxdParamsspeciesip3d') + await RxD_page.waitForSelector('#netParamsrxdParamsspeciesip3charge') + await RxD_page.waitForSelector('#netParamsrxdParamsspeciesip3initial') + await RxD_page.waitForTimeout(PAGE_WAIT) + await RxD_page.click('#netParamsrxdParamsspeciesip3initial') + await RxD_page.keyboard.press('Backspace'); + await RxD_page.keyboard.press('Backspace'); + await RxD_page.keyboard.press('Backspace'); + await RxD_page.type('#netParamsrxdParamsspeciesip3initial', '2') + await RxD_page.waitForTimeout(PAGE_WAIT) + await RxD_page.click('#netParamsrxdParamsspeciesip3charge') + await RxD_page.waitForTimeout(PAGE_WAIT) + await RxD_page.waitForSelector('#netParamsrxdParamsspeciesip3initial[value = "2"]') console.log('IP3 increased') @@ -266,19 +289,19 @@ describe('RxD testing', () => { it('Create and Simulate Network', async () => { - await page.waitForSelector(selectors.MODEL_BUTTON_SELECTOR) - await page.click(selectors.MODEL_BUTTON_SELECTOR); - await page.waitForSelector(selectors.CREATE_AND_SIMULATE_NETWORK_SELECTOR) - await page.click(selectors.CREATE_AND_SIMULATE_NETWORK_SELECTOR, { timeout: TIMEOUT }); + await RxD_page.waitForSelector(selectors.MODEL_BUTTON_SELECTOR) + await RxD_page.click(selectors.MODEL_BUTTON_SELECTOR); + await RxD_page.waitForSelector(selectors.CREATE_AND_SIMULATE_NETWORK_SELECTOR) + await RxD_page.click(selectors.CREATE_AND_SIMULATE_NETWORK_SELECTOR, { timeout: TIMEOUT }); console.log('Creating and simulating network ...') - await page.waitForTimeout(PAGE_WAIT * 3) + await RxD_page.waitForTimeout(PAGE_WAIT * 3) - await page.waitForSelector('div[title="Raster plot"][aria-disabled="false"]', { timeout: TIMEOUT * 3 }) - await page.waitForSelector('div[title="RxD concentration plot"][aria-disabled="false"]', { timeout: TIMEOUT * 3 }) + await RxD_page.waitForSelector('div[title="Raster plot"][aria-disabled="false"]', { timeout: TIMEOUT * 3 }) + await RxD_page.waitForSelector('div[title="RxD concentration plot"][aria-disabled="false"]', { timeout: TIMEOUT * 3 }) - await page.waitForTimeout(PAGE_WAIT) + await RxD_page.waitForTimeout(PAGE_WAIT) console.log('Network created and simulated') }) @@ -287,54 +310,54 @@ describe('RxD testing', () => { console.log('Opening the RxD plot ...') - await page.waitForSelector('div[title="RxD concentration plot"][aria-disabled="false"]', { timeout: TIMEOUT * 3 }) - await page.click('div[title="RxD concentration plot"][aria-disabled="false"]') - await page.waitForSelector('div.flexlayout__tabset') + await RxD_page.waitForSelector('div[title="RxD concentration plot"][aria-disabled="false"]', { timeout: TIMEOUT * 3 }) + await RxD_page.click('div[title="RxD concentration plot"][aria-disabled="false"]') + await RxD_page.waitForSelector('div.flexlayout__tabset') console.log('... taking snapshot ...'); - await page.waitForTimeout(PAGE_WAIT); - expect(await page.screenshot()) + await RxD_page.waitForTimeout(PAGE_WAIT); + expect(await RxD_page.screenshot()) .toMatchImageSnapshot({ ...SNAPSHOT_OPTIONS, customSnapshotIdentifier: 'RxD Plot' }); - await page.waitForTimeout(PAGE_WAIT); + await RxD_page.waitForTimeout(PAGE_WAIT); console.log('Plot displayed') }) it('Check LFP Time Series Plot', async () => { console.log('Opening the LFP TS plot ...') - await page.waitForSelector('div[title="LFP Time Series Plot"][aria-disabled="false"]', { timeout: TIMEOUT * 3 }) - await page.click('div[title="LFP Time Series Plot"][aria-disabled="false"]') - await page.waitForSelector('div.flexlayout__tabset') + await RxD_page.waitForSelector('div[title="LFP Time Series Plot"][aria-disabled="false"]', { timeout: TIMEOUT * 3 }) + await RxD_page.click('div[title="LFP Time Series Plot"][aria-disabled="false"]') + await RxD_page.waitForSelector('div.flexlayout__tabset') console.log('... taking snapshot ...'); - await page.waitForTimeout(PAGE_WAIT); - expect(await page.screenshot()) + await RxD_page.waitForTimeout(PAGE_WAIT); + expect(await RxD_page.screenshot()) .toMatchImageSnapshot({ ...SNAPSHOT_OPTIONS, customSnapshotIdentifier: 'LFP Time Series Plot After change' }); - await page.waitForTimeout(PAGE_WAIT); + await RxD_page.waitForTimeout(PAGE_WAIT); console.log('Plot displayed') }) it('Check LFP PSD Plot', async () => { console.log('Opening the LFP PSD plot ...') - await page.waitForSelector('div[title="LFP PSD Plot"][aria-disabled="false"]', { timeout: TIMEOUT * 3 }) - await page.click('div[title="LFP PSD Plot"][aria-disabled="false"]') - await page.waitForSelector('div.flexlayout__tabset') + await RxD_page.waitForSelector('div[title="LFP PSD Plot"][aria-disabled="false"]', { timeout: TIMEOUT * 3 }) + await RxD_page.click('div[title="LFP PSD Plot"][aria-disabled="false"]') + await RxD_page.waitForSelector('div.flexlayout__tabset') console.log('... taking snapshot ...'); - await page.waitForTimeout(PAGE_WAIT); - expect(await page.screenshot()) + await RxD_page.waitForTimeout(PAGE_WAIT); + expect(await RxD_page.screenshot()) .toMatchImageSnapshot({ ...SNAPSHOT_OPTIONS, customSnapshotIdentifier: 'LFP PSD Plot After change' }); - await page.waitForTimeout(PAGE_WAIT); + await RxD_page.waitForTimeout(PAGE_WAIT); console.log('Plot displayed') }) diff --git a/tests/frontend/e2e/tests/SaveOpenFile.test.js b/tests/frontend/e2e/tests/SaveOpenFile.test.js index 74ca4d18..bc0d4633 100644 --- a/tests/frontend/e2e/tests/SaveOpenFile.test.js +++ b/tests/frontend/e2e/tests/SaveOpenFile.test.js @@ -1,5 +1,6 @@ //IMPORTS: import 'expect-puppeteer'; +import puppeteer from 'puppeteer'; import { toMatchImageSnapshot } from 'jest-image-snapshot' expect.extend({ toMatchImageSnapshot }) const path = require('path'); @@ -38,53 +39,76 @@ const PASSWORD = 'testpassword' //TESTS: jest.setTimeout(300000); +let SaveOpen_File_browser; +let SaveOpen_File_page; + describe.skip('Save / Open File testing', () => { beforeAll(async () => { - await page.goto(baseURL); - await page.waitForSelector(selectors.LOGIN_PAGE_SELECTOR); - await page.waitForSelector(selectors.USERNAME_SELECTOR) - await expect(page) - .toFill(selectors.USERNAME_SELECTOR, USERNAME, { timeout: TIMEOUT }); - - await page.waitForSelector(selectors.PASSWORD_SELECTOR) - await expect(page) - .toFill(selectors.PASSWORD_SELECTOR, PASSWORD, { timeout: TIMEOUT }); - - await page.click(selectors.LOGIN_BUTTON_SELECTOR) - - await page.waitForFunction(() => { - let el = document.querySelector('#loading-spinner'); - return el == null || el.clientHeight === 0; - }, { timeout: TIMEOUT }); + SaveOpen_File_browser = await puppeteer.launch( + { + headless: 'new', + args: ['--no-sandbox', '--disable-setuid-sandbox'], + defaultViewport: { + width: 1300, + height: 1024 + }, + } + ); + SaveOpen_File_page = await SaveOpen_File_browser.newPage(); + await SaveOpen_File_page.goto(baseURL); + if (baseURL.includes('test.netpyne.metacell.us')) { + console.log('Logging in as test user ...') + await SaveOpen_File_page.waitForSelector(selectors.LOGIN_PAGE_SELECTOR); + await SaveOpen_File_page.waitForSelector(selectors.USERNAME_SELECTOR) + await expect(SaveOpen_File_page) + .toFill(selectors.USERNAME_SELECTOR, USERNAME, { timeout: TIMEOUT }); + + await SaveOpen_File_page.waitForSelector(selectors.PASSWORD_SELECTOR) + await expect(SaveOpen_File_page) + .toFill(selectors.PASSWORD_SELECTOR, PASSWORD, { timeout: TIMEOUT }); + + await SaveOpen_File_page.click(selectors.LOGIN_BUTTON_SELECTOR) + // Wait for initial loading spinner to disappear + await SaveOpen_File_page.waitForFunction(() => { + let el = document.querySelector('#loading-spinner'); + return el == null || el.clientHeight === 0; + }, { timeout: TIMEOUT }); + console.log('Logged in successfully') + } }); + afterAll(async () => { + // Close the browser instance after all tests have run + await SaveOpen_File_browser.close(); + }); + it('Open new page', async () => { console.log('Opening a new NetPyNE page') - await page.on("dialog", dialog => + await SaveOpen_File_page.on("dialog", dialog => dialog.accept()); - await page.waitForSelector(selectors.SELECT_CELL_BUTTON_SELECTOR, { timeout: TIMEOUT * 6, visible: true }) - await page.waitForSelector(selectors.FILE_TAB_SELECTOR, { timeout: PAGE_WAIT * 3 }) - await page.waitForTimeout(PAGE_WAIT) - await page.click(selectors.FILE_TAB_SELECTOR) - await page.waitForSelector(selectors.NEW_FILE_SELECTOR, { timeout: PAGE_WAIT * 3 }) - await page.waitForTimeout(PAGE_WAIT) - await page.click(selectors.NEW_FILE_SELECTOR) - await page.waitForTimeout(PAGE_WAIT) - await page.waitForSelector(selectors.CONFIRM_NEW_PAGE_SELECTOR) - await page.click(selectors.CONFIRM_NEW_PAGE_SELECTOR) - await page.waitForTimeout(PAGE_WAIT * 3) - - await page.waitForFunction(() => { + await SaveOpen_File_page.waitForSelector(selectors.SELECT_CELL_BUTTON_SELECTOR, { timeout: TIMEOUT * 6, visible: true }) + await SaveOpen_File_page.waitForSelector(selectors.FILE_TAB_SELECTOR, { timeout: PAGE_WAIT * 3 }) + await SaveOpen_File_page.waitForTimeout(PAGE_WAIT) + await SaveOpen_File_page.click(selectors.FILE_TAB_SELECTOR) + await SaveOpen_File_page.waitForSelector(selectors.NEW_FILE_SELECTOR, { timeout: PAGE_WAIT * 3 }) + await SaveOpen_File_page.waitForTimeout(PAGE_WAIT) + await SaveOpen_File_page.click(selectors.NEW_FILE_SELECTOR) + await SaveOpen_File_page.waitForTimeout(PAGE_WAIT) + await SaveOpen_File_page.waitForSelector(selectors.CONFIRM_NEW_PAGE_SELECTOR) + await SaveOpen_File_page.click(selectors.CONFIRM_NEW_PAGE_SELECTOR) + await SaveOpen_File_page.waitForTimeout(PAGE_WAIT * 3) + + await SaveOpen_File_page.waitForFunction(() => { let el = document.querySelector('#loading-spinner'); return el == null || el.clientHeight === 0; }, { timeout: TIMEOUT * 3 }); - await page.waitForSelector(selectors.SELECT_CELL_BUTTON_SELECTOR, { timeout: TIMEOUT * 10 }) + await SaveOpen_File_page.waitForSelector(selectors.SELECT_CELL_BUTTON_SELECTOR, { timeout: TIMEOUT * 10 }) console.log('Page opened successfully') @@ -93,65 +117,65 @@ describe.skip('Save / Open File testing', () => { it('Open model from File > Open', async () => { console.log('Opening model from File') - await page.waitForTimeout(PAGE_WAIT * 2) - await page.waitForSelector(selectors.FILE_TAB_SELECTOR) - await page.click(selectors.FILE_TAB_SELECTOR) - await page.waitForSelector(selectors.NEW_FILE_SELECTOR, { timeout: PAGE_WAIT * 3 }) - await page.waitForTimeout(PAGE_WAIT) + await SaveOpen_File_page.waitForTimeout(PAGE_WAIT * 2) + await SaveOpen_File_page.waitForSelector(selectors.FILE_TAB_SELECTOR) + await SaveOpen_File_page.click(selectors.FILE_TAB_SELECTOR) + await SaveOpen_File_page.waitForSelector(selectors.NEW_FILE_SELECTOR, { timeout: PAGE_WAIT * 3 }) + await SaveOpen_File_page.waitForTimeout(PAGE_WAIT) - await page.evaluate(async () => { + await SaveOpen_File_page.evaluate(async () => { document.getElementById("Open...").click(); }) - await page.waitForSelector(selectors.FILE_SYSTEM_SELECTOR) - await page.click(selectors.LEVEL_UP_SELECTOR) - await page.waitForTimeout(PAGE_WAIT) - await page.waitForSelector(selectors.FOLDERS_SELECTOR) + await SaveOpen_File_page.waitForSelector(selectors.FILE_SYSTEM_SELECTOR) + await SaveOpen_File_page.click(selectors.LEVEL_UP_SELECTOR) + await SaveOpen_File_page.waitForTimeout(PAGE_WAIT) + await SaveOpen_File_page.waitForSelector(selectors.FOLDERS_SELECTOR) - const folder_num = await page.$$(selectors.FOLDERS_SELECTOR) + const folder_num = await SaveOpen_File_page.$$(selectors.FOLDERS_SELECTOR) - await page.evaluate(() => { + await SaveOpen_File_page.evaluate(() => { [...document.querySelectorAll('div[class = "rst__rowContents rst__rowContentsDragDisabled"]')].find(element => element.textContent === 'src').click(); }); - await page.waitForTimeout(PAGE_WAIT) + await SaveOpen_File_page.waitForTimeout(PAGE_WAIT) - const folder_num_src = await page.$$(selectors.FOLDERS_SELECTOR) + const folder_num_src = await SaveOpen_File_page.$$(selectors.FOLDERS_SELECTOR) expect(folder_num_src.length).toBeGreaterThan(folder_num.length) - await page.evaluate(() => { + await SaveOpen_File_page.evaluate(() => { [...document.querySelectorAll('div[class = "rst__rowContents rst__rowContentsDragDisabled"]')].find(element => element.textContent === 'netpyne').click(); }); - await page.waitForTimeout(PAGE_WAIT) + await SaveOpen_File_page.waitForTimeout(PAGE_WAIT) - const folder_num_netpyne = await page.$$(selectors.FOLDERS_SELECTOR) + const folder_num_netpyne = await SaveOpen_File_page.$$(selectors.FOLDERS_SELECTOR) expect(folder_num_netpyne.length).toBeGreaterThan(folder_num_src.length) - await page.evaluate(() => { + await SaveOpen_File_page.evaluate(() => { [...document.querySelectorAll('div[class = "rst__rowContents rst__rowContentsDragDisabled"]')].find(element => element.textContent === 'examples').scrollIntoView(); }); - await page.evaluate(() => { + await SaveOpen_File_page.evaluate(() => { [...document.querySelectorAll('div[class = "rst__rowContents rst__rowContentsDragDisabled"]')].find(element => element.textContent === 'examples').click(); }); - await page.waitForTimeout(PAGE_WAIT * 2) + await SaveOpen_File_page.waitForTimeout(PAGE_WAIT * 2) - await page.evaluate(() => { + await SaveOpen_File_page.evaluate(() => { [...document.querySelectorAll('div[class = "rst__rowContents rst__rowContentsDragDisabled"]')].find(element => element.textContent === 'HybridTut').scrollIntoView(); }); - await page.evaluate(() => { + await SaveOpen_File_page.evaluate(() => { [...document.querySelectorAll('div[class = "rst__rowContents rst__rowContentsDragDisabled"]')].find(element => element.textContent === 'netClamp').click(); }); - await page.waitForTimeout(PAGE_WAIT * 2) + await SaveOpen_File_page.waitForTimeout(PAGE_WAIT * 2) - const folder_num_netClamp = await page.$$(selectors.FOLDERS_SELECTOR) + const folder_num_netClamp = await SaveOpen_File_page.$$(selectors.FOLDERS_SELECTOR) expect(folder_num_netClamp.length).toBeGreaterThan(folder_num_netpyne.length) - await page.click(selectors.SELECT_BUTTON_SELECTOR) + await SaveOpen_File_page.click(selectors.SELECT_BUTTON_SELECTOR) - await page.waitForSelector(selectors.E_RULE_SELECTOR) + await SaveOpen_File_page.waitForSelector(selectors.E_RULE_SELECTOR) console.log('Model Loaded') @@ -160,26 +184,26 @@ describe.skip('Save / Open File testing', () => { it('Create and Simulate opened model', async () => { console.log('Instantiating and Simulating model...') - await page.waitForTimeout(PAGE_WAIT) + await SaveOpen_File_page.waitForTimeout(PAGE_WAIT) - await page.waitForSelector(selectors.NETWORK_CREATION_MENU_BUTTON_SELECTOR) - await page.click(selectors.NETWORK_CREATION_MENU_BUTTON_SELECTOR) + await SaveOpen_File_page.waitForSelector(selectors.NETWORK_CREATION_MENU_BUTTON_SELECTOR) + await SaveOpen_File_page.click(selectors.NETWORK_CREATION_MENU_BUTTON_SELECTOR) - await page.waitForSelector(selectors.NETWORK_CREATION_MENU_ITEMS_SELECTOR) - await page.evaluate(() => { + await SaveOpen_File_page.waitForSelector(selectors.NETWORK_CREATION_MENU_ITEMS_SELECTOR) + await SaveOpen_File_page.evaluate(() => { [...document.querySelectorAll('#split-button-menu > li')].find(element => element.innerText === 'CREATE AND SIMULATE').click(); }); - await page.waitForSelector(selectors.NETWORK_CREATION_BUTTON_SELECTOR) - await page.click(selectors.NETWORK_CREATION_BUTTON_SELECTOR) + await SaveOpen_File_page.waitForSelector(selectors.NETWORK_CREATION_BUTTON_SELECTOR) + await SaveOpen_File_page.click(selectors.NETWORK_CREATION_BUTTON_SELECTOR) - await page.waitForSelector(selectors.CANVAS_SELECTOR, { timeout: TIMEOUT * 2 }); + await SaveOpen_File_page.waitForSelector(selectors.CANVAS_SELECTOR, { timeout: TIMEOUT * 2 }); - await page.waitForSelector(selectors.RASTER_PLOT_SELECTOR, { timeout: TIMEOUT * 3 }) + await SaveOpen_File_page.waitForSelector(selectors.RASTER_PLOT_SELECTOR, { timeout: TIMEOUT * 3 }) console.log('... taking snapshot ...'); - await page.waitForTimeout(PAGE_WAIT) - expect(await page.screenshot()) + await SaveOpen_File_page.waitForTimeout(PAGE_WAIT) + expect(await SaveOpen_File_page.screenshot()) .toMatchImageSnapshot({ ...SNAPSHOT_OPTIONS, customSnapshotIdentifier: 'NetClamp Model' @@ -190,55 +214,55 @@ describe.skip('Save / Open File testing', () => { it('Change the instantiated model', async () => { console.log('Editing model ...') - await page.evaluate(() => { + await SaveOpen_File_page.evaluate(() => { [...document.querySelectorAll('button[class = "MuiButtonBase-root MuiButton-root MuiButton-contained"]')].find(element => element.innerText === 'BACK TO EDIT').click(); }); - await page.waitForSelector(selectors.POPULATIONS_TAB_SELECTOR) - await page.click(selectors.POPULATIONS_TAB_SELECTOR) - await page.waitForSelector('#E2') + await SaveOpen_File_page.waitForSelector(selectors.POPULATIONS_TAB_SELECTOR) + await SaveOpen_File_page.click(selectors.POPULATIONS_TAB_SELECTOR) + await SaveOpen_File_page.waitForSelector('#E2') - await page.click('#E2') - await page.waitForSelector('#netParamspopParamsE2numCells') - expect(page).toFill('#netParamspopParamsE2numCells', '5') - await page.waitForTimeout(PAGE_WAIT * 2) + await SaveOpen_File_page.click('#E2') + await SaveOpen_File_page.waitForSelector('#netParamspopParamsE2numCells') + expect(SaveOpen_File_page).toFill('#netParamspopParamsE2numCells', '5') + await SaveOpen_File_page.waitForTimeout(PAGE_WAIT * 2) - await page.click('#I2') - await page.waitForSelector('#netParamspopParamsI2numCells') - expect(page).toFill('#netParamspopParamsI2numCells', '5') - await page.waitForTimeout(PAGE_WAIT * 2) + await SaveOpen_File_page.click('#I2') + await SaveOpen_File_page.waitForSelector('#netParamspopParamsI2numCells') + expect(SaveOpen_File_page).toFill('#netParamspopParamsI2numCells', '5') + await SaveOpen_File_page.waitForTimeout(PAGE_WAIT * 2) - await page.click('#E4') - await page.waitForSelector('#netParamspopParamsE4numCells') - expect(page).toFill('#netParamspopParamsE4numCells', '5') - await page.waitForTimeout(PAGE_WAIT * 2) + await SaveOpen_File_page.click('#E4') + await SaveOpen_File_page.waitForSelector('#netParamspopParamsE4numCells') + expect(SaveOpen_File_page).toFill('#netParamspopParamsE4numCells', '5') + await SaveOpen_File_page.waitForTimeout(PAGE_WAIT * 2) - await page.click('#I4') - await page.waitForSelector('#netParamspopParamsI4numCells') - expect(page).toFill('#netParamspopParamsI4numCells', '5') - await page.waitForTimeout(PAGE_WAIT * 2) + await SaveOpen_File_page.click('#I4') + await SaveOpen_File_page.waitForSelector('#netParamspopParamsI4numCells') + expect(SaveOpen_File_page).toFill('#netParamspopParamsI4numCells', '5') + await SaveOpen_File_page.waitForTimeout(PAGE_WAIT * 2) - await page.click('#E5') - await page.waitForSelector('#netParamspopParamsE5numCells') - expect(page).toFill('#netParamspopParamsE5numCells', '5') - await page.waitForTimeout(PAGE_WAIT * 2) + await SaveOpen_File_page.click('#E5') + await SaveOpen_File_page.waitForSelector('#netParamspopParamsE5numCells') + expect(SaveOpen_File_page).toFill('#netParamspopParamsE5numCells', '5') + await SaveOpen_File_page.waitForTimeout(PAGE_WAIT * 2) - await page.click('#I5') - await page.waitForSelector('#netParamspopParamsI5numCells') - expect(page).toFill('#netParamspopParamsI5numCells', '5') - await page.waitForTimeout(PAGE_WAIT * 2) + await SaveOpen_File_page.click('#I5') + await SaveOpen_File_page.waitForSelector('#netParamspopParamsI5numCells') + expect(SaveOpen_File_page).toFill('#netParamspopParamsI5numCells', '5') + await SaveOpen_File_page.waitForTimeout(PAGE_WAIT * 2) - await page.waitForSelector(selectors.MODEL_BUTTON_SELECTOR, { timeout: TIMEOUT }); - await page.click(selectors.MODEL_BUTTON_SELECTOR, { timeout: TIMEOUT }); - await page.waitForSelector(selectors.CREATE_AND_SIMULATE_NETWORK_SELECTOR, { timeout: TIMEOUT }); - await page.click(selectors.CREATE_AND_SIMULATE_NETWORK_SELECTOR, { timeout: TIMEOUT }); + await SaveOpen_File_page.waitForSelector(selectors.MODEL_BUTTON_SELECTOR, { timeout: TIMEOUT }); + await SaveOpen_File_page.click(selectors.MODEL_BUTTON_SELECTOR, { timeout: TIMEOUT }); + await SaveOpen_File_page.waitForSelector(selectors.CREATE_AND_SIMULATE_NETWORK_SELECTOR, { timeout: TIMEOUT }); + await SaveOpen_File_page.click(selectors.CREATE_AND_SIMULATE_NETWORK_SELECTOR, { timeout: TIMEOUT }); - await page.waitForSelector(selectors.CANVAS_SELECTOR, { timeout: TIMEOUT * 2 }); + await SaveOpen_File_page.waitForSelector(selectors.CANVAS_SELECTOR, { timeout: TIMEOUT * 2 }); - await page.waitForSelector(selectors.RASTER_PLOT_SELECTOR, { timeout: TIMEOUT * 3 }) + await SaveOpen_File_page.waitForSelector(selectors.RASTER_PLOT_SELECTOR, { timeout: TIMEOUT * 3 }) console.log('... taking snapshot ...'); - await page.waitForTimeout(PAGE_WAIT) - expect(await page.screenshot()) + await SaveOpen_File_page.waitForTimeout(PAGE_WAIT) + expect(await SaveOpen_File_page.screenshot()) .toMatchImageSnapshot({ ...SNAPSHOT_OPTIONS, customSnapshotIdentifier: 'Edited NetClamp Model' @@ -249,22 +273,22 @@ describe.skip('Save / Open File testing', () => { it('Save model', async () => { console.log('Saving model ...') - await page.waitForSelector(selectors.FILE_TAB_SELECTOR) - await page.click(selectors.FILE_TAB_SELECTOR) - await page.waitForSelector(selectors.NEW_FILE_SELECTOR, { timeout: PAGE_WAIT * 3 }) - await page.waitForTimeout(PAGE_WAIT) - await page.evaluate(async () => { + await SaveOpen_File_page.waitForSelector(selectors.FILE_TAB_SELECTOR) + await SaveOpen_File_page.click(selectors.FILE_TAB_SELECTOR) + await SaveOpen_File_page.waitForSelector(selectors.NEW_FILE_SELECTOR, { timeout: PAGE_WAIT * 3 }) + await SaveOpen_File_page.waitForTimeout(PAGE_WAIT) + await SaveOpen_File_page.evaluate(async () => { document.getElementById("Save...").click(); }) - await page.waitForSelector(selectors.SAVE_MENU_SELECTOR) + await SaveOpen_File_page.waitForSelector(selectors.SAVE_MENU_SELECTOR) // const inputValue = await page.$eval(selectors.PATH_INPUT_SELECTOR, el => el.value); - await page.click(selectors.PATH_INPUT_SELECTOR, { clickCount: 3 }); - await page.waitForTimeout(PAGE_WAIT) - expect(page).toFill(selectors.PATH_INPUT_SELECTOR, 'aut_test') - await page.waitForTimeout(PAGE_WAIT * 2) - await page.click(selectors.SAVE_BUTTON_SELECTOR) - await page.waitForTimeout(PAGE_WAIT) + await SaveOpen_File_page.click(selectors.PATH_INPUT_SELECTOR, { clickCount: 3 }); + await SaveOpen_File_page.waitForTimeout(PAGE_WAIT) + expect(SaveOpen_File_page).toFill(selectors.PATH_INPUT_SELECTOR, 'aut_test') + await SaveOpen_File_page.waitForTimeout(PAGE_WAIT * 2) + await SaveOpen_File_page.click(selectors.SAVE_BUTTON_SELECTOR) + await SaveOpen_File_page.waitForTimeout(PAGE_WAIT) console.log('Model saved as default') }) @@ -272,39 +296,39 @@ describe.skip('Save / Open File testing', () => { it('Save model - NetParams', async () => { console.log('Saving model with NetParams as Python ...') - await page.click(selectors.FILE_TAB_SELECTOR) - await page.waitForSelector(selectors.NEW_FILE_SELECTOR, { timeout: PAGE_WAIT * 3 }) - await page.waitForTimeout(PAGE_WAIT) - await page.evaluate(async () => { + await SaveOpen_File_page.click(selectors.FILE_TAB_SELECTOR) + await SaveOpen_File_page.waitForSelector(selectors.NEW_FILE_SELECTOR, { timeout: PAGE_WAIT * 3 }) + await SaveOpen_File_page.waitForTimeout(PAGE_WAIT) + await SaveOpen_File_page.evaluate(async () => { document.getElementById("Save...").click(); }) - await page.waitForSelector(selectors.SAVE_MENU_SELECTOR) + await SaveOpen_File_page.waitForSelector(selectors.SAVE_MENU_SELECTOR) // const inputValue = await page.$eval(selectors.PATH_INPUT_SELECTOR, el => el.value); // for (let i = 0; i < inputValue.length; i++) { // await page.keyboard.press('Backspace'); // } - await page.waitForTimeout(PAGE_WAIT) + await SaveOpen_File_page.waitForTimeout(PAGE_WAIT) - expect(page).toFill(selectors.PATH_INPUT_SELECTOR, 'aut_test_net_params') - await page.waitForTimeout(PAGE_WAIT) + expect(SaveOpen_File_page).toFill(selectors.PATH_INPUT_SELECTOR, 'aut_test_net_params') + await SaveOpen_File_page.waitForTimeout(PAGE_WAIT) - await page.evaluate(() => { + await SaveOpen_File_page.evaluate(() => { [...document.querySelectorAll('.MuiAccordionSummary-content')].find(element => element.innerText === "Advanced Options").click(); }); - await page.waitForSelector(selectors.EXPORT_OPTIONS_SELECTOR) - await page.waitForSelector(selectors.CHECKBOX_OPTION_SELECTOR) - await page.waitForTimeout(PAGE_WAIT) + await SaveOpen_File_page.waitForSelector(selectors.EXPORT_OPTIONS_SELECTOR) + await SaveOpen_File_page.waitForSelector(selectors.CHECKBOX_OPTION_SELECTOR) + await SaveOpen_File_page.waitForTimeout(PAGE_WAIT) - const checkbox_buttons = await page.$$(selectors.CHECKBOX_OPTION_SELECTOR) + const checkbox_buttons = await SaveOpen_File_page.$$(selectors.CHECKBOX_OPTION_SELECTOR) await checkbox_buttons[0].click() - await page.waitForTimeout(PAGE_WAIT) + await SaveOpen_File_page.waitForTimeout(PAGE_WAIT) - await page.waitForTimeout(PAGE_WAIT) - await page.click(selectors.SAVE_BUTTON_SELECTOR) - await page.waitForTimeout(PAGE_WAIT) + await SaveOpen_File_page.waitForTimeout(PAGE_WAIT) + await SaveOpen_File_page.click(selectors.SAVE_BUTTON_SELECTOR) + await SaveOpen_File_page.waitForTimeout(PAGE_WAIT) console.log('Model saved with NetParams as Python') @@ -313,51 +337,51 @@ describe.skip('Save / Open File testing', () => { it('Save model - SimConfig', async () => { console.log('Saving model with SimConfig as Python ...') - await page.click(selectors.FILE_TAB_SELECTOR) - await page.waitForSelector(selectors.NEW_FILE_SELECTOR, { timeout: PAGE_WAIT * 3 }) - await page.waitForTimeout(PAGE_WAIT) - await page.evaluate(async () => { + await SaveOpen_File_page.click(selectors.FILE_TAB_SELECTOR) + await SaveOpen_File_page.waitForSelector(selectors.NEW_FILE_SELECTOR, { timeout: PAGE_WAIT * 3 }) + await SaveOpen_File_page.waitForTimeout(PAGE_WAIT) + await SaveOpen_File_page.evaluate(async () => { document.getElementById("Save...").click(); }) - await page.waitForSelector(selectors.SAVE_MENU_SELECTOR) + await SaveOpen_File_page.waitForSelector(selectors.SAVE_MENU_SELECTOR) - const inputValue = await page.$eval(selectors.PATH_INPUT_SELECTOR, el => el.value); + const inputValue = await SaveOpen_File_page.$eval(selectors.PATH_INPUT_SELECTOR, el => el.value); for (let i = 0; i < inputValue.length; i++) { - await page.keyboard.press('Backspace'); + await SaveOpen_File_page.keyboard.press('Backspace'); } - await page.waitForTimeout(PAGE_WAIT) + await SaveOpen_File_page.waitForTimeout(PAGE_WAIT) - expect(page).toFill(selectors.PATH_INPUT_SELECTOR, 'aut_test_sim_config') - await page.waitForTimeout(PAGE_WAIT * 2) + expect(SaveOpen_File_page).toFill(selectors.PATH_INPUT_SELECTOR, 'aut_test_sim_config') + await SaveOpen_File_page.waitForTimeout(PAGE_WAIT * 2) - await page.evaluate(() => { + await SaveOpen_File_page.evaluate(() => { [...document.querySelectorAll('.MuiAccordionSummary-content')].find(element => element.innerText === "Advanced Options").click(); }); - await page.waitForSelector(selectors.EXPORT_OPTIONS_SELECTOR) - await page.waitForSelector(selectors.CHECKBOX_OPTION_SELECTOR) - await page.waitForTimeout(PAGE_WAIT) + await SaveOpen_File_page.waitForSelector(selectors.EXPORT_OPTIONS_SELECTOR) + await SaveOpen_File_page.waitForSelector(selectors.CHECKBOX_OPTION_SELECTOR) + await SaveOpen_File_page.waitForTimeout(PAGE_WAIT) - const checkbox_buttons = await page.$$(selectors.CHECKBOX_OPTION_SELECTOR) + const checkbox_buttons = await SaveOpen_File_page.$$(selectors.CHECKBOX_OPTION_SELECTOR) await checkbox_buttons[1].click() - await page.waitForTimeout(PAGE_WAIT) + await SaveOpen_File_page.waitForTimeout(PAGE_WAIT) - await page.waitForTimeout(PAGE_WAIT * 3) - await page.click(selectors.SAVE_BUTTON_SELECTOR) - await page.waitForTimeout(PAGE_WAIT) + await SaveOpen_File_page.waitForTimeout(PAGE_WAIT * 3) + await SaveOpen_File_page.click(selectors.SAVE_BUTTON_SELECTOR) + await SaveOpen_File_page.waitForTimeout(PAGE_WAIT) console.log('Model saved with SimConfig as Python') }) it('Check default Saved Model', async () => { console.log('Checking default saved model ...') - await page.waitForTimeout(PAGE_WAIT * 2) - await page.waitForSelector(selectors.PYTHON_CONSOLE_TAB_SELECTOR) + await SaveOpen_File_page.waitForTimeout(PAGE_WAIT * 2) + await SaveOpen_File_page.waitForSelector(selectors.PYTHON_CONSOLE_TAB_SELECTOR) - await page.click(selectors.PYTHON_CONSOLE_TAB_SELECTOR) - await page.waitForSelector(selectors.PYTHON_CONSLE_SELECTOR) + await SaveOpen_File_page.click(selectors.PYTHON_CONSOLE_TAB_SELECTOR) + await SaveOpen_File_page.waitForSelector(selectors.PYTHON_CONSLE_SELECTOR) - const elementHandle = await page.waitForSelector( + const elementHandle = await SaveOpen_File_page.waitForSelector( selectors.PYTHON_CONSOLE_FRAME_SELECTOR ); @@ -370,13 +394,13 @@ describe.skip('Save / Open File testing', () => { await line.click() await line.type('pwd') - await page.keyboard.down('Shift'); - await page.keyboard.press('Enter'); - await page.keyboard.up('Shift'); + await SaveOpen_File_page.keyboard.down('Shift'); + await SaveOpen_File_page.keyboard.press('Enter'); + await SaveOpen_File_page.keyboard.up('Shift'); await python_frame.waitForSelector(selectors.PYTHON_FIRST_OUTPUT_SELECTOR) - await page.waitForTimeout(PAGE_WAIT * 3) + await SaveOpen_File_page.waitForTimeout(PAGE_WAIT * 3) const first_code_output = await python_frame.$$eval(selectors.PYTHON_FIRST_OUTPUT_SELECTOR, pwd_code_outputs => { return pwd_code_outputs.map(pwd_code_output => pwd_code_output.innerText) @@ -388,11 +412,11 @@ describe.skip('Save / Open File testing', () => { await code_lines[1].type('cd uploads/aut_test/src') - await page.keyboard.down('Shift'); - await page.keyboard.press('Enter'); - await page.keyboard.up('Shift'); + await SaveOpen_File_page.keyboard.down('Shift'); + await SaveOpen_File_page.keyboard.press('Enter'); + await SaveOpen_File_page.keyboard.up('Shift'); - await page.waitForTimeout(PAGE_WAIT * 3) + await SaveOpen_File_page.waitForTimeout(PAGE_WAIT * 3) const second_code_output = await python_frame.$$eval(selectors.PYTHON_OUTPUT_SELECTOR, cd_code_outputs => { return cd_code_outputs.map(cd_code_output => cd_code_output.innerText) @@ -404,11 +428,11 @@ describe.skip('Save / Open File testing', () => { await ls_code_lines[2].type('ls -l') - await page.keyboard.down('Shift'); - await page.keyboard.press('Enter'); - await page.keyboard.up('Shift'); + await SaveOpen_File_page.keyboard.down('Shift'); + await SaveOpen_File_page.keyboard.press('Enter'); + await SaveOpen_File_page.keyboard.up('Shift'); - await page.waitForTimeout(PAGE_WAIT * 3) + await SaveOpen_File_page.waitForTimeout(PAGE_WAIT * 3) const third_code_output = await python_frame.$$eval(selectors.PYTHON_OUTPUT_SELECTOR, ls_code_outputs => { return ls_code_outputs.map(ls_code_output => ls_code_output.innerText) @@ -424,9 +448,9 @@ describe.skip('Save / Open File testing', () => { it('Check netParams.py Saved Model', async () => { console.log('Checking netParams.py saved model ...') - await page.waitForSelector(selectors.PYTHON_CONSLE_SELECTOR) + await SaveOpen_File_page.waitForSelector(selectors.PYTHON_CONSLE_SELECTOR) - const elementHandle = await page.waitForSelector( + const elementHandle = await SaveOpen_File_page.waitForSelector( selectors.PYTHON_CONSOLE_FRAME_SELECTOR ); @@ -438,30 +462,30 @@ describe.skip('Save / Open File testing', () => { await cd_code_lines[2].type('cd ../../') - await page.keyboard.down('Shift'); - await page.keyboard.press('Enter'); - await page.keyboard.up('Shift'); + await SaveOpen_File_page.keyboard.down('Shift'); + await SaveOpen_File_page.keyboard.press('Enter'); + await SaveOpen_File_page.keyboard.up('Shift'); - await page.waitForTimeout(PAGE_WAIT * 3) + await SaveOpen_File_page.waitForTimeout(PAGE_WAIT * 3) const net_code_lines = await python_frame.$$(selectors.PYTHON_CELL_SELECTOR) await net_code_lines[3].type('cd aut_test_net_params/src') - await page.keyboard.down('Shift'); - await page.keyboard.press('Enter'); - await page.keyboard.up('Shift'); + await SaveOpen_File_page.keyboard.down('Shift'); + await SaveOpen_File_page.keyboard.press('Enter'); + await SaveOpen_File_page.keyboard.up('Shift'); - await page.waitForTimeout(PAGE_WAIT * 3) + await SaveOpen_File_page.waitForTimeout(PAGE_WAIT * 3) const ls_code_lines = await python_frame.$$(selectors.PYTHON_CELL_SELECTOR) await ls_code_lines[4].type('ls -l') - await page.keyboard.down('Shift'); - await page.keyboard.press('Enter'); - await page.keyboard.up('Shift'); + await SaveOpen_File_page.keyboard.down('Shift'); + await SaveOpen_File_page.keyboard.press('Enter'); + await SaveOpen_File_page.keyboard.up('Shift'); - await page.waitForTimeout(PAGE_WAIT * 3) + await SaveOpen_File_page.waitForTimeout(PAGE_WAIT * 3) const netParam_code_output = await python_frame.$$eval(selectors.PYTHON_OUTPUT_SELECTOR, np_code_outputs => { return np_code_outputs.map(np_code_output => np_code_output.innerText) @@ -476,9 +500,9 @@ describe.skip('Save / Open File testing', () => { it('Check cfg.py Saved Model', async () => { console.log('Checking cfg.py saved model ...') - await page.waitForSelector(selectors.PYTHON_CONSLE_SELECTOR) + await SaveOpen_File_page.waitForSelector(selectors.PYTHON_CONSLE_SELECTOR) - const elementHandle = await page.waitForSelector( + const elementHandle = await SaveOpen_File_page.waitForSelector( selectors.PYTHON_CONSOLE_FRAME_SELECTOR ); @@ -490,30 +514,30 @@ describe.skip('Save / Open File testing', () => { await cd_code_lines[5].type('cd ../../') - await page.keyboard.down('Shift'); - await page.keyboard.press('Enter'); - await page.keyboard.up('Shift'); + await SaveOpen_File_page.keyboard.down('Shift'); + await SaveOpen_File_page.keyboard.press('Enter'); + await SaveOpen_File_page.keyboard.up('Shift'); - await page.waitForTimeout(PAGE_WAIT * 3) + await SaveOpen_File_page.waitForTimeout(PAGE_WAIT * 3) const net_code_lines = await python_frame.$$(selectors.PYTHON_CELL_SELECTOR) await net_code_lines[6].type('cd aut_test_sim_config/src') - await page.keyboard.down('Shift'); - await page.keyboard.press('Enter'); - await page.keyboard.up('Shift'); + await SaveOpen_File_page.keyboard.down('Shift'); + await SaveOpen_File_page.keyboard.press('Enter'); + await SaveOpen_File_page.keyboard.up('Shift'); - await page.waitForTimeout(PAGE_WAIT * 3) + await SaveOpen_File_page.waitForTimeout(PAGE_WAIT * 3) const ls_code_lines = await python_frame.$$(selectors.PYTHON_CELL_SELECTOR) await ls_code_lines[7].type('ls -l') - await page.keyboard.down('Shift'); - await page.keyboard.press('Enter'); - await page.keyboard.up('Shift'); + await SaveOpen_File_page.keyboard.down('Shift'); + await SaveOpen_File_page.keyboard.press('Enter'); + await SaveOpen_File_page.keyboard.up('Shift'); - await page.waitForTimeout(PAGE_WAIT * 3) + await SaveOpen_File_page.waitForTimeout(PAGE_WAIT * 3) const simConfig_code_output = await python_frame.$$eval(selectors.PYTHON_OUTPUT_SELECTOR, sc_code_outputs => { return sc_code_outputs.map(sc_code_output => sc_code_output.innerText) @@ -529,9 +553,9 @@ describe.skip('Save / Open File testing', () => { console.log('Checking the edited Populations of the saved model ...') - await page.waitForSelector(selectors.PYTHON_CONSLE_SELECTOR) + await SaveOpen_File_page.waitForSelector(selectors.PYTHON_CONSLE_SELECTOR) - const elementHandle = await page.waitForSelector( + const elementHandle = await SaveOpen_File_page.waitForSelector( selectors.PYTHON_CONSOLE_FRAME_SELECTOR ); @@ -543,11 +567,11 @@ describe.skip('Save / Open File testing', () => { await code_lines[8].type('cat netParams.json ') - await page.keyboard.down('Shift'); - await page.keyboard.press('Enter'); - await page.keyboard.up('Shift'); + await SaveOpen_File_page.keyboard.down('Shift'); + await SaveOpen_File_page.keyboard.press('Enter'); + await SaveOpen_File_page.keyboard.up('Shift'); - await page.waitForTimeout(PAGE_WAIT * 3) + await SaveOpen_File_page.waitForTimeout(PAGE_WAIT * 3) const cat_code_output = await python_frame.$$eval(selectors.PYTHON_OUTPUT_SELECTOR, cat_code_outputs => { return cat_code_outputs.map(cat_code_output => cat_code_output.innerText) diff --git a/tests/frontend/e2e/tests/TestTutorial1.js b/tests/frontend/e2e/tests/TestTutorial1.js index eac93af8..eb809a75 100644 --- a/tests/frontend/e2e/tests/TestTutorial1.js +++ b/tests/frontend/e2e/tests/TestTutorial1.js @@ -20,7 +20,7 @@ beforeAll(async () => { await page.setUserAgent('Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.100 Safari/537.36'); }); -describe('Tutorial #1', () => { +describe.skip('Tutorial #1', () => { beforeAll(async () => { await page.waitForSelector('.NetPyNE-root-1'); diff --git a/tests/frontend/e2e/tests/Tut#1_smoke.test.js b/tests/frontend/e2e/tests/Tut#1_smoke.test.js index 207f7a0b..b7158c5f 100644 --- a/tests/frontend/e2e/tests/Tut#1_smoke.test.js +++ b/tests/frontend/e2e/tests/Tut#1_smoke.test.js @@ -1,8 +1,11 @@ //IMPORTS: import 'expect-puppeteer'; +import puppeteer from 'puppeteer'; import { click } from './utils'; +// import { expect } from 'expect-puppeteer'; import { toMatchImageSnapshot } from 'jest-image-snapshot' expect.extend({ toMatchImageSnapshot }) + const path = require('path'); var scriptName = path.basename(__filename, '.js'); import * as selectors from './selectors' @@ -33,54 +36,77 @@ const PASSWORD = 'testpassword' jest.setTimeout(300000); - +let browser; +let tutorial_1_page; describe('Tutorial #1 for Smoke Testing', () => { beforeAll(async () => { - await page.goto(baseURL); - await page.waitForSelector(selectors.LOGIN_PAGE_SELECTOR); - await page.waitForSelector(selectors.USERNAME_SELECTOR) - await expect(page) - .toFill(selectors.USERNAME_SELECTOR, USERNAME, { timeout: TIMEOUT }); - - await page.waitForSelector(selectors.PASSWORD_SELECTOR) - await expect(page) - .toFill(selectors.PASSWORD_SELECTOR, PASSWORD, { timeout: TIMEOUT }); - - await page.click(selectors.LOGIN_BUTTON_SELECTOR) - // Wait for initial loading spinner to disappear - await page.waitForFunction(() => { - let el = document.querySelector('#loading-spinner'); - return el == null || el.clientHeight === 0; - }, { timeout: TIMEOUT }); + browser = await puppeteer.launch( + { + headless: 'new', + args: ['--no-sandbox', '--disable-setuid-sandbox'], + defaultViewport: { + width: 1300, + height: 1024 + }, + } + ); + tutorial_1_page = await browser.newPage(); + await tutorial_1_page.goto(baseURL); + + await tutorial_1_page.goto(baseURL); + if (baseURL.includes('test.netpyne.metacell.us')) { + console.log('Logging in as test user ...') + await tutorial_1_page.waitForSelector(selectors.LOGIN_PAGE_SELECTOR); + await tutorial_1_page.waitForSelector(selectors.USERNAME_SELECTOR) + await expect(tutorial_1_page) + .toFill(selectors.USERNAME_SELECTOR, USERNAME, { timeout: TIMEOUT }); + + await tutorial_1_page.waitForSelector(selectors.PASSWORD_SELECTOR) + await expect(tutorial_1_page) + .toFill(selectors.PASSWORD_SELECTOR, PASSWORD, { timeout: TIMEOUT }); + + await tutorial_1_page.click(selectors.LOGIN_BUTTON_SELECTOR) + // Wait for initial loading spinner to disappear + await tutorial_1_page.waitForFunction(() => { + let el = document.querySelector('#loading-spinner'); + return el == null || el.clientHeight === 0; + }, { timeout: TIMEOUT }); + console.log('Logged in successfully') + } + }); + + afterAll(async () => { + // Close the browser instance after all tests have run + await browser.close(); }); it('Open new page', async () => { console.log('Opening a new NetPyNE page') - await page.on("dialog", dialog => + await tutorial_1_page.on("dialog", dialog => dialog.accept()); - await page.waitForSelector(selectors.SELECT_CELL_BUTTON_SELECTOR, { timeout: TIMEOUT * 6, visible: true }) - await page.waitForSelector(selectors.FILE_TAB_SELECTOR, { timeout: PAGE_WAIT * 3 }) - await page.waitForTimeout(PAGE_WAIT) - await page.click(selectors.FILE_TAB_SELECTOR) - await page.waitForSelector(selectors.NEW_FILE_SELECTOR, { timeout: PAGE_WAIT * 3 }) - await page.waitForTimeout(PAGE_WAIT) - await page.click(selectors.NEW_FILE_SELECTOR) - await page.waitForTimeout(PAGE_WAIT) - await page.waitForSelector(selectors.CONFIRM_NEW_PAGE_SELECTOR) - await page.click(selectors.CONFIRM_NEW_PAGE_SELECTOR) - await page.waitForTimeout(PAGE_WAIT * 2) - - await page.waitForFunction(() => { + await tutorial_1_page.waitForSelector(selectors.SELECT_CELL_BUTTON_SELECTOR, { timeout: TIMEOUT * 6, visible: true }) + await tutorial_1_page.waitForSelector(selectors.FILE_TAB_SELECTOR, { timeout: PAGE_WAIT * 3 }) + await tutorial_1_page.waitForTimeout(PAGE_WAIT) + await tutorial_1_page.click(selectors.FILE_TAB_SELECTOR) + await tutorial_1_page.waitForSelector(selectors.NEW_FILE_SELECTOR, { timeout: PAGE_WAIT * 3 }) + await tutorial_1_page.waitForTimeout(PAGE_WAIT) + await tutorial_1_page.click(selectors.NEW_FILE_SELECTOR) + await tutorial_1_page.waitForTimeout(PAGE_WAIT) + await tutorial_1_page.waitForSelector(selectors.CONFIRM_NEW_PAGE_SELECTOR) + await tutorial_1_page.click(selectors.CONFIRM_NEW_PAGE_SELECTOR) + await tutorial_1_page.waitForTimeout(PAGE_WAIT * 2) + + await tutorial_1_page.waitForFunction(() => { let el = document.querySelector('#loading-spinner'); return el == null || el.clientHeight === 0; }, { timeout: TIMEOUT }); - await page.waitForSelector(selectors.SELECT_CELL_BUTTON_SELECTOR, { timeout: TIMEOUT * 10 }) + await tutorial_1_page.waitForSelector(selectors.SELECT_CELL_BUTTON_SELECTOR, { timeout: TIMEOUT * 10 }) console.log('Page opened successfully') @@ -89,57 +115,57 @@ describe('Tutorial #1 for Smoke Testing', () => { it('Create and Simulate network', async () => { - await page.waitForTimeout(PAGE_WAIT * 2) - await page.waitForSelector(selectors.SELECT_CELL_BUTTON_SELECTOR, { timeout: TIMEOUT }) + await tutorial_1_page.waitForTimeout(PAGE_WAIT * 2) + await tutorial_1_page.waitForSelector(selectors.SELECT_CELL_BUTTON_SELECTOR, { timeout: TIMEOUT }) console.log('Tutorial #1') - await page.waitForTimeout(PAGE_WAIT) - await page.waitForSelector(selectors.TUTORIALS_BUTTON_SELECTOR, { timeout: TIMEOUT }) - await click(page, selectors.TUTORIALS_BUTTON_SELECTOR, { timeout: TIMEOUT }) - await page.waitForSelector(selectors.TUTORIAL_1_SELECTOR, { timeout: TIMEOUT }) - await click(page, selectors.TUTORIAL_1_SELECTOR, { timeout: TIMEOUT }) - await page.waitForSelector(selectors.PYR_CELL_SELECTOR) - await page.waitForTimeout(PAGE_WAIT) + await tutorial_1_page.waitForTimeout(PAGE_WAIT) + await tutorial_1_page.waitForSelector(selectors.TUTORIALS_BUTTON_SELECTOR, { timeout: TIMEOUT }) + await click(tutorial_1_page, selectors.TUTORIALS_BUTTON_SELECTOR, { timeout: TIMEOUT }) + await tutorial_1_page.waitForSelector(selectors.TUTORIAL_1_SELECTOR, { timeout: TIMEOUT }) + await click(tutorial_1_page, selectors.TUTORIAL_1_SELECTOR, { timeout: TIMEOUT }) + await tutorial_1_page.waitForSelector(selectors.PYR_CELL_SELECTOR) + await tutorial_1_page.waitForTimeout(PAGE_WAIT) - await page.waitForSelector(selectors.MODEL_BUTTON_SELECTOR) - await click(page, selectors.MODEL_BUTTON_SELECTOR, { timeout: TIMEOUT }); - await page.waitForSelector(selectors.CREATE_NETWORK_SELECTOR) - await click(page, selectors.CREATE_NETWORK_SELECTOR, { timeout: TIMEOUT }); + await tutorial_1_page.waitForSelector(selectors.MODEL_BUTTON_SELECTOR) + await click(tutorial_1_page, selectors.MODEL_BUTTON_SELECTOR, { timeout: TIMEOUT }); + await tutorial_1_page.waitForSelector(selectors.CREATE_NETWORK_SELECTOR) + await click(tutorial_1_page, selectors.CREATE_NETWORK_SELECTOR, { timeout: TIMEOUT }); console.log('Create network') - await page.waitForTimeout(PAGE_WAIT) + await tutorial_1_page.waitForTimeout(PAGE_WAIT) console.log('... taking snapshot ...'); - await page.waitForTimeout(PAGE_WAIT); - expect(await page.screenshot()) + await tutorial_1_page.waitForTimeout(PAGE_WAIT); + expect(await tutorial_1_page.screenshot()) .toMatchImageSnapshot({ ...SNAPSHOT_OPTIONS, customSnapshotIdentifier: 'Tutorial#1 Network' }); - await click(page, selectors.MODEL_BUTTON_SELECTOR, { timeout: TIMEOUT }); - await click(page, selectors.SIMULATE_NETWORK_SELECTOR, { timeout: TIMEOUT }); + await click(tutorial_1_page, selectors.MODEL_BUTTON_SELECTOR, { timeout: TIMEOUT }); + await click(tutorial_1_page, selectors.SIMULATE_NETWORK_SELECTOR, { timeout: TIMEOUT }); console.log('Simulate network') - await page.waitForSelector(selectors.SIMULATION_PAGE_SELECTOR, { timeout: TIMEOUT * 2 }); + await tutorial_1_page.waitForSelector(selectors.SIMULATION_PAGE_SELECTOR, { timeout: TIMEOUT * 2 }); - await page.waitForTimeout(PAGE_WAIT) + await tutorial_1_page.waitForTimeout(PAGE_WAIT) }); it('Connections Plot', async () => { - await page.waitForTimeout(PAGE_WAIT * 2); - await click(page, selectors.CONNECTIONS_PLOT_SELECTOR, { timeout: TIMEOUT }) - await page.waitForSelector(selectors.CANVAS_SELECTOR, { timeout: TIMEOUT }) + await tutorial_1_page.waitForTimeout(PAGE_WAIT * 2); + await click(tutorial_1_page, selectors.CONNECTIONS_PLOT_SELECTOR, { timeout: TIMEOUT }) + await tutorial_1_page.waitForSelector(selectors.CANVAS_SELECTOR, { timeout: TIMEOUT }) console.log('View Connections Plot ...') - await page.waitForTimeout(PAGE_WAIT); + await tutorial_1_page.waitForTimeout(PAGE_WAIT); console.log('... taking snapshot ...'); - expect(await page.screenshot()) + expect(await tutorial_1_page.screenshot()) .toMatchImageSnapshot({ ...SNAPSHOT_OPTIONS, customSnapshotIdentifier: 'Connections Plot' @@ -149,13 +175,13 @@ describe('Tutorial #1 for Smoke Testing', () => { it('2D Net Plot', async () => { - await click(page, selectors.TWO_D_NET_PLOT_SELECTOR, { timeout: TIMEOUT }) - await page.waitForSelector(selectors.CANVAS_SELECTOR, { timeout: TIMEOUT }) + await click(tutorial_1_page, selectors.TWO_D_NET_PLOT_SELECTOR, { timeout: TIMEOUT }) + await tutorial_1_page.waitForSelector(selectors.CANVAS_SELECTOR, { timeout: TIMEOUT }) console.log('View 2D Net Plot ...') - await page.waitForTimeout(PAGE_WAIT * 2); + await tutorial_1_page.waitForTimeout(PAGE_WAIT * 2); console.log('... taking snapshot ...'); - expect(await page.screenshot()) + expect(await tutorial_1_page.screenshot()) .toMatchImageSnapshot({ ...SNAPSHOT_OPTIONS, customSnapshotIdentifier: '2D Net Plot' @@ -164,13 +190,13 @@ describe('Tutorial #1 for Smoke Testing', () => { it('Cell Traces Plot', async () => { - await click(page, selectors.CELL_TRACES_PLOT_SELECTOR, { timeout: TIMEOUT }) - await page.waitForSelector(selectors.CANVAS_SELECTOR, { timeout: TIMEOUT }) + await click(tutorial_1_page, selectors.CELL_TRACES_PLOT_SELECTOR, { timeout: TIMEOUT }) + await tutorial_1_page.waitForSelector(selectors.CANVAS_SELECTOR, { timeout: TIMEOUT }) console.log('View Cell Traces Plot ...') - await page.waitForTimeout(PAGE_WAIT); + await tutorial_1_page.waitForTimeout(PAGE_WAIT); console.log('... taking snapshot ...'); - expect(await page.screenshot()) + expect(await tutorial_1_page.screenshot()) .toMatchImageSnapshot({ ...SNAPSHOT_OPTIONS, customSnapshotIdentifier: 'Cell Traces Plot' @@ -179,13 +205,13 @@ describe('Tutorial #1 for Smoke Testing', () => { it('Raster Plot', async () => { - await click(page, selectors.RASTER_PLOT_SELECTOR, { timeout: TIMEOUT }) - await page.waitForSelector(selectors.CANVAS_SELECTOR, { timeout: TIMEOUT }) + await click(tutorial_1_page, selectors.RASTER_PLOT_SELECTOR, { timeout: TIMEOUT }) + await tutorial_1_page.waitForSelector(selectors.CANVAS_SELECTOR, { timeout: TIMEOUT }) console.log('View Raster Plot ...') - await page.waitForTimeout(PAGE_WAIT); + await tutorial_1_page.waitForTimeout(PAGE_WAIT); console.log('... taking snapshot ...'); - expect(await page.screenshot()) + expect(await tutorial_1_page.screenshot()) .toMatchImageSnapshot({ ...SNAPSHOT_OPTIONS, customSnapshotIdentifier: 'Raster Plot' @@ -194,13 +220,13 @@ describe('Tutorial #1 for Smoke Testing', () => { it('Spike Hist Plot', async () => { - await click(page, selectors.SPIKE_HIST_PLOT_SELECTOR, { timeout: TIMEOUT }) - await page.waitForSelector(selectors.CANVAS_SELECTOR, { timeout: TIMEOUT }) + await click(tutorial_1_page, selectors.SPIKE_HIST_PLOT_SELECTOR, { timeout: TIMEOUT }) + await tutorial_1_page.waitForSelector(selectors.CANVAS_SELECTOR, { timeout: TIMEOUT }) console.log('View Spike Hist Plot ...') - await page.waitForTimeout(PAGE_WAIT); + await tutorial_1_page.waitForTimeout(PAGE_WAIT); console.log('... taking snapshot ...'); - expect(await page.screenshot()) + expect(await tutorial_1_page.screenshot()) .toMatchImageSnapshot({ ...SNAPSHOT_OPTIONS, customSnapshotIdentifier: 'Spike Hist Plot' @@ -209,13 +235,13 @@ describe('Tutorial #1 for Smoke Testing', () => { it('Granger Plot', async () => { - await click(page, selectors.GRANGER_PLOT_SELECTOR, { timeout: TIMEOUT }) - await page.waitForSelector(selectors.CANVAS_SELECTOR, { timeout: TIMEOUT }) + await click(tutorial_1_page, selectors.GRANGER_PLOT_SELECTOR, { timeout: TIMEOUT }) + await tutorial_1_page.waitForSelector(selectors.CANVAS_SELECTOR, { timeout: TIMEOUT }) console.log('View Granger Plot ...') - await page.waitForTimeout(PAGE_WAIT); + await tutorial_1_page.waitForTimeout(PAGE_WAIT); console.log('... taking snapshot ...'); - expect(await page.screenshot()) + expect(await tutorial_1_page.screenshot()) .toMatchImageSnapshot({ ...SNAPSHOT_OPTIONS, customSnapshotIdentifier: 'Granger Plot' @@ -224,28 +250,30 @@ describe('Tutorial #1 for Smoke Testing', () => { it('Rate Spectogram Plot', async () => { - await click(page, selectors.RATE_SPECTROGRAM_PLOT_SELECTOR, { timeout: TIMEOUT }) - await page.waitForSelector(selectors.CANVAS_SELECTOR, { timeout: TIMEOUT }) + await click(tutorial_1_page, selectors.RATE_SPECTROGRAM_PLOT_SELECTOR, { timeout: TIMEOUT }) + await tutorial_1_page.waitForSelector(selectors.CANVAS_SELECTOR, { timeout: TIMEOUT }) - await page.waitForTimeout(PAGE_WAIT); + await tutorial_1_page.waitForTimeout(PAGE_WAIT); - await click(page, selectors.CONNECTIONS_PLOT_SELECTOR, { timeout: TIMEOUT }) - await page.waitForSelector(selectors.CANVAS_SELECTOR, { timeout: TIMEOUT }) + await click(tutorial_1_page, selectors.CONNECTIONS_PLOT_SELECTOR, { timeout: TIMEOUT }) + await tutorial_1_page.waitForSelector(selectors.CANVAS_SELECTOR, { timeout: TIMEOUT }) - await page.waitForTimeout(PAGE_WAIT); + await tutorial_1_page.waitForTimeout(PAGE_WAIT); - await click(page, selectors.RATE_SPECTROGRAM_PLOT_SELECTOR, { timeout: TIMEOUT }) - await page.waitForSelector(selectors.CANVAS_SELECTOR, { timeout: TIMEOUT }) + await click(tutorial_1_page, selectors.RATE_SPECTROGRAM_PLOT_SELECTOR, { timeout: TIMEOUT }) + await tutorial_1_page.waitForSelector(selectors.CANVAS_SELECTOR, { timeout: TIMEOUT }) console.log('View Rate Spectogram Plot ...') - await page.waitForTimeout(PAGE_WAIT); + await tutorial_1_page.waitForTimeout(PAGE_WAIT); console.log('... taking snapshot ...'); - expect(await page.screenshot()) + expect(await tutorial_1_page.screenshot()) .toMatchImageSnapshot({ ...SNAPSHOT_OPTIONS, customSnapshotIdentifier: 'Rate Spectogram Plot' }); + + await tutorial_1_page.waitForTimeout(PAGE_WAIT); }); }); \ No newline at end of file diff --git a/tests/frontend/e2e/tests/Tut#2_smoke.test.js b/tests/frontend/e2e/tests/Tut#2_smoke.test.js index 9ac5921b..5ca787f8 100644 --- a/tests/frontend/e2e/tests/Tut#2_smoke.test.js +++ b/tests/frontend/e2e/tests/Tut#2_smoke.test.js @@ -1,5 +1,6 @@ //IMPORTS: import 'expect-puppeteer'; +import puppeteer from 'puppeteer'; import { click } from './utils'; import { toMatchImageSnapshot } from 'jest-image-snapshot' expect.extend({ toMatchImageSnapshot }) @@ -8,6 +9,7 @@ var scriptName = path.basename(__filename, '.js'); import * as selectors from './selectors' + //PAGE INFO: const baseURL = process.env.url || 'https://test.netpyne.metacell.us/' const PAGE_WAIT = 3000; @@ -30,55 +32,77 @@ const PASSWORD = 'testpassword' //TESTS: jest.setTimeout(300000); - - +let browser2; +let tutorial_2_page; describe('Tutorial #2 for Smoke Testing', () => { beforeAll(async () => { - await page.goto(baseURL); - await page.waitForSelector(selectors.LOGIN_PAGE_SELECTOR); - await page.waitForSelector(selectors.USERNAME_SELECTOR) - await expect(page) - .toFill(selectors.USERNAME_SELECTOR, USERNAME, { timeout: TIMEOUT }); - - await page.waitForSelector(selectors.PASSWORD_SELECTOR) - await expect(page) - .toFill(selectors.PASSWORD_SELECTOR, PASSWORD, { timeout: TIMEOUT }); - - await page.click(selectors.LOGIN_BUTTON_SELECTOR) - // Wait for initial loading spinner to disappear - await page.waitForFunction(() => { - let el = document.querySelector('#loading-spinner'); - return el == null || el.clientHeight === 0; - }, { timeout: TIMEOUT }); + browser2 = await puppeteer.launch( + { + headless: 'new', + args: ['--no-sandbox', '--disable-setuid-sandbox'], + defaultViewport: { + width: 1300, + height: 1024 + }, + } + ); + tutorial_2_page = await browser2.newPage(); + await tutorial_2_page.goto(baseURL); + + await tutorial_2_page.goto(baseURL); + if (baseURL.includes('test.netpyne.metacell.us')) { + console.log('Logging in as test user ...') + await tutorial_2_page.waitForSelector(selectors.LOGIN_PAGE_SELECTOR); + await tutorial_2_page.waitForSelector(selectors.USERNAME_SELECTOR) + await expect(tutorial_2_page) + .toFill(selectors.USERNAME_SELECTOR, USERNAME, { timeout: TIMEOUT }); + + await tutorial_2_page.waitForSelector(selectors.PASSWORD_SELECTOR) + await expect(tutorial_2_page) + .toFill(selectors.PASSWORD_SELECTOR, PASSWORD, { timeout: TIMEOUT }); + + await tutorial_2_page.click(selectors.LOGIN_BUTTON_SELECTOR) + // Wait for initial loading spinner to disappear + await tutorial_2_page.waitForFunction(() => { + let el = document.querySelector('#loading-spinner'); + return el == null || el.clientHeight === 0; + }, { timeout: TIMEOUT }); + console.log('Logged in successfully') + } + }); + + afterAll(async () => { + // Close the browser instance after all tests have run + await browser2.close(); }); it('Open new page', async () => { console.log('Opening a new NetPyNE page') - await page.on("dialog", dialog => + await tutorial_2_page.on("dialog", dialog => dialog.accept()); - await page.waitForSelector(selectors.SELECT_CELL_BUTTON_SELECTOR, { timeout: TIMEOUT * 6, visible: true }) - await page.waitForSelector(selectors.FILE_TAB_SELECTOR, { timeout: PAGE_WAIT * 3 }) - await page.waitForTimeout(PAGE_WAIT) - await page.click(selectors.FILE_TAB_SELECTOR) - await page.waitForSelector(selectors.NEW_FILE_SELECTOR, { timeout: PAGE_WAIT * 3 }) - await page.waitForTimeout(PAGE_WAIT) - await page.click(selectors.NEW_FILE_SELECTOR) - await page.waitForTimeout(PAGE_WAIT) - await page.waitForSelector(selectors.CONFIRM_NEW_PAGE_SELECTOR) - await page.click(selectors.CONFIRM_NEW_PAGE_SELECTOR) - await page.waitForTimeout(PAGE_WAIT * 2) - - await page.waitForFunction(() => { + await tutorial_2_page.waitForSelector(selectors.SELECT_CELL_BUTTON_SELECTOR, { timeout: TIMEOUT * 6, visible: true }) + await tutorial_2_page.waitForSelector(selectors.FILE_TAB_SELECTOR, { timeout: PAGE_WAIT * 3 }) + await tutorial_2_page.waitForTimeout(PAGE_WAIT) + await tutorial_2_page.click(selectors.FILE_TAB_SELECTOR) + await tutorial_2_page.waitForSelector(selectors.NEW_FILE_SELECTOR, { timeout: PAGE_WAIT * 3 }) + await tutorial_2_page.waitForTimeout(PAGE_WAIT) + await tutorial_2_page.click(selectors.NEW_FILE_SELECTOR) + await tutorial_2_page.waitForTimeout(PAGE_WAIT) + await tutorial_2_page.waitForSelector(selectors.CONFIRM_NEW_PAGE_SELECTOR) + await tutorial_2_page.click(selectors.CONFIRM_NEW_PAGE_SELECTOR) + await tutorial_2_page.waitForTimeout(PAGE_WAIT * 2) + + await tutorial_2_page.waitForFunction(() => { let el = document.querySelector('#loading-spinner'); return el == null || el.clientHeight === 0; }, { timeout: TIMEOUT }); - await page.waitForSelector(selectors.SELECT_CELL_BUTTON_SELECTOR, { timeout: TIMEOUT * 10 }) + await tutorial_2_page.waitForSelector(selectors.SELECT_CELL_BUTTON_SELECTOR, { timeout: TIMEOUT * 10 }) console.log('Page opened successfully') @@ -87,46 +111,47 @@ describe('Tutorial #2 for Smoke Testing', () => { it('Create and Simulate network', async () => { - await page.waitForTimeout(PAGE_WAIT * 2) - await page.waitForSelector(selectors.SELECT_CELL_BUTTON_SELECTOR, { timeout: TIMEOUT }) + await tutorial_2_page.waitForTimeout(PAGE_WAIT * 2) + await tutorial_2_page.waitForSelector(selectors.SELECT_CELL_BUTTON_SELECTOR, { timeout: TIMEOUT }) console.log('Tutorial #2') - await page.waitForTimeout(PAGE_WAIT) - await page.waitForSelector(selectors.TUTORIALS_BUTTON_SELECTOR, { visible: true }) - await page.click(selectors.TUTORIALS_BUTTON_SELECTOR, { timeout: TIMEOUT }) - await page.waitForSelector(selectors.TUTORIAL_2_SELECTOR, { visible: true }) - await page.click(selectors.TUTORIAL_2_SELECTOR, { timeout: TIMEOUT }) - await page.waitForSelector(selectors.PYR_2_CELL_SELECTOR) - await page.waitForSelector(selectors.INT_CELL_SELECTOR) - await page.waitForTimeout(PAGE_WAIT) + await tutorial_2_page.waitForTimeout(PAGE_WAIT) + await tutorial_2_page.waitForSelector(selectors.TUTORIALS_BUTTON_SELECTOR, { visible: true }) + await tutorial_2_page.click(selectors.TUTORIALS_BUTTON_SELECTOR, { timeout: TIMEOUT }) + await tutorial_2_page.waitForSelector(selectors.TUTORIAL_2_SELECTOR, { visible: true }) + await tutorial_2_page.click(selectors.TUTORIAL_2_SELECTOR, { timeout: TIMEOUT }) + await tutorial_2_page.waitForSelector(selectors.PYR_2_CELL_SELECTOR) + await tutorial_2_page.waitForSelector(selectors.INT_CELL_SELECTOR) + await tutorial_2_page.waitForTimeout(PAGE_WAIT) - await page.waitForSelector(selectors.MODEL_BUTTON_SELECTOR) - await page.click(selectors.MODEL_BUTTON_SELECTOR, { timeout: TIMEOUT }); - await page.waitForSelector(selectors.CREATE_NETWORK_SELECTOR) - await page.click(selectors.CREATE_NETWORK_SELECTOR, { timeout: TIMEOUT }); + await tutorial_2_page.waitForSelector(selectors.MODEL_BUTTON_SELECTOR) + await tutorial_2_page.click(selectors.MODEL_BUTTON_SELECTOR, { timeout: TIMEOUT }); + await tutorial_2_page.waitForSelector(selectors.CREATE_NETWORK_SELECTOR) + await tutorial_2_page.click(selectors.CREATE_NETWORK_SELECTOR, { timeout: TIMEOUT }); console.log('Create network') - await page.waitForTimeout(PAGE_WAIT * 3) + await tutorial_2_page.waitForTimeout(PAGE_WAIT * 3) - await page.waitForSelector(selectors.THREE_D_REP_SELECTOR) + await tutorial_2_page.waitForSelector(selectors.THREE_D_REP_SELECTOR, { timeout: TIMEOUT * 3 }) console.log('... taking snapshot ...'); - await page.waitForTimeout(PAGE_WAIT); - expect(await page.screenshot()) + await tutorial_2_page.waitForTimeout(PAGE_WAIT); + expect(await tutorial_2_page.screenshot()) .toMatchImageSnapshot({ ...SNAPSHOT_OPTIONS, customSnapshotIdentifier: 'Tutorial#2 Network' }); - - await page.click(selectors.MODEL_BUTTON_SELECTOR, { timeout: TIMEOUT }); - await page.click(selectors.SIMULATE_NETWORK_SELECTOR, { timeout: TIMEOUT }); + await tutorial_2_page.waitForSelector(selectors.MODEL_BUTTON_SELECTOR, { timeout: TIMEOUT }); + await tutorial_2_page.click(selectors.MODEL_BUTTON_SELECTOR, { timeout: TIMEOUT }); + await tutorial_2_page.waitForSelector(selectors.SIMULATE_NETWORK_SELECTOR, { timeout: TIMEOUT }); + await tutorial_2_page.click(selectors.SIMULATE_NETWORK_SELECTOR, { timeout: TIMEOUT }); console.log('Simulate network') - await page.waitForSelector(selectors.SIMULATION_PAGE_SELECTOR, { timeout: TIMEOUT * 2 }); + await tutorial_2_page.waitForSelector(selectors.SIMULATION_PAGE_SELECTOR, { timeout: TIMEOUT * 2 }); - await page.waitForSelector(selectors.RASTER_PLOT_SELECTOR, { timeout: TIMEOUT * 3 }) + await tutorial_2_page.waitForSelector(selectors.RASTER_PLOT_SELECTOR, { timeout: TIMEOUT * 3 }) }); @@ -134,14 +159,15 @@ describe('Tutorial #2 for Smoke Testing', () => { it('Connections Plot', async () => { - await page.waitForTimeout(PAGE_WAIT * 2); - await page.click(selectors.CONNECTIONS_PLOT_SELECTOR, { timeout: TIMEOUT }) - await page.waitForSelector(selectors.CANVAS_SELECTOR, { timeout: TIMEOUT }) + await tutorial_2_page.waitForTimeout(PAGE_WAIT * 2); + await tutorial_2_page.waitForSelector(selectors.CONNECTIONS_PLOT_SELECTOR, { timeout: TIMEOUT }) + await tutorial_2_page.click(selectors.CONNECTIONS_PLOT_SELECTOR, { timeout: TIMEOUT }) + await tutorial_2_page.waitForSelector(selectors.CANVAS_SELECTOR, { timeout: TIMEOUT }) console.log('View Connections Plot ...') - await page.waitForTimeout(PAGE_WAIT); + await tutorial_2_page.waitForTimeout(PAGE_WAIT); console.log('... taking snapshot ...'); - expect(await page.screenshot()) + expect(await tutorial_2_page.screenshot()) .toMatchImageSnapshot({ ...SNAPSHOT_OPTIONS, customSnapshotIdentifier: 'Connections Plot' @@ -150,14 +176,14 @@ describe('Tutorial #2 for Smoke Testing', () => { }); it('2D Net Plot', async () => { - - await page.click(selectors.TWO_D_NET_PLOT_SELECTOR, { timeout: TIMEOUT }) - await page.waitForSelector(selectors.CANVAS_SELECTOR, { timeout: TIMEOUT }) + await tutorial_2_page.waitForSelector(selectors.TWO_D_NET_PLOT_SELECTOR, { timeout: TIMEOUT }) + await tutorial_2_page.click(selectors.TWO_D_NET_PLOT_SELECTOR, { timeout: TIMEOUT }) + await tutorial_2_page.waitForSelector(selectors.CANVAS_SELECTOR, { timeout: TIMEOUT }) console.log('View 2D Net Plot ...') - await page.waitForTimeout(PAGE_WAIT); + await tutorial_2_page.waitForTimeout(PAGE_WAIT); console.log('... taking snapshot ...'); - expect(await page.screenshot()) + expect(await tutorial_2_page.screenshot()) .toMatchImageSnapshot({ ...SNAPSHOT_OPTIONS, customSnapshotIdentifier: '2D Net Plot' @@ -165,14 +191,14 @@ describe('Tutorial #2 for Smoke Testing', () => { }); it('Cell Traces Plot', async () => { - - await page.click(selectors.CELL_TRACES_PLOT_SELECTOR, { timeout: TIMEOUT }) - await page.waitForSelector(selectors.CANVAS_SELECTOR, { timeout: TIMEOUT }) + await tutorial_2_page.waitForSelector(selectors.CELL_TRACES_PLOT_SELECTOR, { timeout: TIMEOUT }) + await tutorial_2_page.click(selectors.CELL_TRACES_PLOT_SELECTOR, { timeout: TIMEOUT }) + await tutorial_2_page.waitForSelector(selectors.CANVAS_SELECTOR, { timeout: TIMEOUT }) console.log('View Cell Traces Plot ...') - await page.waitForTimeout(PAGE_WAIT); + await tutorial_2_page.waitForTimeout(PAGE_WAIT); console.log('... taking snapshot ...'); - expect(await page.screenshot()) + expect(await tutorial_2_page.screenshot()) .toMatchImageSnapshot({ ...SNAPSHOT_OPTIONS, customSnapshotIdentifier: 'Cell Traces Plot' @@ -180,14 +206,14 @@ describe('Tutorial #2 for Smoke Testing', () => { }); it('Raster Plot', async () => { - - await page.click(selectors.RASTER_PLOT_SELECTOR, { timeout: TIMEOUT }) - await page.waitForSelector(selectors.CANVAS_SELECTOR, { timeout: TIMEOUT }) + await tutorial_2_page.waitForSelector(selectors.RASTER_PLOT_SELECTOR, { timeout: TIMEOUT }) + await tutorial_2_page.click(selectors.RASTER_PLOT_SELECTOR, { timeout: TIMEOUT }) + await tutorial_2_page.waitForSelector(selectors.CANVAS_SELECTOR, { timeout: TIMEOUT }) console.log('View Raster Plot ...') - await page.waitForTimeout(PAGE_WAIT * 3); + await tutorial_2_page.waitForTimeout(PAGE_WAIT * 3); console.log('... taking snapshot ...'); - expect(await page.screenshot()) + expect(await tutorial_2_page.screenshot()) .toMatchImageSnapshot({ ...SNAPSHOT_OPTIONS, customSnapshotIdentifier: 'Raster Plot' @@ -195,14 +221,14 @@ describe('Tutorial #2 for Smoke Testing', () => { }); it('Spike Hist Plot', async () => { - - await page.click(selectors.SPIKE_HIST_PLOT_SELECTOR, { timeout: TIMEOUT }) - await page.waitForSelector(selectors.CANVAS_SELECTOR, { timeout: TIMEOUT }) + await tutorial_2_page.waitForSelector(selectors.SPIKE_HIST_PLOT_SELECTOR, { timeout: TIMEOUT }) + await tutorial_2_page.click(selectors.SPIKE_HIST_PLOT_SELECTOR, { timeout: TIMEOUT }) + await tutorial_2_page.waitForSelector(selectors.CANVAS_SELECTOR, { timeout: TIMEOUT }) console.log('View Spike Hist Plot ...') - await page.waitForTimeout(PAGE_WAIT); + await tutorial_2_page.waitForTimeout(PAGE_WAIT); console.log('... taking snapshot ...'); - expect(await page.screenshot()) + expect(await tutorial_2_page.screenshot()) .toMatchImageSnapshot({ ...SNAPSHOT_OPTIONS, customSnapshotIdentifier: 'Spike Hist Plot' @@ -210,14 +236,14 @@ describe('Tutorial #2 for Smoke Testing', () => { }); it('Granger Plot', async () => { - - await page.click(selectors.GRANGER_PLOT_SELECTOR, { timeout: TIMEOUT }) - await page.waitForSelector(selectors.CANVAS_SELECTOR, { timeout: TIMEOUT }) + await tutorial_2_page.waitForSelector(selectors.GRANGER_PLOT_SELECTOR, { timeout: TIMEOUT }) + await tutorial_2_page.click(selectors.GRANGER_PLOT_SELECTOR, { timeout: TIMEOUT }) + await tutorial_2_page.waitForSelector(selectors.CANVAS_SELECTOR, { timeout: TIMEOUT }) console.log('View Granger Plot ...') - await page.waitForTimeout(PAGE_WAIT); + await tutorial_2_page.waitForTimeout(PAGE_WAIT); console.log('... taking snapshot ...'); - expect(await page.screenshot()) + expect(await tutorial_2_page.screenshot()) .toMatchImageSnapshot({ ...SNAPSHOT_OPTIONS, customSnapshotIdentifier: 'Granger Plot' @@ -225,25 +251,25 @@ describe('Tutorial #2 for Smoke Testing', () => { }); it('Rate Spectogram Plot', async () => { - await page.waitForSelector(selectors.RATE_SPECTROGRAM_PLOT_SELECTOR, { visible: true }) - await page.click(selectors.RATE_SPECTROGRAM_PLOT_SELECTOR, { timeout: TIMEOUT }) - await page.waitForSelector(selectors.CANVAS_SELECTOR, { timeout: TIMEOUT }) + await tutorial_2_page.waitForSelector(selectors.RATE_SPECTROGRAM_PLOT_SELECTOR, { visible: true, timeout: TIMEOUT}) + await tutorial_2_page.click(selectors.RATE_SPECTROGRAM_PLOT_SELECTOR, { timeout: TIMEOUT }) + await tutorial_2_page.waitForSelector(selectors.CANVAS_SELECTOR, { timeout: TIMEOUT }) - await page.waitForTimeout(PAGE_WAIT); + await tutorial_2_page.waitForTimeout(PAGE_WAIT); - await page.click(selectors.CONNECTIONS_PLOT_SELECTOR, { timeout: TIMEOUT }) - await page.waitForSelector(selectors.CANVAS_SELECTOR, { timeout: TIMEOUT }) + await tutorial_2_page.click(selectors.CONNECTIONS_PLOT_SELECTOR, { timeout: TIMEOUT }) + await tutorial_2_page.waitForSelector(selectors.CANVAS_SELECTOR, { timeout: TIMEOUT }) - await page.waitForTimeout(PAGE_WAIT); + await tutorial_2_page.waitForTimeout(PAGE_WAIT); - await page.click(selectors.RATE_SPECTROGRAM_PLOT_SELECTOR, { timeout: TIMEOUT }) - await page.waitForSelector(selectors.CANVAS_SELECTOR, { timeout: TIMEOUT }) + await tutorial_2_page.click(selectors.RATE_SPECTROGRAM_PLOT_SELECTOR, { timeout: TIMEOUT }) + await tutorial_2_page.waitForSelector(selectors.CANVAS_SELECTOR, { timeout: TIMEOUT }) console.log('View Rate Spectogram Plot ...') - await page.waitForTimeout(PAGE_WAIT); + await tutorial_2_page.waitForTimeout(PAGE_WAIT); console.log('... taking snapshot ...'); - expect(await page.screenshot()) + expect(await tutorial_2_page.screenshot()) .toMatchImageSnapshot({ ...SNAPSHOT_OPTIONS, customSnapshotIdentifier: 'Rate Spectogram Plot' diff --git a/tests/frontend/e2e/tests/Tut#3a_smoke.test.js b/tests/frontend/e2e/tests/Tut#3a_smoke.test.js index d7aafeae..302e4014 100644 --- a/tests/frontend/e2e/tests/Tut#3a_smoke.test.js +++ b/tests/frontend/e2e/tests/Tut#3a_smoke.test.js @@ -1,5 +1,6 @@ //IMPORTS: import 'expect-puppeteer'; +import puppeteer from 'puppeteer'; import { click } from './utils'; import { toMatchImageSnapshot } from 'jest-image-snapshot' expect.extend({ toMatchImageSnapshot }) @@ -31,55 +32,76 @@ const PASSWORD = 'testpassword' //TESTS: jest.setTimeout(300000); - +let browser3; +let tutorial_3a_page; describe('Tutorial #3a for Smoke Testing', () => { beforeAll(async () => { - await page.goto(baseURL); - await page.waitForSelector(selectors.LOGIN_PAGE_SELECTOR); - await page.waitForSelector(selectors.USERNAME_SELECTOR) - await expect(page) - .toFill(selectors.USERNAME_SELECTOR, USERNAME, { timeout: TIMEOUT }); - - await page.waitForSelector(selectors.PASSWORD_SELECTOR) - await expect(page) - .toFill(selectors.PASSWORD_SELECTOR, PASSWORD, { timeout: TIMEOUT }); - - await page.click(selectors.LOGIN_BUTTON_SELECTOR) - // Wait for initial loading spinner to disappear - await page.waitForFunction(() => { - let el = document.querySelector('#loading-spinner'); - return el == null || el.clientHeight === 0; - }, { timeout: TIMEOUT }); + browser3 = await puppeteer.launch( + { + headless: 'new', + args: ['--no-sandbox', '--disable-setuid-sandbox'], + defaultViewport: { + width: 1300, + height: 1024 + }, + } + ); + tutorial_3a_page = await browser3.newPage(); + await tutorial_3a_page.goto(baseURL); + if (baseURL.includes('test.netpyne.metacell.us')) { + console.log('Logging in as test user ...') + await tutorial_3a_page.waitForSelector(selectors.LOGIN_PAGE_SELECTOR); + await tutorial_3a_page.waitForSelector(selectors.USERNAME_SELECTOR) + await expect(tutorial_3a_page) + .toFill(selectors.USERNAME_SELECTOR, USERNAME, { timeout: TIMEOUT }); + + await tutorial_3a_page.waitForSelector(selectors.PASSWORD_SELECTOR) + await expect(tutorial_3a_page) + .toFill(selectors.PASSWORD_SELECTOR, PASSWORD, { timeout: TIMEOUT }); + + await tutorial_3a_page.click(selectors.LOGIN_BUTTON_SELECTOR) + // Wait for initial loading spinner to disappear + await tutorial_3a_page.waitForFunction(() => { + let el = document.querySelector('#loading-spinner'); + return el == null || el.clientHeight === 0; + }, { timeout: TIMEOUT }); + console.log('Logged in successfully') + } + }); + + afterAll(async () => { + // Close the browser instance after all tests have run + await browser3.close(); }); it('Open new page', async () => { console.log('Opening a new NetPyNE page') - await page.on("dialog", dialog => + await tutorial_3a_page.on("dialog", dialog => dialog.accept()); - await page.waitForSelector(selectors.SELECT_CELL_BUTTON_SELECTOR, { timeout: TIMEOUT * 6, visible: true }) - await page.waitForSelector(selectors.FILE_TAB_SELECTOR, { timeout: PAGE_WAIT * 3 }) - await page.waitForTimeout(PAGE_WAIT) - await page.click(selectors.FILE_TAB_SELECTOR) - await page.waitForSelector(selectors.NEW_FILE_SELECTOR, { timeout: PAGE_WAIT * 3 }) - await page.waitForTimeout(PAGE_WAIT) - await page.click(selectors.NEW_FILE_SELECTOR) - await page.waitForTimeout(PAGE_WAIT) - await page.waitForSelector(selectors.CONFIRM_NEW_PAGE_SELECTOR) - await page.click(selectors.CONFIRM_NEW_PAGE_SELECTOR) - await page.waitForTimeout(PAGE_WAIT * 2) - - await page.waitForFunction(() => { + await tutorial_3a_page.waitForSelector(selectors.SELECT_CELL_BUTTON_SELECTOR, { timeout: TIMEOUT * 6, visible: true }) + await tutorial_3a_page.waitForSelector(selectors.FILE_TAB_SELECTOR, { timeout: PAGE_WAIT * 3 }) + await tutorial_3a_page.waitForTimeout(PAGE_WAIT) + await tutorial_3a_page.click(selectors.FILE_TAB_SELECTOR) + await tutorial_3a_page.waitForSelector(selectors.NEW_FILE_SELECTOR, { timeout: PAGE_WAIT * 3 }) + await tutorial_3a_page.waitForTimeout(PAGE_WAIT) + await tutorial_3a_page.click(selectors.NEW_FILE_SELECTOR) + await tutorial_3a_page.waitForTimeout(PAGE_WAIT) + await tutorial_3a_page.waitForSelector(selectors.CONFIRM_NEW_PAGE_SELECTOR) + await tutorial_3a_page.click(selectors.CONFIRM_NEW_PAGE_SELECTOR) + await tutorial_3a_page.waitForTimeout(PAGE_WAIT * 2) + + await tutorial_3a_page.waitForFunction(() => { let el = document.querySelector('#loading-spinner'); return el == null || el.clientHeight === 0; }, { timeout: TIMEOUT }); - await page.waitForSelector(selectors.SELECT_CELL_BUTTON_SELECTOR, { timeout: TIMEOUT * 10 }) + await tutorial_3a_page.waitForSelector(selectors.SELECT_CELL_BUTTON_SELECTOR, { timeout: TIMEOUT * 10 }) console.log('Page opened successfully') @@ -88,49 +110,50 @@ describe('Tutorial #3a for Smoke Testing', () => { it('Create and Simulate network', async () => { - await page.waitForTimeout(PAGE_WAIT * 2) - await page.waitForSelector(selectors.SELECT_CELL_BUTTON_SELECTOR, { timeout: TIMEOUT }) + await tutorial_3a_page.waitForTimeout(PAGE_WAIT * 2) + await tutorial_3a_page.waitForSelector(selectors.SELECT_CELL_BUTTON_SELECTOR, { timeout: TIMEOUT }) console.log('Tutorial #3a') - await page.waitForTimeout(PAGE_WAIT) - await page.waitForSelector(selectors.TUTORIALS_BUTTON_SELECTOR, { visible: true }) + await tutorial_3a_page.waitForTimeout(PAGE_WAIT) + await tutorial_3a_page.waitForSelector(selectors.TUTORIALS_BUTTON_SELECTOR, { visible: true }) - await page.click(selectors.TUTORIALS_BUTTON_SELECTOR, { timeout: TIMEOUT }) - await page.waitForSelector(selectors.TUTORIAL_3A_SELECTOR, { visible: true }) - await page.click(selectors.TUTORIAL_3A_SELECTOR, { timeout: TIMEOUT }) - await page.waitForSelector(selectors.E_CELL_TYPE_SELECTOR) - await page.waitForSelector(selectors.I_CELL_TYPE_SELECTOR) - await page.waitForTimeout(PAGE_WAIT) + await tutorial_3a_page.click(selectors.TUTORIALS_BUTTON_SELECTOR, { timeout: TIMEOUT }) + await tutorial_3a_page.waitForSelector(selectors.TUTORIAL_3A_SELECTOR, { visible: true }) + await tutorial_3a_page.click(selectors.TUTORIAL_3A_SELECTOR, { timeout: TIMEOUT }) + await tutorial_3a_page.waitForSelector(selectors.E_CELL_TYPE_SELECTOR) + await tutorial_3a_page.waitForSelector(selectors.I_CELL_TYPE_SELECTOR) + await tutorial_3a_page.waitForTimeout(PAGE_WAIT) - await page.waitForSelector(selectors.MODEL_BUTTON_SELECTOR) - await page.click(selectors.MODEL_BUTTON_SELECTOR, { timeout: TIMEOUT }); - await page.waitForSelector(selectors.CREATE_NETWORK_SELECTOR) - await page.click(selectors.CREATE_NETWORK_SELECTOR, { timeout: TIMEOUT }); + await tutorial_3a_page.waitForSelector(selectors.MODEL_BUTTON_SELECTOR) + await tutorial_3a_page.click(selectors.MODEL_BUTTON_SELECTOR, { timeout: TIMEOUT }); + await tutorial_3a_page.waitForSelector(selectors.CREATE_NETWORK_SELECTOR) + await tutorial_3a_page.click(selectors.CREATE_NETWORK_SELECTOR, { timeout: TIMEOUT }); console.log('Create network') - await page.waitForTimeout(PAGE_WAIT * 3) + await tutorial_3a_page.waitForTimeout(PAGE_WAIT * 3) - await page.waitForSelector(selectors.THREE_D_REP_SELECTOR) + await tutorial_3a_page.waitForSelector(selectors.THREE_D_REP_SELECTOR, { timeout: TIMEOUT }) console.log('... taking snapshot ...'); - await page.waitForTimeout(PAGE_WAIT); - expect(await page.screenshot()) + await tutorial_3a_page.waitForTimeout(PAGE_WAIT); + expect(await tutorial_3a_page.screenshot()) .toMatchImageSnapshot({ ...SNAPSHOT_OPTIONS, customSnapshotIdentifier: 'Tutorial#3a Network' }); - - await page.click(selectors.MODEL_BUTTON_SELECTOR, { timeout: TIMEOUT }); - await page.click(selectors.SIMULATE_NETWORK_SELECTOR, { timeout: TIMEOUT }); + await tutorial_3a_page.waitForSelector(selectors.MODEL_BUTTON_SELECTOR, { timeout: TIMEOUT }); + await tutorial_3a_page.click(selectors.MODEL_BUTTON_SELECTOR, { timeout: TIMEOUT }); + await tutorial_3a_page.waitForSelector(selectors.SIMULATE_NETWORK_SELECTOR, { timeout: TIMEOUT }); + await tutorial_3a_page.click(selectors.SIMULATE_NETWORK_SELECTOR, { timeout: TIMEOUT }); console.log('Simulate network') - await page.waitForSelector(selectors.SIMULATION_PAGE_SELECTOR, { timeout: TIMEOUT * 2 }); + await tutorial_3a_page.waitForSelector(selectors.SIMULATION_PAGE_SELECTOR, { timeout: TIMEOUT * 2 }); - await page.waitForSelector(selectors.RASTER_PLOT_SELECTOR, { timeout: TIMEOUT * 10 }) + await tutorial_3a_page.waitForSelector(selectors.RASTER_PLOT_SELECTOR, { timeout: TIMEOUT * 10 }) }); @@ -138,14 +161,15 @@ describe('Tutorial #3a for Smoke Testing', () => { it('Connections Plot', async () => { - await page.waitForTimeout(PAGE_WAIT * 2); - await page.click(selectors.CONNECTIONS_PLOT_SELECTOR, { timeout: TIMEOUT }) - await page.waitForSelector(selectors.CANVAS_SELECTOR, { timeout: TIMEOUT }) + await tutorial_3a_page.waitForTimeout(PAGE_WAIT * 2); + await tutorial_3a_page.waitForSelector(selectors.CONNECTIONS_PLOT_SELECTOR, { timeout: TIMEOUT }) + await tutorial_3a_page.click(selectors.CONNECTIONS_PLOT_SELECTOR, { timeout: TIMEOUT }) + await tutorial_3a_page.waitForSelector(selectors.CANVAS_SELECTOR, { timeout: TIMEOUT }) console.log('View Connections Plot ...') - await page.waitForTimeout(PAGE_WAIT); + await tutorial_3a_page.waitForTimeout(PAGE_WAIT); console.log('... taking snapshot ...'); - expect(await page.screenshot()) + expect(await tutorial_3a_page.screenshot()) .toMatchImageSnapshot({ ...SNAPSHOT_OPTIONS, customSnapshotIdentifier: 'Connections Plot' @@ -154,14 +178,14 @@ describe('Tutorial #3a for Smoke Testing', () => { }); it('2D Net Plot', async () => { - - await page.click(selectors.TWO_D_NET_PLOT_SELECTOR, { timeout: TIMEOUT }) - await page.waitForSelector(selectors.CANVAS_SELECTOR, { timeout: TIMEOUT }) + await tutorial_3a_page.waitForSelector(selectors.TWO_D_NET_PLOT_SELECTOR, { timeout: TIMEOUT }) + await tutorial_3a_page.click(selectors.TWO_D_NET_PLOT_SELECTOR, { timeout: TIMEOUT }) + await tutorial_3a_page.waitForSelector(selectors.CANVAS_SELECTOR, { timeout: TIMEOUT }) console.log('View 2D Net Plot ...') - await page.waitForTimeout(PAGE_WAIT * 3); + await tutorial_3a_page.waitForTimeout(PAGE_WAIT * 3); console.log('... taking snapshot ...'); - expect(await page.screenshot()) + expect(await tutorial_3a_page.screenshot()) .toMatchImageSnapshot({ ...SNAPSHOT_OPTIONS, customSnapshotIdentifier: '2D Net Plot' @@ -169,14 +193,14 @@ describe('Tutorial #3a for Smoke Testing', () => { }); it('Cell Traces Plot', async () => { - - await page.click(selectors.CELL_TRACES_PLOT_SELECTOR, { timeout: TIMEOUT }) - await page.waitForSelector(selectors.CANVAS_SELECTOR, { timeout: TIMEOUT }) + await tutorial_3a_page.waitForSelector(selectors.CELL_TRACES_PLOT_SELECTOR, { timeout: TIMEOUT }) + await tutorial_3a_page.click(selectors.CELL_TRACES_PLOT_SELECTOR, { timeout: TIMEOUT }) + await tutorial_3a_page.waitForSelector(selectors.CANVAS_SELECTOR, { timeout: TIMEOUT }) console.log('View Cell Traces Plot ...') - await page.waitForTimeout(PAGE_WAIT); + await tutorial_3a_page.waitForTimeout(PAGE_WAIT); console.log('... taking snapshot ...'); - expect(await page.screenshot()) + expect(await tutorial_3a_page.screenshot()) .toMatchImageSnapshot({ ...SNAPSHOT_OPTIONS, customSnapshotIdentifier: 'Cell Traces Plot' @@ -184,14 +208,14 @@ describe('Tutorial #3a for Smoke Testing', () => { }); it('Raster Plot', async () => { - - await page.click(selectors.RASTER_PLOT_SELECTOR, { timeout: TIMEOUT }) - await page.waitForSelector(selectors.CANVAS_SELECTOR, { timeout: TIMEOUT }) + await tutorial_3a_page.waitForSelector(selectors.RASTER_PLOT_SELECTOR, { timeout: TIMEOUT }) + await tutorial_3a_page.click(selectors.RASTER_PLOT_SELECTOR, { timeout: TIMEOUT }) + await tutorial_3a_page.waitForSelector(selectors.CANVAS_SELECTOR, { timeout: TIMEOUT }) console.log('View Raster Plot ...') - await page.waitForTimeout(PAGE_WAIT); + await tutorial_3a_page.waitForTimeout(PAGE_WAIT); console.log('... taking snapshot ...'); - expect(await page.screenshot()) + expect(await tutorial_3a_page.screenshot()) .toMatchImageSnapshot({ ...SNAPSHOT_OPTIONS, customSnapshotIdentifier: 'Raster Plot' @@ -199,14 +223,14 @@ describe('Tutorial #3a for Smoke Testing', () => { }); it('Spike Hist Plot', async () => { - - await page.click(selectors.SPIKE_HIST_PLOT_SELECTOR, { timeout: TIMEOUT }) - await page.waitForSelector(selectors.CANVAS_SELECTOR, { timeout: TIMEOUT }) + await tutorial_3a_page.waitForSelector(selectors.SPIKE_HIST_PLOT_SELECTOR, { timeout: TIMEOUT }) + await tutorial_3a_page.click(selectors.SPIKE_HIST_PLOT_SELECTOR, { timeout: TIMEOUT }) + await tutorial_3a_page.waitForSelector(selectors.CANVAS_SELECTOR, { timeout: TIMEOUT }) console.log('View Spike Hist Plot ...') - await page.waitForTimeout(PAGE_WAIT); + await tutorial_3a_page.waitForTimeout(PAGE_WAIT); console.log('... taking snapshot ...'); - expect(await page.screenshot()) + expect(await tutorial_3a_page.screenshot()) .toMatchImageSnapshot({ ...SNAPSHOT_OPTIONS, customSnapshotIdentifier: 'Spike Hist Plot' @@ -214,14 +238,14 @@ describe('Tutorial #3a for Smoke Testing', () => { }); it('LFP Time Series Plot', async () => { - - await page.click(selectors.LFP_TS_PLOT_SELECTOR, { timeout: TIMEOUT }) - await page.waitForSelector(selectors.CANVAS_SELECTOR, { timeout: TIMEOUT }) + await tutorial_3a_page.waitForSelector(selectors.LFP_TS_PLOT_SELECTOR, { timeout: TIMEOUT }) + await tutorial_3a_page.click(selectors.LFP_TS_PLOT_SELECTOR, { timeout: TIMEOUT }) + await tutorial_3a_page.waitForSelector(selectors.CANVAS_SELECTOR, { timeout: TIMEOUT }) console.log('View LFP Time Series Plot ...') - await page.waitForTimeout(PAGE_WAIT); + await tutorial_3a_page.waitForTimeout(PAGE_WAIT); console.log('... taking snapshot ...'); - expect(await page.screenshot()) + expect(await tutorial_3a_page.screenshot()) .toMatchImageSnapshot({ ...SNAPSHOT_OPTIONS, customSnapshotIdentifier: 'LFP Time Series Plot' @@ -229,14 +253,14 @@ describe('Tutorial #3a for Smoke Testing', () => { }); it('LFP PSD Plot', async () => { - - await page.click(selectors.LFP_PSD_PLOT_SELECTOR, { timeout: TIMEOUT }) - await page.waitForSelector(selectors.CANVAS_SELECTOR, { timeout: TIMEOUT }) + await tutorial_3a_page.waitForSelector(selectors.LFP_PSD_PLOT_SELECTOR, { timeout: TIMEOUT }) + await tutorial_3a_page.click(selectors.LFP_PSD_PLOT_SELECTOR, { timeout: TIMEOUT }) + await tutorial_3a_page.waitForSelector(selectors.CANVAS_SELECTOR, { timeout: TIMEOUT }) console.log('View LFP PSD Plot ...') - await page.waitForTimeout(PAGE_WAIT); + await tutorial_3a_page.waitForTimeout(PAGE_WAIT); console.log('... taking snapshot ...'); - expect(await page.screenshot()) + expect(await tutorial_3a_page.screenshot()) .toMatchImageSnapshot({ ...SNAPSHOT_OPTIONS, customSnapshotIdentifier: 'LFP PSD Plot' @@ -244,14 +268,14 @@ describe('Tutorial #3a for Smoke Testing', () => { }); it('LFP Spectrogram Plot', async () => { - - await page.click(selectors.LFP_SPECTOGRAM_PLOT_SELECTOR, { timeout: TIMEOUT }) - await page.waitForSelector(selectors.CANVAS_SELECTOR, { timeout: TIMEOUT }) + await tutorial_3a_page.waitForSelector(selectors.LFP_SPECTOGRAM_PLOT_SELECTOR, { timeout: TIMEOUT }) + await tutorial_3a_page.click(selectors.LFP_SPECTOGRAM_PLOT_SELECTOR, { timeout: TIMEOUT }) + await tutorial_3a_page.waitForSelector(selectors.CANVAS_SELECTOR, { timeout: TIMEOUT }) console.log('View LFP Spectrogram Plot ...') - await page.waitForTimeout(PAGE_WAIT * 5); + await tutorial_3a_page.waitForTimeout(PAGE_WAIT * 5); console.log('... taking snapshot ...'); - expect(await page.screenshot()) + expect(await tutorial_3a_page.screenshot()) .toMatchImageSnapshot({ ...SNAPSHOT_OPTIONS, customSnapshotIdentifier: 'LFP Spectrogram Plot' @@ -259,14 +283,14 @@ describe('Tutorial #3a for Smoke Testing', () => { }); it('Granger Plot', async () => { - - await page.click(selectors.GRANGER_PLOT_SELECTOR, { timeout: TIMEOUT }) - await page.waitForSelector(selectors.CANVAS_SELECTOR, { timeout: TIMEOUT }) + await tutorial_3a_page.waitForSelector(selectors.GRANGER_PLOT_SELECTOR, { timeout: TIMEOUT }) + await tutorial_3a_page.click(selectors.GRANGER_PLOT_SELECTOR, { timeout: TIMEOUT }) + await tutorial_3a_page.waitForSelector(selectors.CANVAS_SELECTOR, { timeout: TIMEOUT }) console.log('View Granger Plot ...') - await page.waitForTimeout(PAGE_WAIT); + await tutorial_3a_page.waitForTimeout(PAGE_WAIT); console.log('... taking snapshot ...'); - expect(await page.screenshot()) + expect(await tutorial_3a_page.screenshot()) .toMatchImageSnapshot({ ...SNAPSHOT_OPTIONS, customSnapshotIdentifier: 'Granger Plot' @@ -274,14 +298,14 @@ describe('Tutorial #3a for Smoke Testing', () => { }); it('RxD concentration plot', async () => { - - await page.click(selectors.RXD_CONCENTRATION_PLOT_SELECTOR, { timeout: TIMEOUT }) - await page.waitForSelector(selectors.CANVAS_SELECTOR, { timeout: TIMEOUT }) + await tutorial_3a_page.waitForSelector(selectors.RXD_CONCENTRATION_PLOT_SELECTOR, { timeout: TIMEOUT }) + await tutorial_3a_page.click(selectors.RXD_CONCENTRATION_PLOT_SELECTOR, { timeout: TIMEOUT }) + await tutorial_3a_page.waitForSelector(selectors.CANVAS_SELECTOR, { timeout: TIMEOUT }) console.log('View RxD concentration plot ...') - await page.waitForTimeout(PAGE_WAIT); + await tutorial_3a_page.waitForTimeout(PAGE_WAIT); console.log('... taking snapshot ...'); - expect(await page.screenshot()) + expect(await tutorial_3a_page.screenshot()) .toMatchImageSnapshot({ ...SNAPSHOT_OPTIONS, customSnapshotIdentifier: 'RxD concentration plot' @@ -289,25 +313,25 @@ describe('Tutorial #3a for Smoke Testing', () => { }); it('Rate Spectogram Plot', async () => { + await tutorial_3a_page.waitForSelector(selectors.RATE_SPECTROGRAM_PLOT_SELECTOR, { timeout: TIMEOUT }) + await tutorial_3a_page.click(selectors.RATE_SPECTROGRAM_PLOT_SELECTOR, { timeout: TIMEOUT }) + await tutorial_3a_page.waitForSelector(selectors.CANVAS_SELECTOR, { timeout: TIMEOUT }) - await page.click(selectors.RATE_SPECTROGRAM_PLOT_SELECTOR, { timeout: TIMEOUT }) - await page.waitForSelector(selectors.CANVAS_SELECTOR, { timeout: TIMEOUT }) - - await page.waitForTimeout(PAGE_WAIT); - - await page.click(selectors.CONNECTIONS_PLOT_SELECTOR, { timeout: TIMEOUT }) - await page.waitForSelector(selectors.CANVAS_SELECTOR, { timeout: TIMEOUT }) + await tutorial_3a_page.waitForTimeout(PAGE_WAIT); + await tutorial_3a_page.waitForSelector(selectors.CONNECTIONS_PLOT_SELECTOR, { timeout: TIMEOUT }) + await tutorial_3a_page.click(selectors.CONNECTIONS_PLOT_SELECTOR, { timeout: TIMEOUT }) + await tutorial_3a_page.waitForSelector(selectors.CANVAS_SELECTOR, { timeout: TIMEOUT }) - await page.waitForTimeout(PAGE_WAIT); + await tutorial_3a_page.waitForTimeout(PAGE_WAIT); - await page.click(selectors.RATE_SPECTROGRAM_PLOT_SELECTOR, { timeout: TIMEOUT }) - await page.waitForSelector(selectors.CANVAS_SELECTOR, { timeout: TIMEOUT }) + await tutorial_3a_page.click(selectors.RATE_SPECTROGRAM_PLOT_SELECTOR, { timeout: TIMEOUT }) + await tutorial_3a_page.waitForSelector(selectors.CANVAS_SELECTOR, { timeout: TIMEOUT }) console.log('View Rate Spectogram Plot ...') - await page.waitForTimeout(PAGE_WAIT); + await tutorial_3a_page.waitForTimeout(PAGE_WAIT); console.log('... taking snapshot ...'); - expect(await page.screenshot()) + expect(await tutorial_3a_page.screenshot()) .toMatchImageSnapshot({ ...SNAPSHOT_OPTIONS, customSnapshotIdentifier: 'Rate Spectogram Plot' diff --git a/tests/frontend/e2e/tests/Tut#3b_smoke.test.js b/tests/frontend/e2e/tests/Tut#3b_smoke.test.js index 4f9c7add..3ca85a00 100644 --- a/tests/frontend/e2e/tests/Tut#3b_smoke.test.js +++ b/tests/frontend/e2e/tests/Tut#3b_smoke.test.js @@ -1,5 +1,6 @@ //IMPORTS: import 'expect-puppeteer'; +import puppeteer from 'puppeteer'; import { click } from './utils'; import { toMatchImageSnapshot } from 'jest-image-snapshot' expect.extend({ toMatchImageSnapshot }) @@ -32,55 +33,76 @@ const PASSWORD = 'testpassword' //TESTS: jest.setTimeout(300000); - +let browser3b; +let tutorial_3b_page; describe('Tutorial #3b for Smoke Testing', () => { beforeAll(async () => { - await page.goto(baseURL); - await page.waitForSelector(selectors.LOGIN_PAGE_SELECTOR); - await page.waitForSelector(selectors.USERNAME_SELECTOR) - await expect(page) - .toFill(selectors.USERNAME_SELECTOR, USERNAME, { timeout: TIMEOUT }); - - await page.waitForSelector(selectors.PASSWORD_SELECTOR) - await expect(page) - .toFill(selectors.PASSWORD_SELECTOR, PASSWORD, { timeout: TIMEOUT }); - - await page.click(selectors.LOGIN_BUTTON_SELECTOR) - // Wait for initial loading spinner to disappear - await page.waitForFunction(() => { - let el = document.querySelector('#loading-spinner'); - return el == null || el.clientHeight === 0; - }, { timeout: TIMEOUT }); + browser3b = await puppeteer.launch( + { + headless: 'new', + args: ['--no-sandbox', '--disable-setuid-sandbox'], + defaultViewport: { + width: 1300, + height: 1024 + }, + } + ); + tutorial_3b_page = await browser3b.newPage(); + await tutorial_3b_page.goto(baseURL); + if (baseURL.includes('test.netpyne.metacell.us')) { + console.log('Logging in as test user ...') + await tutorial_3b_page.waitForSelector(selectors.LOGIN_PAGE_SELECTOR); + await tutorial_3b_page.waitForSelector(selectors.USERNAME_SELECTOR) + await expect(tutorial_3b_page) + .toFill(selectors.USERNAME_SELECTOR, USERNAME, { timeout: TIMEOUT }); + + await tutorial_3b_page.waitForSelector(selectors.PASSWORD_SELECTOR) + await expect(tutorial_3b_page) + .toFill(selectors.PASSWORD_SELECTOR, PASSWORD, { timeout: TIMEOUT }); + + await tutorial_3b_page.click(selectors.LOGIN_BUTTON_SELECTOR) + // Wait for initial loading spinner to disappear + await tutorial_3b_page.waitForFunction(() => { + let el = document.querySelector('#loading-spinner'); + return el == null || el.clientHeight === 0; + }, { timeout: TIMEOUT }); + console.log('Logged in successfully') + } + }); + + afterAll(async () => { + // Close the browser instance after all tests have run + await browser3b.close(); }); it('Open new page', async () => { console.log('Opening a new NetPyNE page') - await page.on("dialog", dialog => + await tutorial_3b_page.on("dialog", dialog => dialog.accept()); - await page.waitForSelector(selectors.SELECT_CELL_BUTTON_SELECTOR, { timeout: TIMEOUT * 6, visible: true }) - await page.waitForSelector(selectors.FILE_TAB_SELECTOR, { timeout: PAGE_WAIT * 3 }) - await page.waitForTimeout(PAGE_WAIT) - await page.click(selectors.FILE_TAB_SELECTOR) - await page.waitForSelector(selectors.NEW_FILE_SELECTOR, { timeout: PAGE_WAIT * 3 }) - await page.waitForTimeout(PAGE_WAIT) - await page.click(selectors.NEW_FILE_SELECTOR) - await page.waitForTimeout(PAGE_WAIT) - await page.waitForSelector(selectors.CONFIRM_NEW_PAGE_SELECTOR) - await page.click(selectors.CONFIRM_NEW_PAGE_SELECTOR) - await page.waitForTimeout(PAGE_WAIT * 2) - - await page.waitForFunction(() => { + await tutorial_3b_page.waitForSelector(selectors.SELECT_CELL_BUTTON_SELECTOR, { timeout: TIMEOUT * 6, visible: true }) + await tutorial_3b_page.waitForSelector(selectors.FILE_TAB_SELECTOR, { timeout: PAGE_WAIT * 3 }) + await tutorial_3b_page.waitForTimeout(PAGE_WAIT) + await tutorial_3b_page.click(selectors.FILE_TAB_SELECTOR) + await tutorial_3b_page.waitForSelector(selectors.NEW_FILE_SELECTOR, { timeout: PAGE_WAIT * 3 }) + await tutorial_3b_page.waitForTimeout(PAGE_WAIT) + await tutorial_3b_page.click(selectors.NEW_FILE_SELECTOR) + await tutorial_3b_page.waitForTimeout(PAGE_WAIT) + await tutorial_3b_page.waitForSelector(selectors.CONFIRM_NEW_PAGE_SELECTOR) + await tutorial_3b_page.click(selectors.CONFIRM_NEW_PAGE_SELECTOR) + await tutorial_3b_page.waitForTimeout(PAGE_WAIT * 2) + + await tutorial_3b_page.waitForFunction(() => { let el = document.querySelector('#loading-spinner'); return el == null || el.clientHeight === 0; }, { timeout: TIMEOUT }); - await page.waitForSelector(selectors.SELECT_CELL_BUTTON_SELECTOR, { timeout: TIMEOUT * 10 }) + await tutorial_3b_page.waitForSelector(selectors.SELECT_CELL_BUTTON_SELECTOR, { timeout: TIMEOUT * 10 }) console.log('Page opened successfully') @@ -89,46 +111,48 @@ describe('Tutorial #3b for Smoke Testing', () => { it('Create and Simulate network', async () => { - await page.waitForTimeout(PAGE_WAIT * 2) - await page.waitForSelector(selectors.SELECT_CELL_BUTTON_SELECTOR, { timeout: TIMEOUT }) + await tutorial_3b_page.waitForTimeout(PAGE_WAIT * 2) + await tutorial_3b_page.waitForSelector(selectors.SELECT_CELL_BUTTON_SELECTOR, { timeout: TIMEOUT }) console.log('Tutorial #3b') - await page.waitForTimeout(PAGE_WAIT) - await page.waitForSelector(selectors.TUTORIALS_BUTTON_SELECTOR, { timeout: TIMEOUT }) - await page.click(selectors.TUTORIALS_BUTTON_SELECTOR, { timeout: TIMEOUT }) - await page.waitForSelector(selectors.TUTORIAL_3B_SELECTOR, { timeout: TIMEOUT }) - await page.click(selectors.TUTORIAL_3B_SELECTOR, { timeout: TIMEOUT }) - await page.waitForSelector(selectors.E_CELL_TYPE_SELECTOR) - await page.waitForSelector(selectors.I_CELL_TYPE_SELECTOR) - await page.waitForTimeout(PAGE_WAIT) + await tutorial_3b_page.waitForTimeout(PAGE_WAIT) + await tutorial_3b_page.waitForSelector(selectors.TUTORIALS_BUTTON_SELECTOR, { timeout: TIMEOUT }) + await tutorial_3b_page.click(selectors.TUTORIALS_BUTTON_SELECTOR, { timeout: TIMEOUT }) + await tutorial_3b_page.waitForSelector(selectors.TUTORIAL_3B_SELECTOR, { timeout: TIMEOUT }) + await tutorial_3b_page.click(selectors.TUTORIAL_3B_SELECTOR, { timeout: TIMEOUT }) + await tutorial_3b_page.waitForSelector(selectors.E_CELL_TYPE_SELECTOR) + await tutorial_3b_page.waitForSelector(selectors.I_CELL_TYPE_SELECTOR) + await tutorial_3b_page.waitForTimeout(PAGE_WAIT) - await page.waitForSelector(selectors.MODEL_BUTTON_SELECTOR) - await page.click(selectors.MODEL_BUTTON_SELECTOR, { timeout: TIMEOUT }); - await page.waitForSelector(selectors.CREATE_NETWORK_SELECTOR) - await page.click(selectors.CREATE_NETWORK_SELECTOR, { timeout: TIMEOUT }); + await tutorial_3b_page.waitForSelector(selectors.MODEL_BUTTON_SELECTOR) + await tutorial_3b_page.click(selectors.MODEL_BUTTON_SELECTOR, { timeout: TIMEOUT }); + await tutorial_3b_page.waitForSelector(selectors.CREATE_NETWORK_SELECTOR) + await tutorial_3b_page.click(selectors.CREATE_NETWORK_SELECTOR, { timeout: TIMEOUT }); console.log('Create network') - await page.waitForTimeout(PAGE_WAIT * 3) + await tutorial_3b_page.waitForTimeout(PAGE_WAIT * 3) - await page.waitForSelector(selectors.THREE_D_REP_SELECTOR) + await tutorial_3b_page.waitForSelector(selectors.THREE_D_REP_SELECTOR) console.log('... taking snapshot ...'); - await page.waitForTimeout(PAGE_WAIT); - expect(await page.screenshot()) + await tutorial_3b_page.waitForTimeout(PAGE_WAIT); + expect(await tutorial_3b_page.screenshot()) .toMatchImageSnapshot({ ...SNAPSHOT_OPTIONS, customSnapshotIdentifier: 'Tutorial#3b Network' }); - await page.click(selectors.MODEL_BUTTON_SELECTOR, { timeout: TIMEOUT }); - await page.click(selectors.SIMULATE_NETWORK_SELECTOR, { timeout: TIMEOUT }); + await tutorial_3b_page.waitForSelector(selectors.MODEL_BUTTON_SELECTOR, { timeout: TIMEOUT }); + await tutorial_3b_page.click(selectors.MODEL_BUTTON_SELECTOR, { timeout: TIMEOUT }); + await tutorial_3b_page.waitForSelector(selectors.SIMULATE_NETWORK_SELECTOR, { timeout: TIMEOUT }); + await tutorial_3b_page.click(selectors.SIMULATE_NETWORK_SELECTOR, { timeout: TIMEOUT }); console.log('Simulate network') - await page.waitForSelector(selectors.SIMULATION_PAGE_SELECTOR, { timeout: TIMEOUT * 2 }); + await tutorial_3b_page.waitForSelector(selectors.SIMULATION_PAGE_SELECTOR, { timeout: TIMEOUT * 2 }); - await page.waitForSelector(selectors.RASTER_PLOT_SELECTOR, { timeout: TIMEOUT * 3 }) + await tutorial_3b_page.waitForSelector(selectors.RASTER_PLOT_SELECTOR, { timeout: TIMEOUT * 3 }) }); @@ -136,14 +160,15 @@ describe('Tutorial #3b for Smoke Testing', () => { it('Connections Plot', async () => { - await page.waitForTimeout(PAGE_WAIT * 2); - await page.click(selectors.CONNECTIONS_PLOT_SELECTOR, { timeout: TIMEOUT }) - await page.waitForSelector(selectors.CANVAS_SELECTOR, { timeout: TIMEOUT }) + await tutorial_3b_page.waitForTimeout(PAGE_WAIT * 2); + await tutorial_3b_page.waitForSelector(selectors.CONNECTIONS_PLOT_SELECTOR, { timeout: TIMEOUT }) + await tutorial_3b_page.click(selectors.CONNECTIONS_PLOT_SELECTOR, { timeout: TIMEOUT }) + await tutorial_3b_page.waitForSelector(selectors.CANVAS_SELECTOR, { timeout: TIMEOUT }) console.log('View Connections Plot ...') - await page.waitForTimeout(PAGE_WAIT); + await tutorial_3b_page.waitForTimeout(PAGE_WAIT); console.log('... taking snapshot ...'); - expect(await page.screenshot()) + expect(await tutorial_3b_page.screenshot()) .toMatchImageSnapshot({ ...SNAPSHOT_OPTIONS, customSnapshotIdentifier: 'Connections Plot' @@ -152,14 +177,14 @@ describe('Tutorial #3b for Smoke Testing', () => { }); it('2D Net Plot', async () => { - - await page.click(selectors.TWO_D_NET_PLOT_SELECTOR, { timeout: TIMEOUT }) - await page.waitForSelector(selectors.CANVAS_SELECTOR, { timeout: TIMEOUT }) + await tutorial_3b_page.waitForSelector(selectors.TWO_D_NET_PLOT_SELECTOR, { timeout: TIMEOUT }) + await tutorial_3b_page.click(selectors.TWO_D_NET_PLOT_SELECTOR, { timeout: TIMEOUT }) + await tutorial_3b_page.waitForSelector(selectors.CANVAS_SELECTOR, { timeout: TIMEOUT }) console.log('View 2D Net Plot ...') - await page.waitForTimeout(PAGE_WAIT * 3); + await tutorial_3b_page.waitForTimeout(PAGE_WAIT * 3); console.log('... taking snapshot ...'); - expect(await page.screenshot()) + expect(await tutorial_3b_page.screenshot()) .toMatchImageSnapshot({ ...SNAPSHOT_OPTIONS, customSnapshotIdentifier: '2D Net Plot' @@ -167,14 +192,14 @@ describe('Tutorial #3b for Smoke Testing', () => { }); it('Cell Traces Plot', async () => { - - await page.click(selectors.CELL_TRACES_PLOT_SELECTOR, { timeout: TIMEOUT }) - await page.waitForSelector(selectors.CANVAS_SELECTOR, { timeout: TIMEOUT }) + await tutorial_3b_page.waitForSelector(selectors.CELL_TRACES_PLOT_SELECTOR, { timeout: TIMEOUT }) + await tutorial_3b_page.click(selectors.CELL_TRACES_PLOT_SELECTOR, { timeout: TIMEOUT }) + await tutorial_3b_page.waitForSelector(selectors.CANVAS_SELECTOR, { timeout: TIMEOUT }) console.log('View Cell Traces Plot ...') - await page.waitForTimeout(PAGE_WAIT); + await tutorial_3b_page.waitForTimeout(PAGE_WAIT); console.log('... taking snapshot ...'); - expect(await page.screenshot()) + expect(await tutorial_3b_page.screenshot()) .toMatchImageSnapshot({ ...SNAPSHOT_OPTIONS, customSnapshotIdentifier: 'Cell Traces Plot' @@ -182,14 +207,14 @@ describe('Tutorial #3b for Smoke Testing', () => { }); it('Raster Plot', async () => { - - await page.click(selectors.RASTER_PLOT_SELECTOR, { timeout: TIMEOUT }) - await page.waitForSelector(selectors.CANVAS_SELECTOR, { timeout: TIMEOUT }) + await tutorial_3b_page.waitForSelector(selectors.RASTER_PLOT_SELECTOR, { timeout: TIMEOUT }) + await tutorial_3b_page.click(selectors.RASTER_PLOT_SELECTOR, { timeout: TIMEOUT }) + await tutorial_3b_page.waitForSelector(selectors.CANVAS_SELECTOR, { timeout: TIMEOUT }) console.log('View Raster Plot ...') - await page.waitForTimeout(PAGE_WAIT); + await tutorial_3b_page.waitForTimeout(PAGE_WAIT); console.log('... taking snapshot ...'); - expect(await page.screenshot()) + expect(await tutorial_3b_page.screenshot()) .toMatchImageSnapshot({ ...SNAPSHOT_OPTIONS, customSnapshotIdentifier: 'Raster Plot' @@ -197,14 +222,14 @@ describe('Tutorial #3b for Smoke Testing', () => { }); it('Spike Hist Plot', async () => { - - await page.click(selectors.SPIKE_HIST_PLOT_SELECTOR, { timeout: TIMEOUT }) - await page.waitForSelector(selectors.CANVAS_SELECTOR, { timeout: TIMEOUT }) + await tutorial_3b_page.waitForSelector(selectors.SPIKE_HIST_PLOT_SELECTOR, { timeout: TIMEOUT }) + await tutorial_3b_page.click(selectors.SPIKE_HIST_PLOT_SELECTOR, { timeout: TIMEOUT }) + await tutorial_3b_page.waitForSelector(selectors.CANVAS_SELECTOR, { timeout: TIMEOUT }) console.log('View Spike Hist Plot ...') - await page.waitForTimeout(PAGE_WAIT); + await tutorial_3b_page.waitForTimeout(PAGE_WAIT); console.log('... taking snapshot ...'); - expect(await page.screenshot()) + expect(await tutorial_3b_page.screenshot()) .toMatchImageSnapshot({ ...SNAPSHOT_OPTIONS, customSnapshotIdentifier: 'Spike Hist Plot' @@ -212,14 +237,14 @@ describe('Tutorial #3b for Smoke Testing', () => { }); it('LFP Time Series Plot', async () => { - - await page.click(selectors.LFP_TS_PLOT_SELECTOR, { timeout: TIMEOUT }) - await page.waitForSelector(selectors.CANVAS_SELECTOR, { timeout: TIMEOUT }) + await tutorial_3b_page.waitForSelector(selectors.LFP_TS_PLOT_SELECTOR, { timeout: TIMEOUT }) + await tutorial_3b_page.click(selectors.LFP_TS_PLOT_SELECTOR, { timeout: TIMEOUT }) + await tutorial_3b_page.waitForSelector(selectors.CANVAS_SELECTOR, { timeout: TIMEOUT }) console.log('View LFP Time Series Plot ...') - await page.waitForTimeout(PAGE_WAIT); + await tutorial_3b_page.waitForTimeout(PAGE_WAIT); console.log('... taking snapshot ...'); - expect(await page.screenshot()) + expect(await tutorial_3b_page.screenshot()) .toMatchImageSnapshot({ ...SNAPSHOT_OPTIONS, customSnapshotIdentifier: 'LFP Time Series Plot' @@ -227,14 +252,14 @@ describe('Tutorial #3b for Smoke Testing', () => { }); it('LFP PSD Plot', async () => { - - await page.click(selectors.LFP_PSD_PLOT_SELECTOR, { timeout: TIMEOUT }) - await page.waitForSelector(selectors.CANVAS_SELECTOR, { timeout: TIMEOUT }) + await tutorial_3b_page.waitForSelector(selectors.LFP_PSD_PLOT_SELECTOR, { timeout: TIMEOUT }) + await tutorial_3b_page.click(selectors.LFP_PSD_PLOT_SELECTOR, { timeout: TIMEOUT }) + await tutorial_3b_page.waitForSelector(selectors.CANVAS_SELECTOR, { timeout: TIMEOUT }) console.log('View LFP PSD Plot ...') - await page.waitForTimeout(PAGE_WAIT * 2); + await tutorial_3b_page.waitForTimeout(PAGE_WAIT * 2); console.log('... taking snapshot ...'); - expect(await page.screenshot()) + expect(await tutorial_3b_page.screenshot()) .toMatchImageSnapshot({ ...SNAPSHOT_OPTIONS, customSnapshotIdentifier: 'LFP PSD Plot' @@ -242,14 +267,14 @@ describe('Tutorial #3b for Smoke Testing', () => { }); it('LFP Spectrogram Plot', async () => { - - await page.click(selectors.LFP_SPECTOGRAM_PLOT_SELECTOR, { timeout: TIMEOUT }) - await page.waitForSelector(selectors.CANVAS_SELECTOR, { timeout: TIMEOUT }) + await tutorial_3b_page.waitForSelector(selectors.LFP_SPECTOGRAM_PLOT_SELECTOR, { timeout: TIMEOUT }) + await tutorial_3b_page.click(selectors.LFP_SPECTOGRAM_PLOT_SELECTOR, { timeout: TIMEOUT }) + await tutorial_3b_page.waitForSelector(selectors.CANVAS_SELECTOR, { timeout: TIMEOUT }) console.log('View LFP Spectrogram Plot ...') - await page.waitForTimeout(PAGE_WAIT * 5); + await tutorial_3b_page.waitForTimeout(PAGE_WAIT * 5); console.log('... taking snapshot ...'); - expect(await page.screenshot()) + expect(await tutorial_3b_page.screenshot()) .toMatchImageSnapshot({ ...SNAPSHOT_OPTIONS, customSnapshotIdentifier: 'LFP Spectrogram Plot' @@ -257,14 +282,14 @@ describe('Tutorial #3b for Smoke Testing', () => { }); it('Granger Plot', async () => { - - await page.click(selectors.GRANGER_PLOT_SELECTOR, { timeout: TIMEOUT }) - await page.waitForSelector(selectors.CANVAS_SELECTOR, { timeout: TIMEOUT }) + await tutorial_3b_page.waitForSelector(selectors.GRANGER_PLOT_SELECTOR, { timeout: TIMEOUT }) + await tutorial_3b_page.click(selectors.GRANGER_PLOT_SELECTOR, { timeout: TIMEOUT }) + await tutorial_3b_page.waitForSelector(selectors.CANVAS_SELECTOR, { timeout: TIMEOUT }) console.log('View Granger Plot ...') - await page.waitForTimeout(PAGE_WAIT * 2); + await tutorial_3b_page.waitForTimeout(PAGE_WAIT * 2); console.log('... taking snapshot ...'); - expect(await page.screenshot()) + expect(await tutorial_3b_page.screenshot()) .toMatchImageSnapshot({ ...SNAPSHOT_OPTIONS, customSnapshotIdentifier: 'Granger Plot' @@ -272,14 +297,14 @@ describe('Tutorial #3b for Smoke Testing', () => { }); it('RxD concentration plot', async () => { - - await page.click(selectors.RXD_CONCENTRATION_PLOT_SELECTOR, { timeout: TIMEOUT }) - await page.waitForSelector(selectors.CANVAS_SELECTOR, { timeout: TIMEOUT }) + await tutorial_3b_page.waitForSelector(selectors.RXD_CONCENTRATION_PLOT_SELECTOR, { timeout: TIMEOUT }) + await tutorial_3b_page.click(selectors.RXD_CONCENTRATION_PLOT_SELECTOR, { timeout: TIMEOUT }) + await tutorial_3b_page.waitForSelector(selectors.CANVAS_SELECTOR, { timeout: TIMEOUT }) console.log('View RxD concentration plot ...') - await page.waitForTimeout(PAGE_WAIT); + await tutorial_3b_page.waitForTimeout(PAGE_WAIT); console.log('... taking snapshot ...'); - expect(await page.screenshot()) + expect(await tutorial_3b_page.screenshot()) .toMatchImageSnapshot({ ...SNAPSHOT_OPTIONS, customSnapshotIdentifier: 'RxD concentration plot' @@ -287,25 +312,25 @@ describe('Tutorial #3b for Smoke Testing', () => { }); it('Rate Spectogram Plot', async () => { + await tutorial_3b_page.waitForSelector(selectors.RATE_SPECTROGRAM_PLOT_SELECTOR, { timeout: TIMEOUT }) + await tutorial_3b_page.click(selectors.RATE_SPECTROGRAM_PLOT_SELECTOR, { timeout: TIMEOUT }) + await tutorial_3b_page.waitForSelector(selectors.CANVAS_SELECTOR, { timeout: TIMEOUT }) - await page.click(selectors.RATE_SPECTROGRAM_PLOT_SELECTOR, { timeout: TIMEOUT }) - await page.waitForSelector(selectors.CANVAS_SELECTOR, { timeout: TIMEOUT }) - - await page.waitForTimeout(PAGE_WAIT); + await tutorial_3b_page.waitForTimeout(PAGE_WAIT); - await page.click(selectors.CONNECTIONS_PLOT_SELECTOR, { timeout: TIMEOUT }) - await page.waitForSelector(selectors.CANVAS_SELECTOR, { timeout: TIMEOUT }) + await tutorial_3b_page.click(selectors.CONNECTIONS_PLOT_SELECTOR, { timeout: TIMEOUT }) + await tutorial_3b_page.waitForSelector(selectors.CANVAS_SELECTOR, { timeout: TIMEOUT }) - await page.waitForTimeout(PAGE_WAIT); + await tutorial_3b_page.waitForTimeout(PAGE_WAIT); - await page.click(selectors.RATE_SPECTROGRAM_PLOT_SELECTOR, { timeout: TIMEOUT }) - await page.waitForSelector(selectors.CANVAS_SELECTOR, { timeout: TIMEOUT }) + await tutorial_3b_page.click(selectors.RATE_SPECTROGRAM_PLOT_SELECTOR, { timeout: TIMEOUT }) + await tutorial_3b_page.waitForSelector(selectors.CANVAS_SELECTOR, { timeout: TIMEOUT }) console.log('View Rate Spectogram Plot ...') - await page.waitForTimeout(PAGE_WAIT); + await tutorial_3b_page.waitForTimeout(PAGE_WAIT); console.log('... taking snapshot ...'); - expect(await page.screenshot()) + expect(await tutorial_3b_page.screenshot()) .toMatchImageSnapshot({ ...SNAPSHOT_OPTIONS, customSnapshotIdentifier: 'Rate Spectogram Plot' diff --git a/tests/frontend/e2e/tests/Tut#3c_smoke.test.js b/tests/frontend/e2e/tests/Tut#3c_smoke.test.js index 64a59c7c..7784ee2c 100644 --- a/tests/frontend/e2e/tests/Tut#3c_smoke.test.js +++ b/tests/frontend/e2e/tests/Tut#3c_smoke.test.js @@ -1,5 +1,6 @@ //IMPORTS: import 'expect-puppeteer'; +import puppeteer from 'puppeteer'; import { click } from './utils'; import { toMatchImageSnapshot } from 'jest-image-snapshot' expect.extend({ toMatchImageSnapshot }) @@ -33,55 +34,76 @@ const PASSWORD = 'testpassword' //TESTS: jest.setTimeout(300000); - +let browser3c; +let tutorial_3c_page; describe('Tutorial #3c for Smoke Testing', () => { beforeAll(async () => { - await page.goto(baseURL); - await page.waitForSelector(selectors.LOGIN_PAGE_SELECTOR); - await page.waitForSelector(selectors.USERNAME_SELECTOR) - await expect(page) - .toFill(selectors.USERNAME_SELECTOR, USERNAME, { timeout: TIMEOUT }); - - await page.waitForSelector(selectors.PASSWORD_SELECTOR) - await expect(page) - .toFill(selectors.PASSWORD_SELECTOR, PASSWORD, { timeout: TIMEOUT }); - - await page.click(selectors.LOGIN_BUTTON_SELECTOR) - // Wait for initial loading spinner to disappear - await page.waitForFunction(() => { - let el = document.querySelector('#loading-spinner'); - return el == null || el.clientHeight === 0; - }, { timeout: TIMEOUT }); + browser3c = await puppeteer.launch( + { + headless: 'new', + args: ['--no-sandbox', '--disable-setuid-sandbox'], + defaultViewport: { + width: 1300, + height: 1024 + }, + } + ); + tutorial_3c_page = await browser3c.newPage(); + await tutorial_3c_page.goto(baseURL); + if (baseURL.includes('test.netpyne.metacell.us')) { + console.log('Logging in as test user ...') + await tutorial_3c_page.waitForSelector(selectors.LOGIN_PAGE_SELECTOR); + await tutorial_3c_page.waitForSelector(selectors.USERNAME_SELECTOR) + await expect(tutorial_3c_page) + .toFill(selectors.USERNAME_SELECTOR, USERNAME, { timeout: TIMEOUT }); + + await tutorial_3c_page.waitForSelector(selectors.PASSWORD_SELECTOR) + await expect(tutorial_3c_page) + .toFill(selectors.PASSWORD_SELECTOR, PASSWORD, { timeout: TIMEOUT }); + + await tutorial_3c_page.click(selectors.LOGIN_BUTTON_SELECTOR) + // Wait for initial loading spinner to disappear + await tutorial_3c_page.waitForFunction(() => { + let el = document.querySelector('#loading-spinner'); + return el == null || el.clientHeight === 0; + }, { timeout: TIMEOUT }); + console.log('Logged in successfully') + } + }); + + afterAll(async () => { + // Close the browser instance after all tests have run + await browser3c.close(); }); it('Open new page', async () => { console.log('Opening a new NetPyNE page') - await page.on("dialog", dialog => + await tutorial_3c_page.on("dialog", dialog => dialog.accept()); - await page.waitForSelector(selectors.SELECT_CELL_BUTTON_SELECTOR, { timeout: TIMEOUT * 6, visible: true }) - await page.waitForSelector(selectors.FILE_TAB_SELECTOR, { timeout: PAGE_WAIT * 3 }) - await page.waitForTimeout(PAGE_WAIT) - await page.click(selectors.FILE_TAB_SELECTOR) - await page.waitForSelector(selectors.NEW_FILE_SELECTOR, { timeout: PAGE_WAIT * 3 }) - await page.waitForTimeout(PAGE_WAIT) - await page.click(selectors.NEW_FILE_SELECTOR) - await page.waitForTimeout(PAGE_WAIT) - await page.waitForSelector(selectors.CONFIRM_NEW_PAGE_SELECTOR) - await page.click(selectors.CONFIRM_NEW_PAGE_SELECTOR) - await page.waitForTimeout(PAGE_WAIT * 2) - - await page.waitForFunction(() => { + await tutorial_3c_page.waitForSelector(selectors.SELECT_CELL_BUTTON_SELECTOR, { timeout: TIMEOUT * 6, visible: true }) + await tutorial_3c_page.waitForSelector(selectors.FILE_TAB_SELECTOR, { timeout: PAGE_WAIT * 3 }) + await tutorial_3c_page.waitForTimeout(PAGE_WAIT) + await tutorial_3c_page.click(selectors.FILE_TAB_SELECTOR) + await tutorial_3c_page.waitForSelector(selectors.NEW_FILE_SELECTOR, { timeout: PAGE_WAIT * 3 }) + await tutorial_3c_page.waitForTimeout(PAGE_WAIT) + await tutorial_3c_page.click(selectors.NEW_FILE_SELECTOR) + await tutorial_3c_page.waitForTimeout(PAGE_WAIT) + await tutorial_3c_page.waitForSelector(selectors.CONFIRM_NEW_PAGE_SELECTOR) + await tutorial_3c_page.click(selectors.CONFIRM_NEW_PAGE_SELECTOR) + await tutorial_3c_page.waitForTimeout(PAGE_WAIT * 2) + + await tutorial_3c_page.waitForFunction(() => { let el = document.querySelector('#loading-spinner'); return el == null || el.clientHeight === 0; }, { timeout: TIMEOUT }); - await page.waitForSelector(selectors.SELECT_CELL_BUTTON_SELECTOR, { timeout: TIMEOUT * 10 }) + await tutorial_3c_page.waitForSelector(selectors.SELECT_CELL_BUTTON_SELECTOR, { timeout: TIMEOUT * 10 }) console.log('Page opened successfully') @@ -90,34 +112,34 @@ describe('Tutorial #3c for Smoke Testing', () => { it('Create and Simulate network', async () => { - await page.waitForTimeout(PAGE_WAIT * 2) - await page.waitForSelector(selectors.SELECT_CELL_BUTTON_SELECTOR, { timeout: TIMEOUT }) + await tutorial_3c_page.waitForTimeout(PAGE_WAIT * 2) + await tutorial_3c_page.waitForSelector(selectors.SELECT_CELL_BUTTON_SELECTOR, { timeout: TIMEOUT }) console.log('Tutorial #3c') - await page.waitForTimeout(PAGE_WAIT) - await page.waitForSelector(selectors.TUTORIALS_BUTTON_SELECTOR, { timeout: TIMEOUT }) - await page.click(selectors.TUTORIALS_BUTTON_SELECTOR, { timeout: TIMEOUT }) - await page.waitForSelector(selectors.TUTORIAL_3C_SELECTOR, { timeout: TIMEOUT }) - await page.click(selectors.TUTORIAL_3C_SELECTOR, { timeout: TIMEOUT }) - await page.waitForSelector(selectors.E_CELL_TYPE_SELECTOR) - await page.waitForSelector(selectors.I_CELL_TYPE_SELECTOR) - await page.waitForTimeout(PAGE_WAIT) + await tutorial_3c_page.waitForTimeout(PAGE_WAIT) + await tutorial_3c_page.waitForSelector(selectors.TUTORIALS_BUTTON_SELECTOR, { timeout: TIMEOUT }) + await tutorial_3c_page.click(selectors.TUTORIALS_BUTTON_SELECTOR, { timeout: TIMEOUT }) + await tutorial_3c_page.waitForSelector(selectors.TUTORIAL_3C_SELECTOR, { timeout: TIMEOUT }) + await tutorial_3c_page.click(selectors.TUTORIAL_3C_SELECTOR, { timeout: TIMEOUT }) + await tutorial_3c_page.waitForSelector(selectors.E_CELL_TYPE_SELECTOR) + await tutorial_3c_page.waitForSelector(selectors.I_CELL_TYPE_SELECTOR) + await tutorial_3c_page.waitForTimeout(PAGE_WAIT) - await page.waitForSelector(selectors.MODEL_BUTTON_SELECTOR) - await page.click(selectors.MODEL_BUTTON_SELECTOR, { timeout: TIMEOUT }); - await page.waitForSelector(selectors.CREATE_NETWORK_SELECTOR) - await page.click(selectors.CREATE_NETWORK_SELECTOR, { timeout: TIMEOUT }); + await tutorial_3c_page.waitForSelector(selectors.MODEL_BUTTON_SELECTOR) + await tutorial_3c_page.click(selectors.MODEL_BUTTON_SELECTOR, { timeout: TIMEOUT }); + await tutorial_3c_page.waitForSelector(selectors.CREATE_NETWORK_SELECTOR) + await tutorial_3c_page.click(selectors.CREATE_NETWORK_SELECTOR, { timeout: TIMEOUT }); console.log('Create network') - await page.waitForTimeout(PAGE_WAIT * 3) + await tutorial_3c_page.waitForTimeout(PAGE_WAIT * 3) - await page.waitForSelector(selectors.THREE_D_REP_SELECTOR) + await tutorial_3c_page.waitForSelector(selectors.THREE_D_REP_SELECTOR) console.log('... taking snapshot ...'); - await page.waitForTimeout(PAGE_WAIT); - expect(await page.screenshot()) + await tutorial_3c_page.waitForTimeout(PAGE_WAIT); + expect(await tutorial_3c_page.screenshot()) .toMatchImageSnapshot({ ...SNAPSHOT_OPTIONS, customSnapshotIdentifier: 'Tutorial#3c Network' @@ -125,15 +147,15 @@ describe('Tutorial #3c for Smoke Testing', () => { //there is a bug related to 'Model' > 'Simulate Network' // await page.click( MODEL_BUTTON_SELECTOR, { timeout: TIMEOUT }); - await page.waitForTimeout(PAGE_WAIT); + await tutorial_3c_page.waitForTimeout(PAGE_WAIT); //reason why the tests are using the simulate button on the top right - await page.click(selectors.SIMULATE_TOP_RIGHT_BUTTON_SELECTOR, { timeout: TIMEOUT }); + await tutorial_3c_page.click(selectors.SIMULATE_TOP_RIGHT_BUTTON_SELECTOR, { timeout: TIMEOUT }); // await page.click( SIMULATE_NETWORK_SELECTOR, { timeout: TIMEOUT }); console.log('Simulate network') - await page.waitForSelector(selectors.SIMULATION_PAGE_SELECTOR, { timeout: TIMEOUT * 2 }); + await tutorial_3c_page.waitForSelector(selectors.SIMULATION_PAGE_SELECTOR, { timeout: TIMEOUT * 2 }); - await page.waitForSelector(selectors.RASTER_PLOT_SELECTOR, { timeout: TIMEOUT * 3 }) + await tutorial_3c_page.waitForSelector(selectors.RASTER_PLOT_SELECTOR, { timeout: TIMEOUT * 3 }) }); @@ -141,14 +163,15 @@ describe('Tutorial #3c for Smoke Testing', () => { it('Connections Plot', async () => { - await page.waitForTimeout(PAGE_WAIT * 2); - await page.click(selectors.CONNECTIONS_PLOT_SELECTOR, { timeout: TIMEOUT }) - await page.waitForSelector(selectors.CANVAS_SELECTOR, { timeout: TIMEOUT }) + await tutorial_3c_page.waitForTimeout(PAGE_WAIT * 2); + await tutorial_3c_page.waitForSelector(selectors.CONNECTIONS_PLOT_SELECTOR, { timeout: TIMEOUT }) + await tutorial_3c_page.click(selectors.CONNECTIONS_PLOT_SELECTOR, { timeout: TIMEOUT }) + await tutorial_3c_page.waitForSelector(selectors.CANVAS_SELECTOR, { timeout: TIMEOUT }) console.log('View Connections Plot ...') - await page.waitForTimeout(PAGE_WAIT); + await tutorial_3c_page.waitForTimeout(PAGE_WAIT); console.log('... taking snapshot ...'); - expect(await page.screenshot()) + expect(await tutorial_3c_page.screenshot()) .toMatchImageSnapshot({ ...SNAPSHOT_OPTIONS, customSnapshotIdentifier: 'Connections Plot' @@ -157,14 +180,14 @@ describe('Tutorial #3c for Smoke Testing', () => { }); it('2D Net Plot', async () => { - - await page.click(selectors.TWO_D_NET_PLOT_SELECTOR, { timeout: TIMEOUT }) - await page.waitForSelector(selectors.CANVAS_SELECTOR, { timeout: TIMEOUT }) + await tutorial_3c_page.waitForSelector(selectors.TWO_D_NET_PLOT_SELECTOR, { timeout: TIMEOUT }) + await tutorial_3c_page.click(selectors.TWO_D_NET_PLOT_SELECTOR, { timeout: TIMEOUT }) + await tutorial_3c_page.waitForSelector(selectors.CANVAS_SELECTOR, { timeout: TIMEOUT }) console.log('View 2D Net Plot ...') - await page.waitForTimeout(PAGE_WAIT * 3); + await tutorial_3c_page.waitForTimeout(PAGE_WAIT * 3); console.log('... taking snapshot ...'); - expect(await page.screenshot()) + expect(await tutorial_3c_page.screenshot()) .toMatchImageSnapshot({ ...SNAPSHOT_OPTIONS, customSnapshotIdentifier: '2D Net Plot' @@ -172,14 +195,14 @@ describe('Tutorial #3c for Smoke Testing', () => { }); it('Cell Traces Plot', async () => { - - await page.click(selectors.CELL_TRACES_PLOT_SELECTOR, { timeout: TIMEOUT }) - await page.waitForSelector(selectors.CANVAS_SELECTOR, { timeout: TIMEOUT }) + await tutorial_3c_page.waitForSelector(selectors.CELL_TRACES_PLOT_SELECTOR, { timeout: TIMEOUT }) + await tutorial_3c_page.click(selectors.CELL_TRACES_PLOT_SELECTOR, { timeout: TIMEOUT }) + await tutorial_3c_page.waitForSelector(selectors.CANVAS_SELECTOR, { timeout: TIMEOUT }) console.log('View Cell Traces Plot ...') - await page.waitForTimeout(PAGE_WAIT); + await tutorial_3c_page.waitForTimeout(PAGE_WAIT); console.log('... taking snapshot ...'); - expect(await page.screenshot()) + expect(await tutorial_3c_page.screenshot()) .toMatchImageSnapshot({ ...SNAPSHOT_OPTIONS, customSnapshotIdentifier: 'Cell Traces Plot' @@ -187,14 +210,14 @@ describe('Tutorial #3c for Smoke Testing', () => { }); it('Raster Plot', async () => { - - await page.click(selectors.RASTER_PLOT_SELECTOR, { timeout: TIMEOUT }) - await page.waitForSelector(selectors.CANVAS_SELECTOR, { timeout: TIMEOUT }) + await tutorial_3c_page.waitForSelector(selectors.RASTER_PLOT_SELECTOR, { timeout: TIMEOUT }) + await tutorial_3c_page.click(selectors.RASTER_PLOT_SELECTOR, { timeout: TIMEOUT }) + await tutorial_3c_page.waitForSelector(selectors.CANVAS_SELECTOR, { timeout: TIMEOUT }) console.log('View Raster Plot ...') - await page.waitForTimeout(PAGE_WAIT); + await tutorial_3c_page.waitForTimeout(PAGE_WAIT); console.log('... taking snapshot ...'); - expect(await page.screenshot()) + expect(await tutorial_3c_page.screenshot()) .toMatchImageSnapshot({ ...SNAPSHOT_OPTIONS, customSnapshotIdentifier: 'Raster Plot' @@ -202,14 +225,14 @@ describe('Tutorial #3c for Smoke Testing', () => { }); it('Spike Hist Plot', async () => { - - await page.click(selectors.SPIKE_HIST_PLOT_SELECTOR, { timeout: TIMEOUT }) - await page.waitForSelector(selectors.CANVAS_SELECTOR, { timeout: TIMEOUT }) + await tutorial_3c_page.waitForSelector(selectors.SPIKE_HIST_PLOT_SELECTOR, { timeout: TIMEOUT }) + await tutorial_3c_page.click(selectors.SPIKE_HIST_PLOT_SELECTOR, { timeout: TIMEOUT }) + await tutorial_3c_page.waitForSelector(selectors.CANVAS_SELECTOR, { timeout: TIMEOUT }) console.log('View Spike Hist Plot ...') - await page.waitForTimeout(PAGE_WAIT); + await tutorial_3c_page.waitForTimeout(PAGE_WAIT); console.log('... taking snapshot ...'); - expect(await page.screenshot()) + expect(await tutorial_3c_page.screenshot()) .toMatchImageSnapshot({ ...SNAPSHOT_OPTIONS, customSnapshotIdentifier: 'Spike Hist Plot' @@ -217,14 +240,14 @@ describe('Tutorial #3c for Smoke Testing', () => { }); it('LFP Time Series Plot', async () => { - - await page.click(selectors.LFP_TS_PLOT_SELECTOR, { timeout: TIMEOUT }) - await page.waitForSelector(selectors.CANVAS_SELECTOR, { timeout: TIMEOUT }) + await tutorial_3c_page.waitForSelector(selectors.LFP_TS_PLOT_SELECTOR, { timeout: TIMEOUT }) + await tutorial_3c_page.click(selectors.LFP_TS_PLOT_SELECTOR, { timeout: TIMEOUT }) + await tutorial_3c_page.waitForSelector(selectors.CANVAS_SELECTOR, { timeout: TIMEOUT }) console.log('View LFP Time Series Plot ...') - await page.waitForTimeout(PAGE_WAIT); + await tutorial_3c_page.waitForTimeout(PAGE_WAIT); console.log('... taking snapshot ...'); - expect(await page.screenshot()) + expect(await tutorial_3c_page.screenshot()) .toMatchImageSnapshot({ ...SNAPSHOT_OPTIONS, customSnapshotIdentifier: 'LFP Time Series Plot' @@ -232,14 +255,14 @@ describe('Tutorial #3c for Smoke Testing', () => { }); it('LFP PSD Plot', async () => { - - await page.click(selectors.LFP_PSD_PLOT_SELECTOR, { timeout: TIMEOUT }) - await page.waitForSelector(selectors.CANVAS_SELECTOR, { timeout: TIMEOUT }) + await tutorial_3c_page.waitForSelector(selectors.LFP_PSD_PLOT_SELECTOR, { timeout: TIMEOUT }) + await tutorial_3c_page.click(selectors.LFP_PSD_PLOT_SELECTOR, { timeout: TIMEOUT }) + await tutorial_3c_page.waitForSelector(selectors.CANVAS_SELECTOR, { timeout: TIMEOUT }) console.log('View LFP PSD Plot ...') - await page.waitForTimeout(PAGE_WAIT); + await tutorial_3c_page.waitForTimeout(PAGE_WAIT); console.log('... taking snapshot ...'); - expect(await page.screenshot()) + expect(await tutorial_3c_page.screenshot()) .toMatchImageSnapshot({ ...SNAPSHOT_OPTIONS, customSnapshotIdentifier: 'LFP PSD Plot' @@ -247,14 +270,14 @@ describe('Tutorial #3c for Smoke Testing', () => { }); it('LFP Spectrogram Plot', async () => { - - await page.click(selectors.LFP_SPECTOGRAM_PLOT_SELECTOR, { timeout: TIMEOUT }) - await page.waitForSelector(selectors.CANVAS_SELECTOR, { timeout: TIMEOUT }) + await tutorial_3c_page.waitForSelector(selectors.LFP_SPECTOGRAM_PLOT_SELECTOR, { timeout: TIMEOUT }) + await tutorial_3c_page.click(selectors.LFP_SPECTOGRAM_PLOT_SELECTOR, { timeout: TIMEOUT }) + await tutorial_3c_page.waitForSelector(selectors.CANVAS_SELECTOR, { timeout: TIMEOUT }) console.log('View LFP Spectrogram Plot ...') - await page.waitForTimeout(PAGE_WAIT * 3); + await tutorial_3c_page.waitForTimeout(PAGE_WAIT * 3); console.log('... taking snapshot ...'); - expect(await page.screenshot()) + expect(await tutorial_3c_page.screenshot()) .toMatchImageSnapshot({ ...SNAPSHOT_OPTIONS, customSnapshotIdentifier: 'LFP Spectrogram Plot' @@ -262,14 +285,14 @@ describe('Tutorial #3c for Smoke Testing', () => { }); it('Granger Plot', async () => { - - await page.click(selectors.GRANGER_PLOT_SELECTOR, { timeout: TIMEOUT }) - await page.waitForSelector(selectors.CANVAS_SELECTOR, { timeout: TIMEOUT }) + await tutorial_3c_page.waitForSelector(selectors.GRANGER_PLOT_SELECTOR, { timeout: TIMEOUT }) + await tutorial_3c_page.click(selectors.GRANGER_PLOT_SELECTOR, { timeout: TIMEOUT }) + await tutorial_3c_page.waitForSelector(selectors.CANVAS_SELECTOR, { timeout: TIMEOUT }) console.log('View Granger Plot ...') - await page.waitForTimeout(PAGE_WAIT); + await tutorial_3c_page.waitForTimeout(PAGE_WAIT); console.log('... taking snapshot ...'); - expect(await page.screenshot()) + expect(await tutorial_3c_page.screenshot()) .toMatchImageSnapshot({ ...SNAPSHOT_OPTIONS, customSnapshotIdentifier: 'Granger Plot' @@ -278,25 +301,25 @@ describe('Tutorial #3c for Smoke Testing', () => { it('Rate Spectogram Plot', async () => { + await tutorial_3c_page.waitForSelector(selectors.RATE_SPECTROGRAM_PLOT_SELECTOR, { timeout: TIMEOUT }) + await tutorial_3c_page.click(selectors.RATE_SPECTROGRAM_PLOT_SELECTOR, { timeout: TIMEOUT }) + await tutorial_3c_page.waitForSelector(selectors.CANVAS_SELECTOR, { timeout: TIMEOUT }) - await page.click(selectors.RATE_SPECTROGRAM_PLOT_SELECTOR, { timeout: TIMEOUT }) - await page.waitForSelector(selectors.CANVAS_SELECTOR, { timeout: TIMEOUT }) - - await page.waitForTimeout(PAGE_WAIT); - - await page.click(selectors.CONNECTIONS_PLOT_SELECTOR, { timeout: TIMEOUT }) - await page.waitForSelector(selectors.CANVAS_SELECTOR, { timeout: TIMEOUT }) + await tutorial_3c_page.waitForTimeout(PAGE_WAIT); + await tutorial_3c_page.waitForSelector(selectors.CONNECTIONS_PLOT_SELECTOR, { timeout: TIMEOUT }) + await tutorial_3c_page.click(selectors.CONNECTIONS_PLOT_SELECTOR, { timeout: TIMEOUT }) + await tutorial_3c_page.waitForSelector(selectors.CANVAS_SELECTOR, { timeout: TIMEOUT }) - await page.waitForTimeout(PAGE_WAIT); + await tutorial_3c_page.waitForTimeout(PAGE_WAIT); - await page.click(selectors.RATE_SPECTROGRAM_PLOT_SELECTOR, { timeout: TIMEOUT }) - await page.waitForSelector(selectors.CANVAS_SELECTOR, { timeout: TIMEOUT }) + await tutorial_3c_page.click(selectors.RATE_SPECTROGRAM_PLOT_SELECTOR, { timeout: TIMEOUT }) + await tutorial_3c_page.waitForSelector(selectors.CANVAS_SELECTOR, { timeout: TIMEOUT }) console.log('View Rate Spectogram Plot ...') - await page.waitForTimeout(PAGE_WAIT); + await tutorial_3c_page.waitForTimeout(PAGE_WAIT); console.log('... taking snapshot ...'); - expect(await page.screenshot()) + expect(await tutorial_3c_page.screenshot()) .toMatchImageSnapshot({ ...SNAPSHOT_OPTIONS, customSnapshotIdentifier: 'Rate Spectogram Plot' diff --git a/tests/frontend/e2e/tests/Tut#4_smoke.test.js b/tests/frontend/e2e/tests/Tut#4_smoke.test.js index bc88cf88..326c0701 100644 --- a/tests/frontend/e2e/tests/Tut#4_smoke.test.js +++ b/tests/frontend/e2e/tests/Tut#4_smoke.test.js @@ -1,5 +1,6 @@ //IMPORTS: import 'expect-puppeteer'; +import puppeteer from 'puppeteer'; import { click } from './utils'; import { toMatchImageSnapshot } from 'jest-image-snapshot' expect.extend({ toMatchImageSnapshot }) @@ -32,55 +33,76 @@ const PASSWORD = 'testpassword' //TESTS: jest.setTimeout(300000); - +let browser4; +let tutorial_4_page; describe('Tutorial #4 for Smoke Testing', () => { beforeAll(async () => { - await page.goto(baseURL); - await page.waitForSelector(selectors.LOGIN_PAGE_SELECTOR); - await page.waitForSelector(selectors.USERNAME_SELECTOR) - await expect(page) - .toFill(selectors.USERNAME_SELECTOR, USERNAME, { timeout: TIMEOUT }); - - await page.waitForSelector(selectors.PASSWORD_SELECTOR) - await expect(page) - .toFill(selectors.PASSWORD_SELECTOR, PASSWORD, { timeout: TIMEOUT }); - - await page.click(selectors.LOGIN_BUTTON_SELECTOR) - // Wait for initial loading spinner to disappear - await page.waitForFunction(() => { - let el = document.querySelector('#loading-spinner'); - return el == null || el.clientHeight === 0; - }, { timeout: TIMEOUT }); + browser4 = await puppeteer.launch( + { + headless: 'new', + args: ['--no-sandbox', '--disable-setuid-sandbox'], + defaultViewport: { + width: 1300, + height: 1024 + }, + } + ); + tutorial_4_page = await browser4.newPage(); + await tutorial_4_page.goto(baseURL); + if (baseURL.includes('test.netpyne.metacell.us')) { + console.log('Logging in as test user ...') + await tutorial_4_page.waitForSelector(selectors.LOGIN_PAGE_SELECTOR); + await tutorial_4_page.waitForSelector(selectors.USERNAME_SELECTOR) + await expect(tutorial_4_page) + .toFill(selectors.USERNAME_SELECTOR, USERNAME, { timeout: TIMEOUT }); + + await tutorial_4_page.waitForSelector(selectors.PASSWORD_SELECTOR) + await expect(tutorial_4_page) + .toFill(selectors.PASSWORD_SELECTOR, PASSWORD, { timeout: TIMEOUT }); + + await tutorial_4_page.click(selectors.LOGIN_BUTTON_SELECTOR) + // Wait for initial loading spinner to disappear + await tutorial_4_page.waitForFunction(() => { + let el = document.querySelector('#loading-spinner'); + return el == null || el.clientHeight === 0; + }, { timeout: TIMEOUT }); + console.log('Logged in successfully') + } + }); + + afterAll(async () => { + // Close the browser instance after all tests have run + await browser4.close(); }); it('Open new page', async () => { console.log('Opening a new NetPyNE page') - await page.on("dialog", dialog => + await tutorial_4_page.on("dialog", dialog => dialog.accept()); - await page.waitForSelector(selectors.SELECT_CELL_BUTTON_SELECTOR, { timeout: TIMEOUT * 6, visible: true }) - await page.waitForSelector(selectors.FILE_TAB_SELECTOR, { timeout: PAGE_WAIT * 3 }) - await page.waitForTimeout(PAGE_WAIT) - await page.click(selectors.FILE_TAB_SELECTOR) - await page.waitForSelector(selectors.NEW_FILE_SELECTOR, { timeout: PAGE_WAIT * 3 }) - await page.waitForTimeout(PAGE_WAIT) - await page.click(selectors.NEW_FILE_SELECTOR) - await page.waitForTimeout(PAGE_WAIT) - await page.waitForSelector(selectors.CONFIRM_NEW_PAGE_SELECTOR) - await page.click(selectors.CONFIRM_NEW_PAGE_SELECTOR) - await page.waitForTimeout(PAGE_WAIT * 2) - - await page.waitForFunction(() => { + await tutorial_4_page.waitForSelector(selectors.SELECT_CELL_BUTTON_SELECTOR, { timeout: TIMEOUT * 6, visible: true }) + await tutorial_4_page.waitForSelector(selectors.FILE_TAB_SELECTOR, { timeout: PAGE_WAIT * 3 }) + await tutorial_4_page.waitForTimeout(PAGE_WAIT) + await tutorial_4_page.click(selectors.FILE_TAB_SELECTOR) + await tutorial_4_page.waitForSelector(selectors.NEW_FILE_SELECTOR, { timeout: PAGE_WAIT * 3 }) + await tutorial_4_page.waitForTimeout(PAGE_WAIT) + await tutorial_4_page.click(selectors.NEW_FILE_SELECTOR) + await tutorial_4_page.waitForTimeout(PAGE_WAIT) + await tutorial_4_page.waitForSelector(selectors.CONFIRM_NEW_PAGE_SELECTOR) + await tutorial_4_page.click(selectors.CONFIRM_NEW_PAGE_SELECTOR) + await tutorial_4_page.waitForTimeout(PAGE_WAIT * 2) + + await tutorial_4_page.waitForFunction(() => { let el = document.querySelector('#loading-spinner'); return el == null || el.clientHeight === 0; }, { timeout: TIMEOUT }); - await page.waitForSelector(selectors.SELECT_CELL_BUTTON_SELECTOR, { timeout: TIMEOUT * 10 }) + await tutorial_4_page.waitForSelector(selectors.SELECT_CELL_BUTTON_SELECTOR, { timeout: TIMEOUT * 10 }) console.log('Page opened successfully') @@ -89,46 +111,47 @@ describe('Tutorial #4 for Smoke Testing', () => { it('Create and Simulate network', async () => { - await page.waitForTimeout(PAGE_WAIT * 2) - await page.waitForSelector(selectors.SELECT_CELL_BUTTON_SELECTOR, { timeout: TIMEOUT }) + await tutorial_4_page.waitForTimeout(PAGE_WAIT * 2) + await tutorial_4_page.waitForSelector(selectors.SELECT_CELL_BUTTON_SELECTOR, { timeout: TIMEOUT }) console.log('Tutorial #4') - await page.waitForTimeout(PAGE_WAIT) - await page.waitForSelector(selectors.TUTORIALS_BUTTON_SELECTOR, { timeout: TIMEOUT }) - await page.click(selectors.TUTORIALS_BUTTON_SELECTOR, { timeout: TIMEOUT }) - await page.waitForSelector(selectors.TUTORIAL_4_SELECTOR, { timeout: TIMEOUT }) - await page.click(selectors.TUTORIAL_4_SELECTOR, { timeout: TIMEOUT }) - await page.waitForSelector(selectors.PYR_2_CELL_SELECTOR) - await page.waitForTimeout(PAGE_WAIT) + await tutorial_4_page.waitForTimeout(PAGE_WAIT) + await tutorial_4_page.waitForSelector(selectors.TUTORIALS_BUTTON_SELECTOR, { timeout: TIMEOUT }) + await tutorial_4_page.click(selectors.TUTORIALS_BUTTON_SELECTOR, { timeout: TIMEOUT }) + await tutorial_4_page.waitForSelector(selectors.TUTORIAL_4_SELECTOR, { timeout: TIMEOUT }) + await tutorial_4_page.click(selectors.TUTORIAL_4_SELECTOR, { timeout: TIMEOUT }) + await tutorial_4_page.waitForSelector(selectors.PYR_2_CELL_SELECTOR) + await tutorial_4_page.waitForTimeout(PAGE_WAIT) - await page.waitForSelector(selectors.MODEL_BUTTON_SELECTOR) - await page.click(selectors.MODEL_BUTTON_SELECTOR, { timeout: TIMEOUT }); - await page.waitForSelector(selectors.CREATE_NETWORK_SELECTOR) - await page.click(selectors.CREATE_NETWORK_SELECTOR, { timeout: TIMEOUT }); + await tutorial_4_page.waitForSelector(selectors.MODEL_BUTTON_SELECTOR) + await tutorial_4_page.click(selectors.MODEL_BUTTON_SELECTOR, { timeout: TIMEOUT }); + await tutorial_4_page.waitForSelector(selectors.CREATE_NETWORK_SELECTOR) + await tutorial_4_page.click(selectors.CREATE_NETWORK_SELECTOR, { timeout: TIMEOUT }); console.log('Create network') - await page.waitForTimeout(PAGE_WAIT * 3) + await tutorial_4_page.waitForTimeout(PAGE_WAIT * 3) - await page.waitForSelector(selectors.THREE_D_REP_SELECTOR) + await tutorial_4_page.waitForSelector(selectors.THREE_D_REP_SELECTOR) console.log('... taking snapshot ...'); - await page.waitForTimeout(PAGE_WAIT); - expect(await page.screenshot()) + await tutorial_4_page.waitForTimeout(PAGE_WAIT); + expect(await tutorial_4_page.screenshot()) .toMatchImageSnapshot({ ...SNAPSHOT_OPTIONS, customSnapshotIdentifier: 'Tutorial#4 Network' }); - - await page.click(selectors.MODEL_BUTTON_SELECTOR, { timeout: TIMEOUT }); - await page.click(selectors.SIMULATE_NETWORK_SELECTOR, { timeout: TIMEOUT }); + await tutorial_4_page.waitForSelector(selectors.MODEL_BUTTON_SELECTOR, { timeout: TIMEOUT }); + await tutorial_4_page.click(selectors.MODEL_BUTTON_SELECTOR, { timeout: TIMEOUT }); + await tutorial_4_page.waitForSelector(selectors.SIMULATE_NETWORK_SELECTOR, { timeout: TIMEOUT }); + await tutorial_4_page.click(selectors.SIMULATE_NETWORK_SELECTOR, { timeout: TIMEOUT }); console.log('Simulate network') - await page.waitForSelector(selectors.SIMULATION_PAGE_SELECTOR, { timeout: TIMEOUT * 2 }); + await tutorial_4_page.waitForSelector(selectors.SIMULATION_PAGE_SELECTOR, { timeout: TIMEOUT * 2 }); - await page.waitForSelector(selectors.RASTER_PLOT_SELECTOR, { timeout: TIMEOUT * 3 }) + await tutorial_4_page.waitForSelector(selectors.RASTER_PLOT_SELECTOR, { timeout: TIMEOUT * 3 }) }); @@ -136,14 +159,15 @@ describe('Tutorial #4 for Smoke Testing', () => { it('Connections Plot', async () => { - await page.waitForTimeout(PAGE_WAIT * 2); - await page.click(selectors.CONNECTIONS_PLOT_SELECTOR, { timeout: TIMEOUT }) - await page.waitForSelector(selectors.CANVAS_SELECTOR, { timeout: TIMEOUT }) + await tutorial_4_page.waitForTimeout(PAGE_WAIT * 2); + await tutorial_4_page.waitForSelector(selectors.CONNECTIONS_PLOT_SELECTOR, { timeout: TIMEOUT }) + await tutorial_4_page.click(selectors.CONNECTIONS_PLOT_SELECTOR, { timeout: TIMEOUT }) + await tutorial_4_page.waitForSelector(selectors.CANVAS_SELECTOR, { timeout: TIMEOUT }) console.log('View Connections Plot ...') - await page.waitForTimeout(PAGE_WAIT); + await tutorial_4_page.waitForTimeout(PAGE_WAIT); console.log('... taking snapshot ...'); - expect(await page.screenshot()) + expect(await tutorial_4_page.screenshot()) .toMatchImageSnapshot({ ...SNAPSHOT_OPTIONS, customSnapshotIdentifier: 'Connections Plot' @@ -152,14 +176,14 @@ describe('Tutorial #4 for Smoke Testing', () => { }); it('2D Net Plot', async () => { - - await page.click(selectors.TWO_D_NET_PLOT_SELECTOR, { timeout: TIMEOUT }) - await page.waitForSelector(selectors.CANVAS_SELECTOR, { timeout: TIMEOUT }) + await tutorial_4_page.waitForSelector(selectors.TWO_D_NET_PLOT_SELECTOR, { timeout: TIMEOUT }) + await tutorial_4_page.click(selectors.TWO_D_NET_PLOT_SELECTOR, { timeout: TIMEOUT }) + await tutorial_4_page.waitForSelector(selectors.CANVAS_SELECTOR, { timeout: TIMEOUT }) console.log('View 2D Net Plot ...') - await page.waitForTimeout(PAGE_WAIT * 3); + await tutorial_4_page.waitForTimeout(PAGE_WAIT * 3); console.log('... taking snapshot ...'); - expect(await page.screenshot()) + expect(await tutorial_4_page.screenshot()) .toMatchImageSnapshot({ ...SNAPSHOT_OPTIONS, customSnapshotIdentifier: '2D Net Plot' @@ -167,14 +191,14 @@ describe('Tutorial #4 for Smoke Testing', () => { }); it('Cell Traces Plot', async () => { - - await page.click(selectors.CELL_TRACES_PLOT_SELECTOR, { timeout: TIMEOUT }) - await page.waitForSelector(selectors.CANVAS_SELECTOR, { timeout: TIMEOUT }) + await tutorial_4_page.waitForSelector(selectors.CELL_TRACES_PLOT_SELECTOR, { timeout: TIMEOUT }) + await tutorial_4_page.click(selectors.CELL_TRACES_PLOT_SELECTOR, { timeout: TIMEOUT }) + await tutorial_4_page.waitForSelector(selectors.CANVAS_SELECTOR, { timeout: TIMEOUT }) console.log('View Cell Traces Plot ...') - await page.waitForTimeout(PAGE_WAIT); + await tutorial_4_page.waitForTimeout(PAGE_WAIT); console.log('... taking snapshot ...'); - expect(await page.screenshot()) + expect(await tutorial_4_page.screenshot()) .toMatchImageSnapshot({ ...SNAPSHOT_OPTIONS, customSnapshotIdentifier: 'Cell Traces Plot' @@ -182,14 +206,14 @@ describe('Tutorial #4 for Smoke Testing', () => { }); it('Raster Plot', async () => { - - await page.click(selectors.RASTER_PLOT_SELECTOR, { timeout: TIMEOUT }) - await page.waitForSelector(selectors.CANVAS_SELECTOR, { timeout: TIMEOUT }) + await tutorial_4_page.waitForSelector(selectors.RASTER_PLOT_SELECTOR, { timeout: TIMEOUT }) + await tutorial_4_page.click(selectors.RASTER_PLOT_SELECTOR, { timeout: TIMEOUT }) + await tutorial_4_page.waitForSelector(selectors.CANVAS_SELECTOR, { timeout: TIMEOUT }) console.log('View Raster Plot ...') - await page.waitForTimeout(PAGE_WAIT); + await tutorial_4_page.waitForTimeout(PAGE_WAIT); console.log('... taking snapshot ...'); - expect(await page.screenshot()) + expect(await tutorial_4_page.screenshot()) .toMatchImageSnapshot({ ...SNAPSHOT_OPTIONS, customSnapshotIdentifier: 'Raster Plot' @@ -197,14 +221,14 @@ describe('Tutorial #4 for Smoke Testing', () => { }); it('Spike Hist Plot', async () => { - - await page.click(selectors.SPIKE_HIST_PLOT_SELECTOR, { timeout: TIMEOUT }) - await page.waitForSelector(selectors.CANVAS_SELECTOR, { timeout: TIMEOUT }) + await tutorial_4_page.waitForSelector(selectors.SPIKE_HIST_PLOT_SELECTOR, { timeout: TIMEOUT }) + await tutorial_4_page.click(selectors.SPIKE_HIST_PLOT_SELECTOR, { timeout: TIMEOUT }) + await tutorial_4_page.waitForSelector(selectors.CANVAS_SELECTOR, { timeout: TIMEOUT }) console.log('View Spike Hist Plot ...') - await page.waitForTimeout(PAGE_WAIT); + await tutorial_4_page.waitForTimeout(PAGE_WAIT); console.log('... taking snapshot ...'); - expect(await page.screenshot()) + expect(await tutorial_4_page.screenshot()) .toMatchImageSnapshot({ ...SNAPSHOT_OPTIONS, customSnapshotIdentifier: 'Spike Hist Plot' @@ -213,25 +237,25 @@ describe('Tutorial #4 for Smoke Testing', () => { it('Rate Spectogram Plot', async () => { + await tutorial_4_page.waitForSelector(selectors.RATE_SPECTROGRAM_PLOT_SELECTOR, { timeout: TIMEOUT }) + await tutorial_4_page.click(selectors.RATE_SPECTROGRAM_PLOT_SELECTOR, { timeout: TIMEOUT }) + await tutorial_4_page.waitForSelector(selectors.CANVAS_SELECTOR, { timeout: TIMEOUT }) - await page.click(selectors.RATE_SPECTROGRAM_PLOT_SELECTOR, { timeout: TIMEOUT }) - await page.waitForSelector(selectors.CANVAS_SELECTOR, { timeout: TIMEOUT }) - - await page.waitForTimeout(PAGE_WAIT); - - await page.click(selectors.CONNECTIONS_PLOT_SELECTOR, { timeout: TIMEOUT }) - await page.waitForSelector(selectors.CANVAS_SELECTOR, { timeout: TIMEOUT }) + await tutorial_4_page.waitForTimeout(PAGE_WAIT); + await tutorial_4_page.waitForSelector(selectors.CONNECTIONS_PLOT_SELECTOR, { timeout: TIMEOUT }) + await tutorial_4_page.click(selectors.CONNECTIONS_PLOT_SELECTOR, { timeout: TIMEOUT }) + await tutorial_4_page.waitForSelector(selectors.CANVAS_SELECTOR, { timeout: TIMEOUT }) - await page.waitForTimeout(PAGE_WAIT); + await tutorial_4_page.waitForTimeout(PAGE_WAIT); - await page.click(selectors.RATE_SPECTROGRAM_PLOT_SELECTOR, { timeout: TIMEOUT }) - await page.waitForSelector(selectors.CANVAS_SELECTOR, { timeout: TIMEOUT }) + await tutorial_4_page.click(selectors.RATE_SPECTROGRAM_PLOT_SELECTOR, { timeout: TIMEOUT }) + await tutorial_4_page.waitForSelector(selectors.CANVAS_SELECTOR, { timeout: TIMEOUT }) console.log('View Rate Spectogram Plot ...') - await page.waitForTimeout(PAGE_WAIT); + await tutorial_4_page.waitForTimeout(PAGE_WAIT); console.log('... taking snapshot ...'); - expect(await page.screenshot()) + expect(await tutorial_4_page.screenshot()) .toMatchImageSnapshot({ ...SNAPSHOT_OPTIONS, customSnapshotIdentifier: 'Rate Spectogram Plot' diff --git a/tests/frontend/e2e/tests/snapshots/Tut#3c_smoke.test/__diff_output__/LFP Spectrogram Plot-diff.png b/tests/frontend/e2e/tests/snapshots/Tut#3c_smoke.test/__diff_output__/LFP Spectrogram Plot-diff.png deleted file mode 100644 index c7ef9712..00000000 Binary files a/tests/frontend/e2e/tests/snapshots/Tut#3c_smoke.test/__diff_output__/LFP Spectrogram Plot-diff.png and /dev/null differ diff --git a/tests/frontend/e2e/tests/snapshots/Tut#3c_smoke.test/__diff_output__/Raster Plot-diff.png b/tests/frontend/e2e/tests/snapshots/Tut#3c_smoke.test/__diff_output__/Raster Plot-diff.png deleted file mode 100644 index 2c3f81c3..00000000 Binary files a/tests/frontend/e2e/tests/snapshots/Tut#3c_smoke.test/__diff_output__/Raster Plot-diff.png and /dev/null differ