Skip to content

Commit

Permalink
Update cypress tests (#548)
Browse files Browse the repository at this point in the history
* fix: update workflows and command.js

* fix: remove useless comments validation.spec.js

* fix: add retries for cypress test

* fix: merge 2 test

* fix: add wait

* fix: change retrie test

* fix: use .then

* fix: fix.then

* fix: add focus_out

* feat: add some condition to validation dpo

* fix: remove condition and add class to selector

* fix: replace input.DPOname by input[type=text]

* feat: full rewrite validation test code

* feat: change react time and selector

* feat: change selector

* feat: add more wait, and change order execute validation

* feat: add separation for validation and refuse pia

Co-authored-by: Timothee-Picard <timothee@atnos.com>
Co-authored-by: Sylvain Pastor <sylvain@pop-os.localdomain>
  • Loading branch information
3 people authored Jun 17, 2021
1 parent 45af442 commit 9d3586d
Show file tree
Hide file tree
Showing 5 changed files with 132 additions and 125 deletions.
7 changes: 4 additions & 3 deletions .github/workflows/integration-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,16 @@ name: integration-tests
on: [push]
jobs:
cypress-run:
runs-on: ubuntu-18.04
runs-on: ubuntu-latest
container: cypress/browsers:node12.18.3-chrome87-ff82
steps:
- name: Checkout
uses: actions/checkout@v1
uses: actions/checkout@v2

- name: Cypress
uses: cypress-io/github-action@v2
with:
start: npm start
start: yarn start
browser: chrome
headless: true
wait-on: http://localhost:4200
37 changes: 37 additions & 0 deletions cypress/integration/pia-angular/dpo_and_pia_refuse.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
describe("Validation", () => {
before(() => {
cy.init();
});

beforeEach(() => {
// Skip tutorial
cy.disable_onboarding();
});

context("Prepare data with import", () => {
// TODO: Import pia with .json
it("File Upload using cypress-file-upload package", () => {
cy.import_pia();
});
});

context("Refuse or ask pia signature", () => {
it(
"should refuse pia",
{
retries: {
runMode: 2,
openMode: 2
}
},
() => {
cy.get_current_pia_id(id => {
cy.go_edited_pia(id, 4, 3).then(() => {
cy.validateDPO();
});
cy.refusePia();
});
}
);
});
});
39 changes: 39 additions & 0 deletions cypress/integration/pia-angular/dpo_and_pia_validation.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
describe("Validation", () => {
before(() => {
cy.init();
});

beforeEach(() => {
// Skip tutorial
cy.disable_onboarding();
});

context("Prepare data with import", () => {
// TODO: Import pia with .json
it("File Upload using cypress-file-upload package", () => {
cy.import_pia();
});
});

context("Avis du DPD et des personnes concernées", () => {
it("should complete DPD", () => {
cy.get_current_pia_id(id => {
cy.go_edited_pia(id, 4, 3).then(() => {
cy.validateDPO();
});
});
});
it("should valid pia", () => {
cy.validatePia();
// cy.closeValidationEvaluationModal();
});
it("should show report", () => {
cy.closeValidationEvaluationModal();
cy.get('.pia-previewBlock[href="#/preview/2"]').click();

cy.url().should("include", "/preview/2");

cy.get(".pia-fullPreviewBlock-data").should("exist");
});
});
});
56 changes: 0 additions & 56 deletions cypress/integration/pia-angular/validation.spec.js

This file was deleted.

118 changes: 52 additions & 66 deletions cypress/support/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ Cypress.Commands.add("import_pia", () => {

// Import
cy.get('input[type="file"]#import_file').attachFile(filepath);
cy.wait(5000);
cy.wait(10000);

// there is a new pia ?
cy.get(".pia-cardsBlock.pia").should("have.length", 1);
Expand Down Expand Up @@ -261,19 +261,19 @@ Cypress.Commands.add("acceptMultipleEval", () => {
cy.get(".pia-evaluationBlock")
.find(".btn-green")
.each(($el, $index, $list) => {
cy.wait(2000);
cy.wait(500);
cy.wrap($el)
.click()
.wait(250);
});
cy.wait(2000)
cy.wait(500)
.get(".pia-entryContentBlock-footer")
.find(".btn-green")
.should("have.class", "btn-active")
.click();
});
Cypress.Commands.add("closeCompletedValidationEvaluationModal", () => {
cy.wait(2000)
cy.wait(500)
.get("#completed-evaluation")
.invoke("show")
.find("button")
Expand All @@ -282,16 +282,16 @@ Cypress.Commands.add("closeCompletedValidationEvaluationModal", () => {
.wait(500);
});
Cypress.Commands.add("closeValidationEvaluationModal", () => {
cy.wait(2000)
cy.wait(1000)
.get("#validate-evaluation")
.invoke("show")
.find(".pia-modalBlock-close")
.first()
.click()
.wait(2000);
.wait(1000);
});
Cypress.Commands.add("validateModal", () => {
cy.wait(2000)
cy.wait(500)
.get(".pia-modalBlock-content .btn.btn-green")
.click()
.wait(500);
Expand All @@ -300,66 +300,48 @@ Cypress.Commands.add("redirectMeasureOnAcceptation", () => {
cy.visit("/#/entry/2/section/3/item/3");
});
Cypress.Commands.add("validateDPO", () => {
cy.get(".pia-entryContentBlock-content-DPO").each(($el, $index, $list) => {
if (cy.wrap($el).find('input[type="text"]').length > 0) {
cy.wrap($el)
.find('input[type="text"]')
.first()
.type("DPO Pia", { force: true });
}
if (cy.wrap($el).find('input[type="radio"]').length > 0) {
cy.wrap($el)
.find('input[type="radio"]')
.first()
.check({ force: true });
}
cy.wrap($el)
.find("textarea")
.type(
"Nam tincidunt sem vel pretium scelerisque. Aliquam tincidunt commodo magna, vitae rutrum massa. Praesent lobortis porttitor gravida. Fusce nulla libero, feugiat eu sodales at, semper ac diam. Morbi sit amet luctus libero, eu sagittis neque",
{ force: true }
);
});
cy.get(".pia-entryContentBlock-content-people").each(($el, $index, $list) => {
cy.wrap($el)
.find("form")
.first()
.find("label")
.first()
.click({ force: true });
cy.wrap($el)
.find("form")
.last()
.find("input")
.first()
.type("DPO Pia", { force: true });
cy.wrap($el)
.find("form")
.last()
.find("label")
.first()
.click({ force: true });
cy.wrap($el)
.find("form")
.last()
.find("textarea")
.type(
"Nam tincidunt sem vel pretium scelerisque. Aliquam tincidunt commodo magna, vitae rutrum massa. Praesent lobortis porttitor gravida. Fusce nulla libero, feugiat eu sodales at, semper ac diam. Morbi sit amet luctus libero, eu sagittis neque",
{ force: true }
);
cy.wrap($el)

// 1 block
const baseContentDPO = ".pia-entryContentBlock-content-DPO "
const reactTime = 1000
cy.wait(reactTime)
cy.get(baseContentDPO + "input[type=text]").first().type("DPO Pia", { force: true });
cy.get(baseContentDPO + ".pia-entryContentBlock-content-DPO-treatment label").first().click({ force: true });
cy.get(baseContentDPO).find("textarea").type(
"Nam tincidunt sem vel pretium scelerisque. Aliquam tincidunt commodo magna, vitae rutrum massa. Praesent lobortis porttitor gravida. Fusce nulla libero, feugiat eu sodales at, semper ac diam. Morbi sit amet luctus libero, eu sagittis neque",
{ force: true }
);
cy.wait(reactTime)

// 2 block
const baseContentPeople = ".pia-entryContentBlock-content-people "
cy.get(baseContentPeople + "label[for=concerned-people-choice-searched]").first().click({ force: true });

cy.wait(reactTime)
cy.wait(reactTime)
cy.get(baseContentPeople + "input.DPOName").first().type("DPO Pia", { force: true });

cy.wait(reactTime)
cy.get(baseContentPeople + "label[for=dpoAvis-1]").first().click({ force: true });

cy.wait(reactTime)

cy.get(baseContentPeople + "textarea").type(
"Nam tincidunt sem vel pretium scelerisque. Aliquam tincidunt commodo magna, vitae rutrum massa. Praesent lobortis porttitor gravida. Fusce nulla libero, feugiat eu sodales at, semper ac diam. Morbi sit amet luctus libero, eu sagittis neque",
{ force: true }
);
cy.get(baseContentPeople)
.find("form")
.parent()
.click({ force: true });
});
});
Cypress.Commands.add("validatePia", () => {
cy.get(".pia-validatePIABlock")
.find(".btn-green")
.should("have.class", "btn-active")
.click();
cy.wait(2000);
cy.get(".pia-entryContentBlock-content-list-confirm")
cy.wait(1000)
.get(".pia-entryContentBlock-content-list-confirm")
.each(($el, $index, $list) => {
cy.wrap($el)
.find("label")
Expand All @@ -380,7 +362,7 @@ Cypress.Commands.add("refusePia", () => {
.find(".btn-green")
.should("have.class", "btn-active")
.click({ force: true });
cy.wait(500)
cy.wait(1000)
.get(".pia-entryContentBlock-content-list-confirm")
.each(($el, $index, $list) => {
cy.wrap($el)
Expand All @@ -391,17 +373,21 @@ Cypress.Commands.add("refusePia", () => {
cy.get(".btn-red")
.first()
.click();
cy.wait(3000);
cy.wait(6000);
cy.get(".pia-entryContentBlock-content-subject-textarea")
.find("textarea", { force: true })
.type(
"Nam tincidunt sem vel pretium scelerisque. Aliquam tincidunt commodo magna, vitae rutrum massa. Praesent lobortis porttitor gravida. Fusce nulla libero, feugiat eu sodales at, semper ac diam. Morbi sit amet luctus libero, eu sagittis neque",
{ force: true }
);
.then(() => {
cy.get(".pia-entryContentBlock-content-subject-textarea")
.find("textarea", { force: true })
.type(
"Nam tincidunt sem vel pretium scelerisque. Aliquam tincidunt commodo magna, vitae rutrum massa. Praesent lobortis porttitor gravida. Fusce nulla libero, feugiat eu sodales at, semper ac diam. Morbi sit amet luctus libero, eu sagittis neque",
{ force: true }
);
});
cy.get(".pia-entryContentBlock-content-subject")
.wait(500)
.wait(1000)
.click("bottom");
cy.wait(500)
cy.wait(1000)
.get(".pia-entryContentBlock-footer")
.find("button")
.last()
Expand Down

0 comments on commit 9d3586d

Please sign in to comment.