Skip to content

Commit

Permalink
Merge pull request #795 from MetaCell/codefresh/tests
Browse files Browse the repository at this point in the history
adding if for when tests are from local to skip the login
  • Loading branch information
enicolasgomez authored Feb 6, 2024
2 parents ba52bd5 + 9288711 commit 267c336
Show file tree
Hide file tree
Showing 17 changed files with 1,553 additions and 1,294 deletions.
11 changes: 0 additions & 11 deletions tests/frontend/e2e/jest-puppeteer.config.js

This file was deleted.

2 changes: 1 addition & 1 deletion tests/frontend/e2e/jest.config.js
Original file line number Diff line number Diff line change
@@ -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'],
};
20 changes: 12 additions & 8 deletions tests/frontend/e2e/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -50,4 +54,4 @@
]
}
}
}
}
211 changes: 117 additions & 94 deletions tests/frontend/e2e/tests/ControlPanel.test.js

Large diffs are not rendered by default.

192 changes: 107 additions & 85 deletions tests/frontend/e2e/tests/EEG_and_Dipole_Tut#1.test.js
Original file line number Diff line number Diff line change
@@ -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 })
Expand Down Expand Up @@ -36,55 +37,76 @@ 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', () => {

it('Open new page', async () => {

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')

Expand All @@ -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)


})
Expand All @@ -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'
Expand All @@ -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'
Expand All @@ -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'
Expand Down
Loading

0 comments on commit 267c336

Please sign in to comment.