From bf9d6731583e8520b7f2892239a0fb323bd60de5 Mon Sep 17 00:00:00 2001 From: ocket8888 Date: Tue, 23 Jan 2024 11:24:36 -0700 Subject: [PATCH] Add e2e tests for new context menu action --- .../cypress/e2e/servers/servers.table.cy.ts | 36 ++++++++++++++++++- .../generic-table.component.html | 2 +- 2 files changed, 36 insertions(+), 2 deletions(-) diff --git a/experimental/traffic-portal/cypress/e2e/servers/servers.table.cy.ts b/experimental/traffic-portal/cypress/e2e/servers/servers.table.cy.ts index f5bcda64c8..34917e4494 100644 --- a/experimental/traffic-portal/cypress/e2e/servers/servers.table.cy.ts +++ b/experimental/traffic-portal/cypress/e2e/servers/servers.table.cy.ts @@ -15,10 +15,44 @@ describe("Servers table page", () => { beforeEach(() => { cy.login(); + cy.visit("/core/servers"); }); it("Filters servers by hostname", () => { - cy.visit("/core/servers"); cy.get("input[name=fuzzControl]").focus().type("edge"); cy.window().its("location.search").should("contain", "search=edge"); }); + it("Queues and clears revalidations on a server", () => { + cy.get("input[name=fuzzControl]").focus().type("edge"); + + // We need to force re-rendering of the table every time we do + // something, or cypress moves too fast and undoes things it's doing + // before the effects can be seen. This could be fixed by splitting + // these into separate tests, but that wouldn't be faster and would have + // the added drawback that it depends on the initial state of the data + // and the order in which the tests are run. + const reload = (): void => { + cy.reload(); + cy.get("button[aria-label='column visibility menu']").click(); + cy.get("input[type=checkbox][name='Reval Pending']").check(); + cy.get("body").click(); // closes the menu so you can interact with other things. + }; + + reload(); + + cy.get(".ag-row:visible").first().rightclick(); + cy.get("button").contains("Queue Content Revalidation").click(); + reload(); + + cy.get(".ag-cell[col-id=revalPending]").first().should("contain.text", "schedule"); + cy.get(".ag-row:visible").first().rightclick(); + cy.get("button").contains("Clear Queued Content Revalidations").click(); + reload(); + + cy.get(".ag-cell[col-id=revalPending]").first().should("contain.text", "done"); + cy.get(".ag-row:visible").first().rightclick(); + cy.get("button").contains("Queue Content Revalidation").click(); + reload(); + + cy.get(".ag-cell[col-id=revalPending]").first().should("contain.text", "schedule"); + }); }); diff --git a/experimental/traffic-portal/src/app/shared/generic-table/generic-table.component.html b/experimental/traffic-portal/src/app/shared/generic-table/generic-table.component.html index 774a8e36e3..612e0beb2d 100644 --- a/experimental/traffic-portal/src/app/shared/generic-table/generic-table.component.html +++ b/experimental/traffic-portal/src/app/shared/generic-table/generic-table.component.html @@ -17,7 +17,7 @@
-