mirror of
https://github.com/sartography/uva-covid19-testing-frontend.git
synced 2025-01-14 09:44:53 +00:00
Fixes e2e tests.
This commit is contained in:
parent
3357150421
commit
f5c374ebc8
@ -1,7 +1,7 @@
|
||||
import {HttpClient} from 'protractor-http-client';
|
||||
import {AppPage} from './app.po';
|
||||
|
||||
describe('Clinical Research Coordinator App', () => {
|
||||
describe('COVID19 Testing Kiosk App', () => {
|
||||
let page: AppPage;
|
||||
let http: HttpClient;
|
||||
|
||||
@ -12,114 +12,26 @@ describe('Clinical Research Coordinator App', () => {
|
||||
|
||||
it('should automatically sign-in and redirect to home screen', () => {
|
||||
page.navigateTo();
|
||||
expect(page.getRoute()).toEqual('/home');
|
||||
expect(page.getElements('#cta_protocol_builder').count()).toBeGreaterThan(0);
|
||||
expect(page.getRoute()).toEqual('/');
|
||||
});
|
||||
|
||||
it('should navigate to help screen', () => {
|
||||
page.clickAndExpectRoute('#nav_help', '/help');
|
||||
it('should navigate to settings screen', () => {
|
||||
page.clickAndExpectRoute('#nav_settings', '/settings');
|
||||
});
|
||||
|
||||
it('should navigate to profile', () => {
|
||||
page.clickElement('#nav_account');
|
||||
page.clickAndExpectRoute('#nav_profile', '/profile');
|
||||
it('should navigate to home screen', () => {
|
||||
page.clickAndExpectRoute('#nav_home', '/');
|
||||
});
|
||||
|
||||
it('should navigate to notifications', () => {
|
||||
page.clickElement('#nav_account');
|
||||
page.clickAndExpectRoute('#nav_notifications', '/notifications');
|
||||
it('should navigate to occupancy count input screen', () => {
|
||||
page.clickAndExpectRoute('#nav_count', '/count');
|
||||
});
|
||||
|
||||
it('should navigate back to home screen', () => {
|
||||
page.setLocalStorageVar('numstudy', '1');
|
||||
expect(page.getLocalStorageVar('numstudy')).toEqual('1');
|
||||
page.clickAndExpectRoute('#nav_home', '/home');
|
||||
expect(page.getElements('#cta_protocol_builder').count()).toBeGreaterThan(0);
|
||||
page.clickAndExpectRoute('#nav_home', '/');
|
||||
});
|
||||
|
||||
it('should open Protocol Builder in new window', async () => {
|
||||
expect(page.getElements('#cta_protocol_builder').count()).toEqual(1);
|
||||
expect(page.getElements('#cta_reload_studies').count()).toEqual(1);
|
||||
|
||||
// Open Protocol Builder in new tab.
|
||||
const numTabsBefore = await page.getNumTabs();
|
||||
page.clickElement('#cta_protocol_builder');
|
||||
const numTabsAfter = await page.getNumTabs();
|
||||
expect(numTabsAfter).toBeGreaterThan(numTabsBefore);
|
||||
|
||||
// Close Protocol Builder tab.
|
||||
await page.switchFocusToTab(1);
|
||||
await page.closeTab();
|
||||
await page.switchFocusToTab(0);
|
||||
it('should navigate to sample input screen', () => {
|
||||
page.clickAndExpectRoute('#nav_sample', '/sample');
|
||||
});
|
||||
|
||||
it('should load new study from Protocol Builder', async () => {
|
||||
const numStudiesBefore = await page.getElements('.study-row').count();
|
||||
|
||||
// Add a new study to Protocol Builder.
|
||||
http.post('/new_study', '' +
|
||||
`STUDYID=${Math.floor(Math.random() * 100000)}&` +
|
||||
`TITLE=${encodeURIComponent('New study title')}&` +
|
||||
`NETBADGEID=dhf8r&` +
|
||||
`DATE_MODIFIED=${encodeURIComponent(new Date().toISOString())}&` +
|
||||
`requirements=9&` +
|
||||
`requirements=21&` +
|
||||
`requirements=40&` +
|
||||
`requirements=44&` +
|
||||
`requirements=52&` +
|
||||
`requirements=53&` +
|
||||
`Q_COMPLETE=y`,
|
||||
{'Content-Type': 'application/x-www-form-urlencoded'}
|
||||
).catch(error => {
|
||||
console.error(error);
|
||||
});
|
||||
http.failOnHttpError = false;
|
||||
|
||||
// Reload the list of studies.
|
||||
await page.clickElement('#cta_reload_studies');
|
||||
await page.waitForNotVisible('.loading');
|
||||
await page.waitForClickable('.study-row');
|
||||
|
||||
const numStudiesAfter = await page.getElements('.study-row').count();
|
||||
expect(numStudiesAfter).toBeGreaterThan(numStudiesBefore);
|
||||
});
|
||||
|
||||
it('should navigate to a study', async () => {
|
||||
const studyRow = page.getElement('.study-row');
|
||||
const studyId = await studyRow.getAttribute('data-study-id');
|
||||
await expect(studyId).not.toBeUndefined();
|
||||
await expect(studyId).not.toBeNull();
|
||||
page.clickAndExpectRoute('.study-row', '/study/' + studyId);
|
||||
});
|
||||
|
||||
it('should display workflow spec categories in tiles', async () => {
|
||||
const numTiles = await page.getElements('.workflow-list-item').count();
|
||||
expect(numTiles).toBeGreaterThan(0);
|
||||
});
|
||||
|
||||
it('should navigate to a workflow', async () => {
|
||||
const wfSelector = '.workflow-list-item .workflow-action';
|
||||
expect(page.getElements(wfSelector).count()).toBeGreaterThan(0);
|
||||
const workflow = await page.getElement(wfSelector);
|
||||
const studyId = await workflow.getAttribute('data-study-id');
|
||||
const catId = await workflow.getAttribute('data-category-id');
|
||||
const workflowId = await workflow.getAttribute('data-workflow-id');
|
||||
|
||||
console.log('studyId', studyId);
|
||||
console.log('catId', catId);
|
||||
console.log('workflowId', workflowId);
|
||||
const expectedRoute = `/study/${studyId}?category=${catId}&workflow=${workflowId}`;
|
||||
await page.clickElement(wfSelector);
|
||||
const newRoute = await page.getRoute();
|
||||
expect(newRoute.slice(0, expectedRoute.length)).toEqual(expectedRoute);
|
||||
});
|
||||
|
||||
// TODO: CATCH 401/403 ERRORS AND VERIFY THAT THEY REDIRECT TO LOGIN
|
||||
// afterEach(async () => {
|
||||
// // Assert that there are no errors emitted from the browser
|
||||
// const logs = await browser.manage().logs().get(logging.Type.BROWSER);
|
||||
// expect(logs).not.toContain(jasmine.objectContaining({
|
||||
// level: logging.Level.SEVERE,
|
||||
// } as logging.Entry));
|
||||
// });
|
||||
});
|
||||
|
@ -5,6 +5,7 @@
|
||||
fxLayoutGap="40px"
|
||||
>
|
||||
<button
|
||||
id="nav_sample"
|
||||
mat-flat-button
|
||||
color="accent"
|
||||
class="btn-xl"
|
||||
@ -12,6 +13,7 @@
|
||||
autofocus
|
||||
>New sample</button>
|
||||
<button
|
||||
id="nav_count"
|
||||
mat-flat-button
|
||||
class="btn-xl"
|
||||
routerLink="/count"
|
||||
|
@ -1,9 +1,9 @@
|
||||
<mat-toolbar color="primary">
|
||||
<mat-toolbar-row>
|
||||
<button mat-button routerLink="/" class="logo">BeSAFE</button>
|
||||
<button mat-button routerLink="/settings">{{testingLocation ? testingLocation.name : 'No location found'}} ({{locationId}})</button>
|
||||
<button id="nav_logo" mat-button routerLink="/" class="logo">BeSAFE</button>
|
||||
<button id="nav_location" mat-button routerLink="/settings">{{testingLocation ? testingLocation.name : 'No location found'}} ({{locationId}})</button>
|
||||
<span fxFlex></span>
|
||||
<button mat-icon-button routerLink="/"><mat-icon>home</mat-icon></button>
|
||||
<button mat-icon-button routerLink="/settings"><mat-icon>settings</mat-icon></button>
|
||||
<button id="nav_home" mat-icon-button routerLink="/"><mat-icon>home</mat-icon></button>
|
||||
<button id="nav_settings" mat-icon-button routerLink="/settings"><mat-icon>settings</mat-icon></button>
|
||||
</mat-toolbar-row>
|
||||
</mat-toolbar>
|
||||
|
Loading…
x
Reference in New Issue
Block a user