From 1296c27a8d25bbafc8ddc63b2ef33443cc6e2491 Mon Sep 17 00:00:00 2001 From: Giulia Ye Date: Wed, 30 Oct 2024 15:03:20 +0100 Subject: [PATCH] chore: remove caso-morte --- e2e/autofill.spec.ts | 48 ++++++++++++ e2e/path-box.spec.ts | 13 +--- src/lib/components/PathBox.svelte | 5 -- src/lib/components/PathBox.test.ts | 6 +- src/lib/pages/old-life/beneficiariesPage.ts | 23 ------ src/lib/pages/old-life/checkoutPage.ts | 77 -------------------- src/lib/pages/old-life/healthStatusPage.ts | 14 ---- src/lib/pages/old-life/personalDataPage.ts | 69 ------------------ src/lib/pages/old-life/preventivatorePage.ts | 20 ----- src/lib/pages/old-life/yourOfferPage.ts | 20 ----- src/lib/pages/pageFactory.test.ts | 25 ------- src/lib/pages/pageFactory.ts | 17 ----- src/types.ts | 3 +- 13 files changed, 52 insertions(+), 288 deletions(-) create mode 100644 e2e/autofill.spec.ts delete mode 100644 src/lib/pages/old-life/beneficiariesPage.ts delete mode 100644 src/lib/pages/old-life/checkoutPage.ts delete mode 100644 src/lib/pages/old-life/healthStatusPage.ts delete mode 100644 src/lib/pages/old-life/personalDataPage.ts delete mode 100644 src/lib/pages/old-life/preventivatorePage.ts delete mode 100644 src/lib/pages/old-life/yourOfferPage.ts diff --git a/e2e/autofill.spec.ts b/e2e/autofill.spec.ts new file mode 100644 index 0000000..66f7c13 --- /dev/null +++ b/e2e/autofill.spec.ts @@ -0,0 +1,48 @@ +import { test } from "./fixtures"; +import YourOfferPage from "../src/lib/pages/life/yourOfferPage"; +import HealthStatusPage from "../src/lib/pages/life/healthStatusPage"; +import BeneficiariesPage from "../src/lib/pages/life/beneficiariesPage"; +import PersonalDataPage from "../src/lib/pages/life/personalDataPage"; +import CheckoutPage from "../src/lib/pages/life/checkoutPage"; + +test.describe("Autofill", () => { + test(`in /vita path, when user goes to the next page, should still render path box`, async ({ + page, + context, + extensionId, + }) => { + const extensionPage = await context.newPage(); + await page.goto(`https://calc-dev.vitesicure.it/vita/preventivatore`); + + await page.waitForLoadState("networkidle"); + + await extensionPage.goto( + `chrome-extension://${extensionId}/src/entries/popup/index.html`, + ); + + await page.waitForTimeout(1000); + await extensionPage.getByText("Autofill and go to next page").dblclick(); + + await page.bringToFront(); + await page.waitForURL(`**/${YourOfferPage.path}**`); + + await page.waitForTimeout(1000); + await extensionPage.getByText("Autofill and go to next page").dblclick(); + await page.waitForURL(`**/${HealthStatusPage.path}`); + + await page.waitForTimeout(1000); + await extensionPage.getByText("Autofill and go to next page").dblclick(); + await page.waitForURL(`**/${BeneficiariesPage.path}`, { timeout: 50000 }); + + await page.waitForTimeout(1000); + await extensionPage.getByText("Autofill and go to next page").dblclick(); + await page.waitForURL(`**/${PersonalDataPage.path}`); + + await page.waitForTimeout(1000); + await extensionPage.getByText("Autofill and go to next page").dblclick(); + await page.waitForURL(`**/${CheckoutPage.path}`); + await page.waitForTimeout(1000); + await extensionPage.getByText("Autofill and go to next page").dblclick(); + await page.waitForURL(`**/grazie**`, { timeout: 30000 }); + }); +}); diff --git a/e2e/path-box.spec.ts b/e2e/path-box.spec.ts index f6f5ecf..2035b6f 100644 --- a/e2e/path-box.spec.ts +++ b/e2e/path-box.spec.ts @@ -2,7 +2,7 @@ import { type Page } from "@playwright/test"; import { test, expect } from "./fixtures"; test.describe("PathBox", () => { - const paths = ["vita", "caso-morte", "infortuni"]; + const paths = ["vita", "infortuni"]; for (const path of paths) { test(`in /${path} path, should render path box`, async ({ page }) => { @@ -21,11 +21,7 @@ test.describe("PathBox", () => { context, extensionId, }) => { - await page.goto( - `https://calc-dev.vitesicure.it/${ - path === "caso-morte" ? "caso-morte?no-redirect=true" : path - }`, - ); + await page.goto(`https://calc-dev.vitesicure.it/${path}`); await page.waitForLoadState("networkidle"); @@ -50,11 +46,6 @@ async function fillAndGoToNextPage(page: Page, path: string) { await page.click("input[name='privacyPolicyAccepted']"); await page.click("button[data-testid='calculate-offer-button']"); break; - case "caso-morte": - await page.fill("input[name='customerInfo.birthDate']", "26/03/1997"); - await page.click("input[name='agreements.privacyPolicy']"); - await page.click("button[data-testid='calculate-quote-button']"); - break; case "infortuni": await page.click("div[data-testid='injury-select-me']"); const continueButton = page.locator("button", { diff --git a/src/lib/components/PathBox.svelte b/src/lib/components/PathBox.svelte index 15ebba3..732720c 100644 --- a/src/lib/components/PathBox.svelte +++ b/src/lib/components/PathBox.svelte @@ -29,11 +29,6 @@ border-color: #d2527f; color: #d2527f; } - .caso-morte { - background: rgba(39, 174, 96, 0.1); - border-color: #27ae60; - color: #27ae60; - } .infortuni { background: rgba(34, 167, 240, 0.1); border-color: #22a7f0; diff --git a/src/lib/components/PathBox.test.ts b/src/lib/components/PathBox.test.ts index 9272277..2e3b928 100644 --- a/src/lib/components/PathBox.test.ts +++ b/src/lib/components/PathBox.test.ts @@ -17,13 +17,9 @@ describe("PathBox", () => { test.each([ { - currentPath: Product.NetLife, + currentPath: Product.Life, style: "background: rgb(252 165 165); color: rgb(185 28 28);", }, - { - currentPath: Product.SquareLife, - style: "background: rgb(134 239 172); color: rgb(21 128 61);", - }, { currentPath: Product.Injury, style: "background: rgb(147 197 253); color: rgb(29 78 216);", diff --git a/src/lib/pages/old-life/beneficiariesPage.ts b/src/lib/pages/old-life/beneficiariesPage.ts deleted file mode 100644 index d819191..0000000 --- a/src/lib/pages/old-life/beneficiariesPage.ts +++ /dev/null @@ -1,23 +0,0 @@ -import Page from "../page"; - -export default class BeneficieariesPage extends Page { - public static path: string = "beneficiari"; - - private beneficiariesType = "input[name='beneficiaries.type']"; - private capitalToBeneficiaries = - "input[name='agreements.beneficiariesPurpose']"; - private insuranceIsNotSavings = "input[name='agreements.policyPurpose']"; - - async autofill(): Promise { - this.changeInputValue( - this.beneficiariesType, - "LEGITIMATE_AND_TESTAMENTARY_HEIRS", - ); - await this.withDelay(() => { - this.clickInputElement(this.capitalToBeneficiaries); - }); - await this.withDelay(() => { - this.clickInputElement(this.insuranceIsNotSavings); - }); - } -} diff --git a/src/lib/pages/old-life/checkoutPage.ts b/src/lib/pages/old-life/checkoutPage.ts deleted file mode 100644 index db194b9..0000000 --- a/src/lib/pages/old-life/checkoutPage.ts +++ /dev/null @@ -1,77 +0,0 @@ -import FakeDataService from "../../services/fakeDataService"; -import Page from "../page"; - -export default class CheckoutPage extends Page { - public static path: string = "checkout"; - private documentType = "input[name='customerInfo.document.type']"; - private documentCode = "input[name='customerInfo.document.code']"; - private documentReleaseDate = - "input[name='customerInfo.document.releaseDate']"; - private documentExpirationDate = - "input[name='customerInfo.document.expireDate']"; - private documentReleasePlace = - "input[name='customerInfo.document.releasePlace']"; - private documentReleaseAuthority = - "input[name='customerInfo.document.releaseAuthority']"; - private medicalExams = - "//*[text()[contains(.,'Rispondendo solo alle domande')]]/../../..//button[2]"; - - private dataTruthfulness = - "//*[text()='Acquistando la polizza dichiaro che tutte le informazioni inserite sono vere ed esatte e mi impegno a comunicare ogni variazione od integrazione delle stesse nel rispetto di quanto previsto dalla Legge sulle dichiarazioni rese in fase contrattuale.']/../../..//button[1]"; - - private iban = "input[name='payment.ibanCode']"; - private ibanOwner = - '//*[text()="Confermi di essere l\'intestatario del conto?"]/../../..//button[1]'; - - private termsAndConditions = - "//*[text()[contains(.,'Dichiaro di aver')]]/../../..//button[1]"; - private privacyPolicyExtended = - "//*[text()[contains(.,'Autorizzo')]]/../../..//button[1]"; - private otherPolicies = - "//*[text()[contains(.,'Possiedi altre polizze come quelle che ci hai chiesto?')]]/../../..//button[1]"; - private confirmObligations = - "//*[text()[contains(.,'Confermi che la Polizza deve soddisfare obblighi contrattuali (es. richiesto dalla banca)')]]/../../..//button[1]"; - - async autofill(): Promise { - this.changeInputValue(this.documentType, "PASSPORT"); - await this.withDelay(() => { - this.changeInputValue(this.documentCode, "ASD123"); - }); - await this.withDelay(() => { - this.changeInputValue(this.documentReleaseDate, "01/01/2020"); - }); - await this.withDelay(() => { - this.changeInputValue(this.documentExpirationDate, "01/01/2030"); - }); - await this.withDelay(() => { - this.changeInputValue(this.documentReleasePlace, FakeDataService.city()); - }); - await this.withDelay(() => { - this.changeInputValue(this.documentReleaseAuthority, "PREFECTURE"); - }); - await this.withDelay(() => { - this.changeInputValue(this.iban, "IT80U0300203280965832926428"); - }); - await this.withDelay(() => { - this.clickWithXpath(this.ibanOwner); - }); - await this.withDelay(() => { - this.clickWithXpath(this.medicalExams); - }); - await this.withDelay(() => { - this.clickWithXpath(this.dataTruthfulness); - }); - await this.withDelay(() => { - this.clickWithXpath(this.termsAndConditions); - }); - await this.withDelay(() => { - this.clickWithXpath(this.privacyPolicyExtended); - }); - await this.withDelay(() => { - this.clickWithXpath(this.otherPolicies); - }); - await this.withDelay(() => { - this.clickWithXpath(this.confirmObligations); - }); - } -} diff --git a/src/lib/pages/old-life/healthStatusPage.ts b/src/lib/pages/old-life/healthStatusPage.ts deleted file mode 100644 index be6de9b..0000000 --- a/src/lib/pages/old-life/healthStatusPage.ts +++ /dev/null @@ -1,14 +0,0 @@ -import Page from "../page"; - -export default class HealthStatusPage extends Page { - public static path: string = "stato-di-salute"; - - private privacyPolicy = - '//*[text()[contains(.,"Ai sensi della vigente normativa sulla Privacy,")]]/../../..//button[1]'; - private questions = "div[data-testid] button:nth-child(2)"; - - async autofill(): Promise { - this.clickWithXpath(this.privacyPolicy); - this.clickMultiples(this.questions); - } -} diff --git a/src/lib/pages/old-life/personalDataPage.ts b/src/lib/pages/old-life/personalDataPage.ts deleted file mode 100644 index d7a757a..0000000 --- a/src/lib/pages/old-life/personalDataPage.ts +++ /dev/null @@ -1,69 +0,0 @@ -import FakeDataService from "../../services/fakeDataService"; -import Page from "../page"; - -export default class PersonalDataPage extends Page { - public static path: string = "dati-personali"; - - private birthCity = "input[name='customerInfo.birthCity']"; - private gender = "input[name='customerInfo.gender']"; - private fiscalCode = '//input[@name="customerInfo.fiscalCode"]/..//button'; - - private job = "input[name='customerInfo.job']"; - private maritalStatus = "input[name='customerInfo.maritalStatus']"; - private familyUnitType = "input[name='customerInfo.familyUnitType']"; - private isPoliticallExposed = - "//*[text()='Sei una persona politicamente esposta e/o ricopri incarichi amministrativi pubblici importanti anche se non politici?']/../../..//button[2]"; - private allInfoViaEmail = - "//*[text()='Confermi di voler ricevere tutte le informazioni via email?']/../../..//button[2]"; - private street = "input[name='street']"; - private streetNumber = "input[name='streetNumber']"; - private postalCode = "input[name='postalCode']"; - private city = "input[name='city']"; - private province = "input[name='province']"; - private state = "input[name='state']"; - - async autofill(): Promise { - await this.withDelay(() => { - this.changeInputValue(this.birthCity, FakeDataService.city()); - }); - await this.withDelay(() => { - this.changeInputValue(this.gender, "MALE"); - }); - await this.withDelay(() => { - this.clickWithXpath(this.fiscalCode); - }); - await this.withDelay(() => { - this.changeInputValue(this.job, "LIVESTOCK_BREEDER"); - }); - await this.withDelay(() => { - this.changeInputValue(this.maritalStatus, "SINGLE"); - }); - await this.withDelay(() => { - this.changeInputValue(this.familyUnitType, "SINGLE"); - }); - await this.withDelay(() => { - this.clickWithXpath(this.isPoliticallExposed); - }); - await this.withDelay(() => { - this.clickWithXpath(this.allInfoViaEmail); - }); - await this.withDelay(() => { - this.changeInputValue(this.street, FakeDataService.street()); - }); - await this.withDelay(() => { - this.changeInputValue(this.streetNumber, "99"); - }); - await this.withDelay(() => { - this.changeInputValue(this.postalCode, "20100"); - }); - await this.withDelay(() => { - this.changeInputValue(this.city, "Milano"); - }); - await this.withDelay(() => { - this.changeInputValue(this.province, "MI"); - }); - await this.withDelay(() => { - this.changeInputValue(this.state, "Italia"); - }); - } -} diff --git a/src/lib/pages/old-life/preventivatorePage.ts b/src/lib/pages/old-life/preventivatorePage.ts deleted file mode 100644 index 935484a..0000000 --- a/src/lib/pages/old-life/preventivatorePage.ts +++ /dev/null @@ -1,20 +0,0 @@ -import FakeDataService from "../../services/fakeDataService"; -import Page from "../page"; - -export default class PreventivatorePage extends Page { - public static path: string = "preventivatore"; - - private birthDate = "input[name='customerInfo.birthDate']"; - private smoker = "input[name='data.smoker'][value='N']"; - private privacyPolicy = "input[name='agreements.privacyPolicy']"; - - async autofill(): Promise { - this.changeInputValue(this.birthDate, FakeDataService.birthdate()); - await this.withDelay(() => { - this.clickInputElement(this.smoker); - }); - await this.withDelay(() => { - this.clickInputElement(this.privacyPolicy); - }); - } -} diff --git a/src/lib/pages/old-life/yourOfferPage.ts b/src/lib/pages/old-life/yourOfferPage.ts deleted file mode 100644 index edeacbb..0000000 --- a/src/lib/pages/old-life/yourOfferPage.ts +++ /dev/null @@ -1,20 +0,0 @@ -import FakeDataService from "../../services/fakeDataService"; -import Page from "../page"; - -export default class YourOfferPage extends Page { - public static path: string = "la-tua-offerta"; - - private name = "input[name='customerInfo.firstName']"; - private surname = "input[name='customerInfo.lastName']"; - private email = "input[name='customerInfo.email']"; - private phone = "input[name='customerInfo.phoneNumber']"; - private privacyPolicy = "input[name='agreements.privacyPolicyBroker']"; - - async autofill(): Promise { - this.changeInputValue(this.name, FakeDataService.firstName()); - this.changeInputValue(this.surname, FakeDataService.lastName()); - this.changeInputValue(this.email, FakeDataService.email()); - this.changeInputValue(this.phone, FakeDataService.phone()); - this.clickInputElement(this.privacyPolicy); - } -} diff --git a/src/lib/pages/pageFactory.test.ts b/src/lib/pages/pageFactory.test.ts index 58cffbe..4eea871 100644 --- a/src/lib/pages/pageFactory.test.ts +++ b/src/lib/pages/pageFactory.test.ts @@ -8,12 +8,6 @@ import HealthStatusPage from "./life/healthStatusPage"; import PersonalDataPage from "./life/personalDataPage"; import PreventivatorePage from "./life/preventivatorePage"; import YourOfferPage from "./life/yourOfferPage"; -import OldBeneficiariesPage from "./old-life/beneficiariesPage"; -import OldCheckoutPage from "./old-life/checkoutPage"; -import OldHealthStatusPage from "./old-life/healthStatusPage"; -import OldPersonalDataPage from "./old-life/personalDataPage"; -import OldPreventivatorePage from "./old-life/preventivatorePage"; -import OldYourOfferPage from "./old-life/yourOfferPage"; import PageFactory from "./pageFactory"; describe("PageFactory tests", () => { @@ -37,25 +31,6 @@ describe("PageFactory tests", () => { CheckoutPage, ); - expect(PageFactory.getPage("caso-morte", "preventivatore")).toBeInstanceOf( - OldPreventivatorePage, - ); - expect(PageFactory.getPage("caso-morte", "la-tua-offerta")).toBeInstanceOf( - OldYourOfferPage, - ); - expect(PageFactory.getPage("caso-morte", "stato-di-salute")).toBeInstanceOf( - OldHealthStatusPage, - ); - expect(PageFactory.getPage("caso-morte", "beneficiari")).toBeInstanceOf( - OldBeneficiariesPage, - ); - expect(PageFactory.getPage("caso-morte", "dati-personali")).toBeInstanceOf( - OldPersonalDataPage, - ); - expect(PageFactory.getPage("caso-morte", "checkout")).toBeInstanceOf( - OldCheckoutPage, - ); - expect(PageFactory.getPage("infortuni", "seleziona")).toBeInstanceOf( SelectPage, ); diff --git a/src/lib/pages/pageFactory.ts b/src/lib/pages/pageFactory.ts index 723c260..127c83c 100644 --- a/src/lib/pages/pageFactory.ts +++ b/src/lib/pages/pageFactory.ts @@ -8,12 +8,6 @@ import HealthStatusPage from "./life/healthStatusPage"; import PersonalDataPage from "./life/personalDataPage"; import PreventivatorePage from "./life/preventivatorePage"; import YourOfferPage from "./life/yourOfferPage"; -import OldBeneficiariesPage from "./old-life/beneficiariesPage"; -import OldCheckoutPage from "./old-life/checkoutPage"; -import OldHealthStatusPage from "./old-life/healthStatusPage"; -import OldPersonalDataPage from "./old-life/personalDataPage"; -import OldPreventivatorePage from "./old-life/preventivatorePage"; -import OldYourOfferPage from "./old-life/yourOfferPage"; import type Page from "./page"; export default class PageFactory { @@ -29,17 +23,6 @@ export default class PageFactory { [CheckoutPage.path, new CheckoutPage()], ]), ], - [ - "caso-morte", - new Map([ - [OldPreventivatorePage.path, new OldPreventivatorePage()], - [OldYourOfferPage.path, new OldYourOfferPage()], - [OldHealthStatusPage.path, new OldHealthStatusPage()], - [OldBeneficiariesPage.path, new OldBeneficiariesPage()], - [OldPersonalDataPage.path, new OldPersonalDataPage()], - [OldCheckoutPage.path, new OldCheckoutPage()], - ]), - ], [ "infortuni", new Map([ diff --git a/src/types.ts b/src/types.ts index a4514f4..3136416 100644 --- a/src/types.ts +++ b/src/types.ts @@ -1,5 +1,4 @@ export enum Product { - SquareLife = "caso-morte", - NetLife = "vita", + Life = "vita", Injury = "infortuni", }