|
| 1 | +/// <reference types="cypress" /> |
| 2 | +/// <reference types="@percy/cypress" /> |
| 3 | + |
| 4 | +import locators from "../../../support/locators"; |
| 5 | +import user from "../../../fixtures/user"; |
| 6 | + |
| 7 | +const baseUrlProduction = Cypress.env("BASE_URL_PRODUCTION"); // Production |
| 8 | + |
| 9 | +const baseUrlEnvironment = Cypress.env("BASE_URL_TEST_ENVIRONMENT"); // Test |
| 10 | + |
| 11 | +const login = (username: string, password: any): void => { |
| 12 | + cy.get(locators.login.BTN_LOGIN).should("be.visible"); |
| 13 | + cy.get(locators.login.USER).should("be.empty").type(username); |
| 14 | + cy.get(locators.login.PASSWORD).type(password); |
| 15 | + cy.get(locators.login.BTN_LOGIN).click(); |
| 16 | +}; |
| 17 | + |
| 18 | +describe("Test regression Home Page", () => { |
| 19 | + it("Verifies the home page the url test and snapshots", () => { |
| 20 | + const environment = "Test"; // identificy the environment |
| 21 | + const baseUrl = baseUrlEnvironment; |
| 22 | + |
| 23 | + if (cy.isPercyEnabled()) { |
| 24 | + cy.log(`Percy está ativado? ${Cypress.env("PERCY_ENABLED")}`); |
| 25 | + cy.log( |
| 26 | + `O ambiente detectado pelo Cypress é: ${Cypress.env( |
| 27 | + "ENVIRONMENT" |
| 28 | + )}` |
| 29 | + ); |
| 30 | + |
| 31 | + cy.visit(`${baseUrl}`); |
| 32 | + cy.title().should("contain", "AletheiaFact.org"); |
| 33 | + cy.url().should("contains", "login"); |
| 34 | + cy.percySnapshot(`${environment} - Login Page`, { |
| 35 | + widths: [768, 1024, 1280], |
| 36 | + }); |
| 37 | + |
| 38 | + cy.get('[id="rcc-confirm-button"]').should("be.visible"); |
| 39 | + cy.get('[id="rcc-confirm-button"]').click(); |
| 40 | + cy.percySnapshot( |
| 41 | + `${environment} - Login Page without Cookie Consent`, |
| 42 | + { widths: [768, 1024, 1280] } |
| 43 | + ); |
| 44 | + |
| 45 | + login("knascimento+qatest@aletheiafact.org", user.password); |
| 46 | + |
| 47 | + cy.get(`${locators.claim.BTN_OK_TUTORIAL}`).should("be.visible"); |
| 48 | + cy.percySnapshot(`${environment} - Home page with modal tutorial`, { |
| 49 | + widths: [768, 1024, 1280], |
| 50 | + }); |
| 51 | + |
| 52 | + cy.get(`${locators.claim.BTN_OK_TUTORIAL}`).click(); |
| 53 | + cy.percySnapshot( |
| 54 | + `${environment} - Home page with Donation Banner`, |
| 55 | + { widths: [768, 1024, 1280] } |
| 56 | + ); |
| 57 | + |
| 58 | + cy.get('[data-testid="CloseOutlinedIcon"]') |
| 59 | + .should("be.visible") |
| 60 | + .click(); |
| 61 | + cy.percySnapshot( |
| 62 | + `${environment} - Home page without Donation Banner`, |
| 63 | + { widths: [768, 1024, 1280] } |
| 64 | + ); |
| 65 | + } |
| 66 | + }); |
| 67 | + it("Verifies the home page the url production and snapshots", () => { |
| 68 | + const environment = "Production"; // identificy simple for environment |
| 69 | + const baseUrl = baseUrlProduction; |
| 70 | + |
| 71 | + if (cy.isPercyEnabled()) { |
| 72 | + cy.log(`Percy está ativado? ${Cypress.env("PERCY_ENABLED")}`); |
| 73 | + cy.log( |
| 74 | + `O ambiente detectado pelo Cypress é: ${Cypress.env( |
| 75 | + "ENVIRONMENT" |
| 76 | + )}` |
| 77 | + ); |
| 78 | + |
| 79 | + cy.visit(`${baseUrl}/login`); |
| 80 | + cy.title().should("contain", "AletheiaFact.org"); |
| 81 | + cy.url().should("contain", "login"); |
| 82 | + cy.percySnapshot(`${environment} - Login page`, { |
| 83 | + widths: [768, 1024, 1280], |
| 84 | + }); |
| 85 | + |
| 86 | + cy.get('[id="rcc-confirm-button"]').should("be.visible"); |
| 87 | + cy.get('[id="rcc-confirm-button"]').click(); |
| 88 | + cy.percySnapshot( |
| 89 | + `${environment} - Login page without Cookie Consent`, |
| 90 | + { widths: [768, 1024, 1280] } |
| 91 | + ); |
| 92 | + |
| 93 | + login("keikonichimoto@aletheiafact.org", user.password); |
| 94 | + |
| 95 | + cy.get(`${locators.claim.BTN_OK_TUTORIAL}`).should("be.visible"); |
| 96 | + cy.percySnapshot(`${environment} - Home page with modal tutorial`, { |
| 97 | + widths: [768, 1024, 1280], |
| 98 | + }); |
| 99 | + |
| 100 | + cy.get(`${locators.claim.BTN_OK_TUTORIAL}`).click(); |
| 101 | + cy.percySnapshot( |
| 102 | + `${environment} - Home page with Donation Banner`, |
| 103 | + { widths: [768, 1024, 1280] } |
| 104 | + ); |
| 105 | + |
| 106 | + cy.get('[data-testid="CloseOutlinedIcon"]') |
| 107 | + .should("be.visible") |
| 108 | + .click(); |
| 109 | + cy.percySnapshot( |
| 110 | + `${environment} - Home page without Donation Banner`, |
| 111 | + { widths: [768, 1024, 1280] } |
| 112 | + ); |
| 113 | + } |
| 114 | + }); |
| 115 | +}); |
0 commit comments