From 5fb8c79dc0e1fd4bf93a204414eef80c879fcffc Mon Sep 17 00:00:00 2001 From: Sam Vevang Date: Mon, 1 Jul 2024 15:35:57 -0500 Subject: [PATCH 01/12] Set up tests for availability endpoint and campaign report --- cypress/e2e/augury.cy.ts | 65 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) diff --git a/cypress/e2e/augury.cy.ts b/cypress/e2e/augury.cy.ts index b68cd68..1ba9723 100644 --- a/cypress/e2e/augury.cy.ts +++ b/cypress/e2e/augury.cy.ts @@ -81,4 +81,69 @@ describe("Augury", () => { // cy.contains("button.btn-danger", "Delete Creative").click(); // cy.contains("Creative deleted"); }); + + + it("checks inventory availability", () => { + cy.visit("/availability"); + + // Functions to be implemented + cy.getStartDateInput().type("2024-07-01"); + cy.getEndDateInput().type("2024-07-31"); + cy.selectSlimSelect("#inventory_id", "Acceptance Test Series") + cy.selectSlimSelect("#zone", "House Preroll") + + cy.getAvailabilityResults().should("be.visible"); + cy.getAvailabilityResults().contains("Calculate"); + cy.getAvailabilityResults().click(); + + // page should container "Forecasted Inventory" + cy.contains("Forecasted Inventory"); + }); + + it("generates a campaign report", () => { + // Assuming we have a campaign with ID 1 + cy.visit("/reports"); + cy.contains("Navigate to different types of reports across Dovetail"); + + + cy.get("#campaign_id + .ss-main").click() // Open the dropdown + + // The dropdown is disconnected/supra of the #campaign_id element + var res = cy.get(".ss-open-below .ss-search input[type=search]").click({ multiple: true }); + res.type("C"); + cy.contains("Campaign Acceptance Test"); + res.type("{downArrow}{enter}"); + + cy.get("#campaign_id").closest(".card").find(".btn").click(); + + cy.contains("Report Builder"); + + }); }); + +declare namespace Cypress { + interface Chainable { + getStartDateInput(): Chainable> + getEndDateInput(): Chainable> + getInventoryTypeSelect(): Chainable> + getAvailabilityResults(): Chainable> + selectSlimSelect(selector: string, value: string): Chainable> + } +} + +// Custom commands that can be chained +Cypress.Commands.add("getStartDateInput", () => { + return cy.get('input#start_date') +}); + +Cypress.Commands.add("getEndDateInput", () => { + return cy.get('input#end_date') +}); + +Cypress.Commands.add("getInventoryTypeSelect", () => { +}); + +Cypress.Commands.add('selectSlimSelect', (selector, value) => { + cy.get(`${selector} + .ss-main`).click() // Open the dropdown + cy.get('.ss-option').contains(value).click() // Select the option +}) \ No newline at end of file From d17a904a2b5a39f6a6a1e837b0644bf07d222d7f Mon Sep 17 00:00:00 2001 From: Sam Vevang Date: Mon, 1 Jul 2024 15:40:18 -0500 Subject: [PATCH 02/12] Lint --- cypress/e2e/augury.cy.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/cypress/e2e/augury.cy.ts b/cypress/e2e/augury.cy.ts index 1ba9723..a60dc0e 100644 --- a/cypress/e2e/augury.cy.ts +++ b/cypress/e2e/augury.cy.ts @@ -146,4 +146,8 @@ Cypress.Commands.add("getInventoryTypeSelect", () => { Cypress.Commands.add('selectSlimSelect', (selector, value) => { cy.get(`${selector} + .ss-main`).click() // Open the dropdown cy.get('.ss-option').contains(value).click() // Select the option -}) \ No newline at end of file +}) + +Cypress.Commands.add("getAvailabilityResults", () => { + cy.get('form.button_to button[type="submit"]') +}); From d99d885f8e8d46ea968de071e17d522445859aff Mon Sep 17 00:00:00 2001 From: Sam Vevang Date: Mon, 1 Jul 2024 15:43:45 -0500 Subject: [PATCH 03/12] Lint --- cypress/e2e/augury.cy.ts | 98 +++++++++++++++++++--------------------- 1 file changed, 47 insertions(+), 51 deletions(-) diff --git a/cypress/e2e/augury.cy.ts b/cypress/e2e/augury.cy.ts index a60dc0e..f90fa50 100644 --- a/cypress/e2e/augury.cy.ts +++ b/cypress/e2e/augury.cy.ts @@ -82,72 +82,68 @@ describe("Augury", () => { // cy.contains("Creative deleted"); }); - - it("checks inventory availability", () => { - cy.visit("/availability"); - - // Functions to be implemented - cy.getStartDateInput().type("2024-07-01"); - cy.getEndDateInput().type("2024-07-31"); - cy.selectSlimSelect("#inventory_id", "Acceptance Test Series") - cy.selectSlimSelect("#zone", "House Preroll") - - cy.getAvailabilityResults().should("be.visible"); - cy.getAvailabilityResults().contains("Calculate"); - cy.getAvailabilityResults().click(); - - // page should container "Forecasted Inventory" - cy.contains("Forecasted Inventory"); - }); - - it("generates a campaign report", () => { - // Assuming we have a campaign with ID 1 - cy.visit("/reports"); - cy.contains("Navigate to different types of reports across Dovetail"); - - - cy.get("#campaign_id + .ss-main").click() // Open the dropdown - - // The dropdown is disconnected/supra of the #campaign_id element - var res = cy.get(".ss-open-below .ss-search input[type=search]").click({ multiple: true }); - res.type("C"); - cy.contains("Campaign Acceptance Test"); - res.type("{downArrow}{enter}"); - - cy.get("#campaign_id").closest(".card").find(".btn").click(); - - cy.contains("Report Builder"); - - }); + it("checks inventory availability", () => { + cy.visit("/availability"); + + // Functions to be implemented + cy.getStartDateInput().type("2024-07-01"); + cy.getEndDateInput().type("2024-07-31"); + cy.selectSlimSelect("#inventory_id", "Acceptance Test Series"); + cy.selectSlimSelect("#zone", "House Preroll"); + + cy.getAvailabilityResults().should("be.visible"); + cy.getAvailabilityResults().contains("Calculate"); + cy.getAvailabilityResults().click(); + + // page should container "Forecasted Inventory" + cy.contains("Forecasted Inventory"); + }); + + it("generates a campaign report", () => { + // Assuming we have a campaign with ID 1 + cy.visit("/reports"); + cy.contains("Navigate to different types of reports across Dovetail"); + + cy.get("#campaign_id + .ss-main").click(); // Open the dropdown + + // The dropdown is disconnected/supra of the #campaign_id element + var res = cy.get(".ss-open-below .ss-search input[type=search]").click({ multiple: true }); + res.type("C"); + cy.contains("Campaign Acceptance Test"); + res.type("{downArrow}{enter}"); + + cy.get("#campaign_id").closest(".card").find(".btn").click(); + + cy.contains("Report Builder"); + }); }); declare namespace Cypress { interface Chainable { - getStartDateInput(): Chainable> - getEndDateInput(): Chainable> - getInventoryTypeSelect(): Chainable> - getAvailabilityResults(): Chainable> - selectSlimSelect(selector: string, value: string): Chainable> + getStartDateInput(): Chainable>; + getEndDateInput(): Chainable>; + getInventoryTypeSelect(): Chainable>; + getAvailabilityResults(): Chainable>; + selectSlimSelect(selector: string, value: string): Chainable>; } } // Custom commands that can be chained Cypress.Commands.add("getStartDateInput", () => { - return cy.get('input#start_date') + return cy.get("input#start_date"); }); Cypress.Commands.add("getEndDateInput", () => { - return cy.get('input#end_date') + return cy.get("input#end_date"); }); -Cypress.Commands.add("getInventoryTypeSelect", () => { -}); +Cypress.Commands.add("getInventoryTypeSelect", () => {}); -Cypress.Commands.add('selectSlimSelect', (selector, value) => { - cy.get(`${selector} + .ss-main`).click() // Open the dropdown - cy.get('.ss-option').contains(value).click() // Select the option -}) +Cypress.Commands.add("selectSlimSelect", (selector, value) => { + cy.get(`${selector} + .ss-main`).click(); // Open the dropdown + cy.get(".ss-option").contains(value).click(); // Select the option +}); Cypress.Commands.add("getAvailabilityResults", () => { - cy.get('form.button_to button[type="submit"]') + cy.get('form.button_to button[type="submit"]'); }); From fa691c09a75ab1f833d1339e17d96cf94b5f8c92 Mon Sep 17 00:00:00 2001 From: Sam Vevang Date: Mon, 1 Jul 2024 15:47:10 -0500 Subject: [PATCH 04/12] Don't assign to intermediate variable --- cypress/e2e/augury.cy.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/cypress/e2e/augury.cy.ts b/cypress/e2e/augury.cy.ts index f90fa50..5b7da4e 100644 --- a/cypress/e2e/augury.cy.ts +++ b/cypress/e2e/augury.cy.ts @@ -107,10 +107,11 @@ describe("Augury", () => { cy.get("#campaign_id + .ss-main").click(); // Open the dropdown // The dropdown is disconnected/supra of the #campaign_id element - var res = cy.get(".ss-open-below .ss-search input[type=search]").click({ multiple: true }); - res.type("C"); + cy.get(".ss-open-below .ss-search input[type=search]").click({ multiple: true }).type("C"); cy.contains("Campaign Acceptance Test"); - res.type("{downArrow}{enter}"); + cy.get(".ss-open-below .ss-search input[type=search]") + .click({ multiple: true }) + .type("{downArrow}{enter}"); cy.get("#campaign_id").closest(".card").find(".btn").click(); From 7be4ba64bd819572e91f063d99907cf71a2342f0 Mon Sep 17 00:00:00 2001 From: Sam Vevang Date: Mon, 1 Jul 2024 15:54:34 -0500 Subject: [PATCH 05/12] Add type references --- cypress/e2e/augury.cy.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/cypress/e2e/augury.cy.ts b/cypress/e2e/augury.cy.ts index 5b7da4e..bc1e4f9 100644 --- a/cypress/e2e/augury.cy.ts +++ b/cypress/e2e/augury.cy.ts @@ -1,3 +1,6 @@ +/// +/// + describe("Augury", () => { beforeEach(() => { cy.login(Cypress.env("TEST_PRX_USER"), Cypress.env("TEST_PRX_PASS")); From 38243874005b346897490c3aeb97ed151dd218e0 Mon Sep 17 00:00:00 2001 From: Sam Vevang Date: Mon, 1 Jul 2024 16:13:01 -0500 Subject: [PATCH 06/12] More linting --- .eslintrc | 4 ++++ cypress/e2e/augury.cy.ts | 12 ++++++------ 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/.eslintrc b/.eslintrc index 0c57feb..d47034a 100644 --- a/.eslintrc +++ b/.eslintrc @@ -8,6 +8,10 @@ "ecmaVersion": "latest", "sourceType": "module" }, + "rules": { + "no-use-before-define": "off", + "no-unused-vars": "off" + }, "overrides": [ { "files": "**/*.ts", diff --git a/cypress/e2e/augury.cy.ts b/cypress/e2e/augury.cy.ts index bc1e4f9..95e3225 100644 --- a/cypress/e2e/augury.cy.ts +++ b/cypress/e2e/augury.cy.ts @@ -1,5 +1,4 @@ -/// -/// +/* global JQuery */ describe("Augury", () => { beforeEach(() => { @@ -110,11 +109,12 @@ describe("Augury", () => { cy.get("#campaign_id + .ss-main").click(); // Open the dropdown // The dropdown is disconnected/supra of the #campaign_id element - cy.get(".ss-open-below .ss-search input[type=search]").click({ multiple: true }).type("C"); + cy.get(".ss-open-below .ss-search input[type=search]").click({ multiple: true }); + cy.get(".ss-open-below .ss-search input[type=search]").type("C"); + cy.contains("Campaign Acceptance Test"); - cy.get(".ss-open-below .ss-search input[type=search]") - .click({ multiple: true }) - .type("{downArrow}{enter}"); + cy.get(".ss-open-below .ss-search input[type=search]").type("{downArrow}{enter}"); + cy.get(".ss-open-below .ss-search input[type=search]").click({ multiple: true }); cy.get("#campaign_id").closest(".card").find(".btn").click(); From 9acca75f6f24856c3becdae10fa2dcb3f76795e1 Mon Sep 17 00:00:00 2001 From: Sam Vevang Date: Tue, 2 Jul 2024 09:03:48 -0500 Subject: [PATCH 07/12] Block for search box --- cypress/e2e/augury.cy.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/cypress/e2e/augury.cy.ts b/cypress/e2e/augury.cy.ts index 95e3225..5e12b55 100644 --- a/cypress/e2e/augury.cy.ts +++ b/cypress/e2e/augury.cy.ts @@ -107,6 +107,7 @@ describe("Augury", () => { cy.contains("Navigate to different types of reports across Dovetail"); cy.get("#campaign_id + .ss-main").click(); // Open the dropdown + cy.contains("Search"); // The dropdown is disconnected/supra of the #campaign_id element cy.get(".ss-open-below .ss-search input[type=search]").click({ multiple: true }); From 649053337aeffb5ed95f74c9ada82cb096acf155 Mon Sep 17 00:00:00 2001 From: Sam Vevang Date: Tue, 2 Jul 2024 09:05:55 -0500 Subject: [PATCH 08/12] Remove unneeded click --- cypress/e2e/augury.cy.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/cypress/e2e/augury.cy.ts b/cypress/e2e/augury.cy.ts index 5e12b55..89bd5e6 100644 --- a/cypress/e2e/augury.cy.ts +++ b/cypress/e2e/augury.cy.ts @@ -115,8 +115,6 @@ describe("Augury", () => { cy.contains("Campaign Acceptance Test"); cy.get(".ss-open-below .ss-search input[type=search]").type("{downArrow}{enter}"); - cy.get(".ss-open-below .ss-search input[type=search]").click({ multiple: true }); - cy.get("#campaign_id").closest(".card").find(".btn").click(); cy.contains("Report Builder"); From 06ed31f63068c679197b732dbf1d065b60b985ba Mon Sep 17 00:00:00 2001 From: Sam Vevang Date: Tue, 2 Jul 2024 12:22:54 -0500 Subject: [PATCH 09/12] Depend on previously created campaign --- cypress/e2e/augury.cy.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/cypress/e2e/augury.cy.ts b/cypress/e2e/augury.cy.ts index 89bd5e6..c99a793 100644 --- a/cypress/e2e/augury.cy.ts +++ b/cypress/e2e/augury.cy.ts @@ -102,7 +102,6 @@ describe("Augury", () => { }); it("generates a campaign report", () => { - // Assuming we have a campaign with ID 1 cy.visit("/reports"); cy.contains("Navigate to different types of reports across Dovetail"); From 6aee6dbcc5f28e18e44849d070f4894f70ddb355 Mon Sep 17 00:00:00 2001 From: Sam Vevang Date: Tue, 2 Jul 2024 12:51:00 -0500 Subject: [PATCH 10/12] It should contain preroll --- cypress/e2e/augury.cy.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/cypress/e2e/augury.cy.ts b/cypress/e2e/augury.cy.ts index c99a793..b9f3431 100644 --- a/cypress/e2e/augury.cy.ts +++ b/cypress/e2e/augury.cy.ts @@ -91,6 +91,7 @@ describe("Augury", () => { cy.getStartDateInput().type("2024-07-01"); cy.getEndDateInput().type("2024-07-31"); cy.selectSlimSelect("#inventory_id", "Acceptance Test Series"); + cy.contains("House Preroll"); cy.selectSlimSelect("#zone", "House Preroll"); cy.getAvailabilityResults().should("be.visible"); From b83dba010685e44dad10aeb2c738150bc433b55f Mon Sep 17 00:00:00 2001 From: Sam Vevang Date: Tue, 2 Jul 2024 13:00:49 -0500 Subject: [PATCH 11/12] Try to confirm the option is present --- cypress/e2e/augury.cy.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/cypress/e2e/augury.cy.ts b/cypress/e2e/augury.cy.ts index b9f3431..995d4d6 100644 --- a/cypress/e2e/augury.cy.ts +++ b/cypress/e2e/augury.cy.ts @@ -144,6 +144,7 @@ Cypress.Commands.add("getInventoryTypeSelect", () => {}); Cypress.Commands.add("selectSlimSelect", (selector, value) => { cy.get(`${selector} + .ss-main`).click(); // Open the dropdown + cy.contains(value); // Confirm the option is present cy.get(".ss-option").contains(value).click(); // Select the option }); From 1f4ad40305e9d86b60d9a79682ef30d0c1c289c1 Mon Sep 17 00:00:00 2001 From: Sam Vevang Date: Tue, 2 Jul 2024 13:16:41 -0500 Subject: [PATCH 12/12] Force --- cypress/e2e/augury.cy.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cypress/e2e/augury.cy.ts b/cypress/e2e/augury.cy.ts index 995d4d6..cd7cef8 100644 --- a/cypress/e2e/augury.cy.ts +++ b/cypress/e2e/augury.cy.ts @@ -145,7 +145,7 @@ Cypress.Commands.add("getInventoryTypeSelect", () => {}); Cypress.Commands.add("selectSlimSelect", (selector, value) => { cy.get(`${selector} + .ss-main`).click(); // Open the dropdown cy.contains(value); // Confirm the option is present - cy.get(".ss-option").contains(value).click(); // Select the option + cy.get(".ss-option").contains(value).click({ force: true }); // Select the option }); Cypress.Commands.add("getAvailabilityResults", () => {