Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

G10.3-1 adapt existing test for action list to ticket #195

Merged
merged 16 commits into from
Feb 27, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions .github/workflows/frontend-cypress.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
name: Run cypress tests

on:
pull_request:
branches:
- develop
# pull_request:
# branches:
# - develop
push:
branches:
- develop
- feature/*
- e2e-tests/*

defaults:
Expand Down Expand Up @@ -56,7 +55,7 @@ jobs:
mvn -B package -PlocalDev -DskipTests -f backend/pom.xml &&
java -Dspring.profiles.active=develop -jar backend/target/*.jar &
sleep 60
cd frontend && npm run e2e -- --cypressConfig apps/quarano-frontend-e2e/cypress-ci.json --browser firefox
cd frontend && npm run e2e -- --cypressConfig apps/quarano-frontend-e2e/cypress-ci.json --browser chrome
kill -2 `lsof -i:8080 -t`

- uses: actions/upload-artifact@v2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,48 +2,66 @@

describe('health-department index cases action-list', () => {
beforeEach(() => {
cy.server();
cy.route('GET', '/hd/actions').as('allActions');
cy.route('GET', '/user/me').as('me');
cy.route('GET', '/hd/cases/').as('cases');
cy.route('GET', '/hd/actions/*').as('action');
cy.route('GET', '/hd/cases/*').as('case');
cy.intercept('GET', '/hd/actions', (req) => {
if (req.url.endsWith('/hd/actions')) {
req.alias = 'allActions';
} else {
req.alias = 'userAction';
}
});
cy.intercept('GET', '/user/me').as('me');
cy.intercept('GET', '/hd/cases', (req) => {
if (req.url.endsWith('/hd/cases/')) {
req.alias = 'allCases';
} else {
req.alias = 'specificCase';
}
});
cy.intercept('PUT', '/hd/actions/*/resolve').as('updateCaseActions');
cy.logInAgent();
});

