deployments-list.cy.ts 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. /// <reference types="cypress" />
  2. import { routeSelectors } from "../../support/routeSelectors";
  3. describe("Deployments list", () => {
  4. beforeEach(() => {
  5. cy.setProjectIdCookie();
  6. cy.mockAuth();
  7. cy.intercept(routeSelectors.ENDPOINTS, {
  8. fixture: "endpoints/endpoints.json",
  9. }).as("endpoints");
  10. });
  11. const waitForAll = () => {
  12. cy.waitMockAuth();
  13. cy.wait(["@endpoints"]);
  14. };
  15. it("renders empty list", () => {
  16. cy.intercept(routeSelectors.DEPLOYMENTS, {
  17. body: { deployments: [] },
  18. }).as("deployments");
  19. cy.visit("/deployments");
  20. waitForAll();
  21. cy.wait(["@deployments"]);
  22. cy.get("div[class^='MainList__EmptyListMessage']").should(
  23. "contain.text",
  24. "don't have any Deployments in this project",
  25. );
  26. });
  27. it("filters list", () => {
  28. cy.visit("/deployments");
  29. waitForAll();
  30. cy.loadFixtures(["transfers/migrations"], (results: any[]) => {
  31. const deployments = results[0].deployments;
  32. cy.get("div[class^='MainListFilter__FilterItem']")
  33. .contains("Running")
  34. .click();
  35. cy.get("div[class^='MainList__NoResults']").should("exist");
  36. cy.get("div[class^='MainListFilter__FilterItem']")
  37. .contains("Error")
  38. .click();
  39. cy.get("div[class^='TransferListItem__Wrapper']").should(
  40. "have.length",
  41. deployments.filter(r => r.last_execution_status === "ERROR").length,
  42. );
  43. cy.get("div[class^='MainListFilter__FilterItem']")
  44. .contains("Completed")
  45. .click();
  46. cy.get("div[class^='TransferListItem__Wrapper']").should(
  47. "have.length",
  48. deployments.filter(r => r.last_execution_status === "COMPLETED").length,
  49. );
  50. cy.get("div[class^='MainListFilter__FilterItem']")
  51. .contains("Canceled")
  52. .click();
  53. cy.get("div[class^='TransferListItem__Wrapper']").should(
  54. "have.length",
  55. deployments.filter(r => r.last_execution_status === "CANCELED").length,
  56. );
  57. cy.get("div[class^='MainListFilter__FilterItem']")
  58. .contains("All")
  59. .click();
  60. cy.get("div[class^='TransferListItem__Wrapper']").should(
  61. "have.length",
  62. deployments.length,
  63. );
  64. cy.get("div[class^='SearchButton__Wrapper']").click();
  65. cy.get("input[class*='SearchInput']").type("ol88-uefi");
  66. cy.get("div[class^='TransferListItem__Wrapper']").should(
  67. "have.length",
  68. deployments.filter(r => r.instances.find(i => i.includes("ol88-uefi")))
  69. .length,
  70. );
  71. cy.get("div[class^='TextInput__Close']").click();
  72. });
  73. });
  74. it("does bulk actions", () => {
  75. cy.visit("/deployments");
  76. waitForAll();
  77. cy.loadFixtures(["transfers/migrations"], (results: any[]) => {
  78. const deployments: any[] = results[0].deployments;
  79. cy.get("div[class*='TransferListItem__Checkbox']").eq(0).click();
  80. cy.get("div[class^='SearchButton__Wrapper']").click();
  81. cy.get("input[class*='SearchInput']").type("ol88-uefi");
  82. cy.get("div[class^='TransferListItem__Wrapper']").should(
  83. "have.length",
  84. deployments.filter(r => r.instances.find(i => i.includes("ol88-uefi")))
  85. .length,
  86. );
  87. cy.get("div[class*='TransferListItem__Checkbox']").eq(0).click();
  88. cy.get("div[class*='MainListFilter__SelectionText']").should(
  89. "contain.text",
  90. "2 of 1",
  91. );
  92. cy.get("div[class^='ActionDropdown__Wrapper']").click();
  93. cy.get("div[class^='ActionDropdown__ListItem']")
  94. .contains("Recreate Deployments")
  95. .click();
  96. cy.get("div[class^='AlertModal__Message']").should(
  97. "contain.text",
  98. "Are you sure you want to recreate",
  99. );
  100. cy.intercept("POST", routeSelectors.DEPLOYMENTS, req => {
  101. expect(
  102. req.body.deployment.transfer_id,
  103. "Transfer ID should be present in the request body",
  104. ).to.exist;
  105. }).as("deployments-recreate");
  106. cy.get("button").contains("Yes").click();
  107. cy.wait(["@deployments-recreate"]);
  108. });
  109. });
  110. });