migrations-list.cy.ts 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. /// <reference types="cypress" />
  2. import { routeSelectors } from "../../support/routeSelectors";
  3. describe("Migrations 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.MIGRATIONS, {
  17. body: { replicas: [] },
  18. }).as("migrations");
  19. cy.visit("/migrations");
  20. waitForAll();
  21. cy.wait(["@migrations"]);
  22. cy.get("div[class^='MainList__EmptyListMessage']").should(
  23. "contain.text",
  24. "don't have any Migrations in this project"
  25. );
  26. cy.get("button").should("contain.text", "Create a Migration");
  27. });
  28. it("filters list", () => {
  29. cy.visit("/migrations");
  30. waitForAll();
  31. cy.loadFixtures(["transfers/migrations"], (results: any[]) => {
  32. const migrations = results[0].migrations;
  33. cy.get("div[class^='MainListFilter__FilterItem']")
  34. .contains("Running")
  35. .click();
  36. cy.get("div[class^='MainList__NoResults']").should("exist");
  37. cy.get("div[class^='MainListFilter__FilterItem']")
  38. .contains("Error")
  39. .click();
  40. cy.get("div[class^='TransferListItem__Wrapper']").should(
  41. "have.length",
  42. migrations.filter(r => r.last_execution_status === "ERROR").length
  43. );
  44. cy.get("div[class^='MainListFilter__FilterItem']")
  45. .contains("Completed")
  46. .click();
  47. cy.get("div[class^='TransferListItem__Wrapper']").should(
  48. "have.length",
  49. migrations.filter(r => r.last_execution_status === "COMPLETED").length
  50. );
  51. cy.get("div[class^='MainListFilter__FilterItem']")
  52. .contains("Canceled")
  53. .click();
  54. cy.get("div[class^='TransferListItem__Wrapper']").should(
  55. "have.length",
  56. migrations.filter(r => r.last_execution_status === "CANCELED").length
  57. );
  58. cy.get("div[class^='MainListFilter__FilterItem']")
  59. .contains("All")
  60. .click();
  61. cy.get("div[class^='TransferListItem__Wrapper']").should(
  62. "have.length",
  63. migrations.length
  64. );
  65. cy.get("div[class^='SearchButton__Wrapper']").click();
  66. cy.get("input[class*='SearchInput']").type("ol88-uefi");
  67. cy.get("div[class^='TransferListItem__Wrapper']").should(
  68. "have.length",
  69. migrations.filter(r => r.instances.find(i => i.includes("ol88-uefi")))
  70. .length
  71. );
  72. cy.get("div[class^='TextInput__Close']").click();
  73. });
  74. });
  75. it("does bulk actions", () => {
  76. cy.visit("/migrations");
  77. waitForAll();
  78. cy.loadFixtures(["transfers/migrations"], (results: any[]) => {
  79. const migrations: any[] = results[0].migrations;
  80. cy.get("div[class*='TransferListItem__Checkbox']").eq(0).click();
  81. cy.get("div[class^='SearchButton__Wrapper']").click();
  82. cy.get("input[class*='SearchInput']").type("ol88-uefi");
  83. cy.get("div[class^='TransferListItem__Wrapper']").should(
  84. "have.length",
  85. migrations.filter(r => r.instances.find(i => i.includes("ol88-uefi")))
  86. .length
  87. );
  88. cy.get("div[class*='TransferListItem__Checkbox']").eq(0).click();
  89. cy.get("div[class*='MainListFilter__SelectionText']").should(
  90. "contain.text",
  91. "2 of 1"
  92. );
  93. cy.get("div[class^='ActionDropdown__Wrapper']").click();
  94. cy.get("div[class^='ActionDropdown__ListItem']")
  95. .contains("Recreate Migrations")
  96. .click();
  97. cy.get("div[class^='AlertModal__Message']").should(
  98. "contain.text",
  99. "Are you sure you want to recreate"
  100. );
  101. let postCount = 0;
  102. cy.intercept("POST", routeSelectors.MIGRATIONS, req => {
  103. postCount += 1;
  104. if (postCount === 1) {
  105. expect(req.body.migration.instances).to.deep.eq([
  106. "Datacenter/ol88-bios",
  107. ]);
  108. } else if (postCount === 2) {
  109. expect(req.body.migration.instances).to.deep.eq([
  110. "Datacenter/ol88-uefi",
  111. ]);
  112. }
  113. }).as("migrations-recreate");
  114. cy.get("button").contains("Yes").click();
  115. cy.wait(["@migrations-recreate"]);
  116. });
  117. });
  118. });