| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134 |
- /// <reference types="cypress" />
- import { routeSelectors } from "../../support/routeSelectors";
- describe("Deployments list", () => {
- beforeEach(() => {
- cy.setProjectIdCookie();
- cy.mockAuth();
- cy.intercept(routeSelectors.ENDPOINTS, {
- fixture: "endpoints/endpoints.json",
- }).as("endpoints");
- });
- const waitForAll = () => {
- cy.waitMockAuth();
- cy.wait(["@endpoints"]);
- };
- it("renders empty list", () => {
- cy.intercept(routeSelectors.DEPLOYMENTS, {
- body: { deployments: [] },
- }).as("deployments");
- cy.visit("/deployments");
- waitForAll();
- cy.wait(["@deployments"]);
- cy.get("div[class^='MainList__EmptyListMessage']").should(
- "contain.text",
- "don't have any Deployments in this project",
- );
- });
- it("filters list", () => {
- cy.visit("/deployments");
- waitForAll();
- cy.loadFixtures(["transfers/migrations"], (results: any[]) => {
- const deployments = results[0].deployments;
- cy.get("div[class^='MainListFilter__FilterItem']")
- .contains("Running")
- .click();
- cy.get("div[class^='MainList__NoResults']").should("exist");
- cy.get("div[class^='MainListFilter__FilterItem']")
- .contains("Error")
- .click();
- cy.get("div[class^='TransferListItem__Wrapper']").should(
- "have.length",
- deployments.filter(r => r.last_execution_status === "ERROR").length,
- );
- cy.get("div[class^='MainListFilter__FilterItem']")
- .contains("Completed")
- .click();
- cy.get("div[class^='TransferListItem__Wrapper']").should(
- "have.length",
- deployments.filter(r => r.last_execution_status === "COMPLETED").length,
- );
- cy.get("div[class^='MainListFilter__FilterItem']")
- .contains("Canceled")
- .click();
- cy.get("div[class^='TransferListItem__Wrapper']").should(
- "have.length",
- deployments.filter(r => r.last_execution_status === "CANCELED").length,
- );
- cy.get("div[class^='MainListFilter__FilterItem']")
- .contains("All")
- .click();
- cy.get("div[class^='TransferListItem__Wrapper']").should(
- "have.length",
- deployments.length,
- );
- cy.get("div[class^='SearchButton__Wrapper']").click();
- cy.get("input[class*='SearchInput']").type("ol88-uefi");
- cy.get("div[class^='TransferListItem__Wrapper']").should(
- "have.length",
- deployments.filter(r => r.instances.find(i => i.includes("ol88-uefi")))
- .length,
- );
- cy.get("div[class^='TextInput__Close']").click();
- });
- });
- it("does bulk actions", () => {
- cy.visit("/deployments");
- waitForAll();
- cy.loadFixtures(["transfers/migrations"], (results: any[]) => {
- const deployments: any[] = results[0].deployments;
- cy.get("div[class*='TransferListItem__Checkbox']").eq(0).click();
- cy.get("div[class^='SearchButton__Wrapper']").click();
- cy.get("input[class*='SearchInput']").type("ol88-uefi");
- cy.get("div[class^='TransferListItem__Wrapper']").should(
- "have.length",
- deployments.filter(r => r.instances.find(i => i.includes("ol88-uefi")))
- .length,
- );
- cy.get("div[class*='TransferListItem__Checkbox']").eq(0).click();
- cy.get("div[class*='MainListFilter__SelectionText']").should(
- "contain.text",
- "2 of 1",
- );
- cy.get("div[class^='ActionDropdown__Wrapper']").click();
- cy.get("div[class^='ActionDropdown__ListItem']")
- .contains("Recreate Deployments")
- .click();
- cy.get("div[class^='AlertModal__Message']").should(
- "contain.text",
- "Are you sure you want to recreate",
- );
- cy.intercept("POST", routeSelectors.DEPLOYMENTS, req => {
- expect(
- req.body.deployment.transfer_id,
- "Transfer ID should be present in the request body",
- ).to.exist;
- }).as("deployments-recreate");
- cy.get("button").contains("Yes").click();
- cy.wait(["@deployments-recreate"]);
- });
- });
- });
|