it('load actions', () => {
it('G10.3-1: comment on and close action', () => {
cy.location('pathname').should('eq', Cypress.env('index_cases_url'));

cy.wait('@me').its('status').should('eq', 200);
cy.wait('@cases').its('status').should('eq', 200);
cy.wait('@me').its('response.statusCode').should('eq', 200);
cy.wait('@allCases').its('response.statusCode').should('eq', 200);

cy.get('[data-cy="action-list"]').click();
cy.location('pathname').should('eq', Cypress.env('health_department_url') + 'index-cases/action-list');

cy.wait('@allActions').its('status').should('eq', 200);
cy.wait('@allActions').its('response.statusCode').should('eq', 200);

cy.get('[data-cy="action-data-table"]')
.find('.ag-center-cols-container > .ag-row')
.should('have.length.greaterThan', 0);
cy.get('[data-cy="action-data-table"]').within(() => {
cy.get('[role=rowgroup] .ag-row')
.should('have.length.greaterThan', 0)
.contains('Sperber')
.should('have.length', 1)
.eq(0)
.parent()
.click();
});

cy.get('[data-cy="action-data-table"]')
.find('.ag-center-cols-container > .ag-row')
.then(($elems) => {
$elems[1].click();
});

cy.location('pathname').should('include', '/actions');

cy.wait('@action').its('status').should('eq', 200);
cy.wait('@case').its('status').should('eq', 200);
cy.get('qro-client-action').should('exist');
cy.get('@action')
cy.wait('@specificCase').its('response.statusCode').should('eq', 200);
cy.wait('@userAction').its('response.statusCode').should('eq', 200);
cy.get('@userAction')
.its('response.body')
.then((body) => {
expect(body.caseId).not.to.eq(null);
expect(body.numberOfResolvedAnomalies).to.eq(0);
expect(body.numberOfUnresolvedAnomalies).to.eq(1);
});
cy.get('qro-client-action-anomaly').contains('Körpertemperatur 40,1°C übersteigt Grenzwert 37,9°C.');
cy.location('pathname').should('include', '/actions');
cy.get('qro-client-action').should('exist');
cy.get('[data-cy="action-comments"]').type('Anruf erledigt');
cy.get('[data-cy="close-actions"]').click();
cy.get('[data-cy="confirm-button"]').click();
cy.wait('@updateCaseActions').its('response.statusCode').should('eq', 200);

cy.location('pathname').should('eq', Cypress.env('health_department_url') + 'index-cases/action-list');

cy.get('[data-cy="action-data-table"]').within(() => {
cy.get('[role=rowgroup] .ag-row').contains('Sperber').should('have.length', 0);
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,13 @@ describe(
cy.intercept('GET', '/diary').as('diary');
cy.intercept('GET', '/details').as('details');
cy.intercept('GET', '/contacts').as('contacts');
cy.intercept('GET', '/hd/cases/*').as('case');
cy.intercept('GET', '/hd/cases/*/questionnaire').as('questionnaire');
cy.intercept('GET', '/hd/cases', (req) => {
if (req.url.endsWith('/questionnaire')) {
req.alias = 'questionnaireForCase';
} else {
req.alias = 'specificCase';
}
});
});

describe('enroll as client', () => {
Expand Down Expand Up @@ -78,7 +83,7 @@ describe(
cy.get('[data-cy="contact-person-form-phone"] input')
.click()
.then(($elem) => {
cy.wrap($elem).type('123123123123');
cy.wrap($elem).click().type('123123123123');
});
cy.get('[data-cy="submit-button"] button').click();

Expand Down Expand Up @@ -135,8 +140,8 @@ describe(

cy.get('.mat-tab-links').children().should('have.length', 6);

cy.wait('@case').its('response.statusCode').should('eq', 200);
cy.get('@case')
cy.wait('@specificCase').its('response.statusCode').should('eq', 200);
cy.get('@specificCase')
.its('response.body')
.then(($body) => {
expect($body.caseId).to.not.eq(null);
Expand Down Expand Up @@ -179,7 +184,7 @@ describe(
it('check questionnaire', () => {
cy.get('[data-cy="questionnaire-tab"]').click();
cy.location('pathname').should('include', '/questionnaire');
cy.wait('@questionnaire').its('response.statusCode').should('eq', 200);
cy.wait('@questionnaireForCase').its('response.statusCode').should('eq', 200);

const tenDaysAgo = dayjs().subtract(10, 'days').format('YYYY-MM-DD');

Expand All @@ -199,9 +204,15 @@ describe(

cy.get('[data-cy="search-contact-case-input"] input').type('Claire');
cy.get('[data-cy="case-data-table"]').find('.ag-center-cols-container > .ag-row').eq(0).click();
cy.wait('@case').its('response.statusCode').should('eq', 200);
cy.wait('@specificCase').its('response.statusCode').should('eq', 200);
cy.get('@specificCase')
.its('response.body')
.then(($body) => {
expect($body._embedded.originCases[0].firstName).to.eq('Markus');
expect($body._embedded.originCases[0].lastName).to.eq('Hanser');
});
cy.location('pathname').should('include', '/edit');
// cy.get('[data-cy="lazy-autocomplete-chip-list"]').should('contain', 'Hanser, Markus'); // TODO: fix
// cy.get('[data-cy="lazy-autocomplete-chip-list"]').contains('Hanser, Markus');
});
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
<form [formGroup]="formGroup" (ngSubmit)="submitForm(caseAction)" class="mt-5" *ngIf="hasOpenAnomalies(caseAction)">
<fieldset>
<legend>Obige Auffälligkeiten als bearbeitet kennzeichnen</legend>
<mat-form-field class="full-width">
<mat-form-field class="full-width" data-cy="action-comments">
<mat-label>Bemerkung</mat-label>
<textarea
[mat-autosize]="true"
Expand All @@ -65,7 +65,7 @@
{{ validationErrorService.getErrorMessage(formGroup.controls.comment, error) | async }}
</mat-error>
</mat-form-field>
<button type="submit" mat-raised-button color="primary" [disabled]="formGroup.invalid">
<button type="submit" mat-raised-button color="primary" [disabled]="formGroup.invalid" data-cy="close-actions">
<mat-icon>check</mat-icon> Auffälligkeiten abschließen
</button>
<button class="ml-3" type="button" mat-raised-button color="secondary" [routerLink]="[returnLink]">
Expand Down
2 changes: 1 addition & 1 deletion frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@
"@types/node": "12.12.38",
"clipboardy": "2.3.0",
"codelyzer": "6.0.1",
"cypress": "6.3.0",
"cypress": "6.4.0",
"dotenv": "8.2.0",
"eslint": "6.8.0",
"eslint-plugin-cypress": "2.10.3",
Expand Down