endpoints-list.cy.ts 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. /// <reference types="cypress" />
  2. import { routeSelectors } from "../../support/routeSelectors";
  3. describe("Endpoints list", () => {
  4. beforeEach(() => {
  5. cy.setProjectIdCookie();
  6. cy.mockAuth({ filterResources: ["users"] });
  7. cy.intercept(routeSelectors.ENDPOINTS, {
  8. fixture: "endpoints/endpoints",
  9. }).as("endpoints");
  10. });
  11. const waitForAll = () => {
  12. cy.waitMockAuth({ filterResources: ["users"] });
  13. cy.wait(["@endpoints"]);
  14. };
  15. it("renders empty list", () => {
  16. cy.intercept(routeSelectors.ENDPOINTS, {
  17. body: { endpoints: [] },
  18. }).as("endpoints-empty");
  19. cy.visit("/endpoints");
  20. cy.wait(["@endpoints-empty"]);
  21. cy.waitMockAuth({ filterResources: ["users"] });
  22. cy.get("div[class^='MainList__EmptyListMessage']").should(
  23. "contain.text",
  24. "don't have any Cloud Endpoints in this project"
  25. );
  26. cy.get("button").should("contain.text", "Add Endpoint");
  27. });
  28. it("filters list", () => {
  29. cy.visit("/endpoints");
  30. waitForAll();
  31. cy.fixture("endpoints/endpoints").then((endpointsFixture: any) => {
  32. const endpoints = endpointsFixture.endpoints;
  33. cy.get("div[class^='MainListFilter__FilterItem']")
  34. .contains("Azure")
  35. .click();
  36. cy.get("div[class^='EndpointListItem__Wrapper']").should(
  37. "have.length",
  38. endpoints.filter(r => r.type === "azure").length
  39. );
  40. cy.get("div[class^='MainListFilter__FilterItem']")
  41. .contains("VMware")
  42. .click();
  43. cy.get("div[class^='EndpointListItem__Wrapper']").should(
  44. "have.length",
  45. endpoints.filter(r => r.type === "vmware_vsphere").length
  46. );
  47. cy.get("div[class^='SearchButton__Wrapper']").click();
  48. cy.get("input[class*='SearchInput']").type("cor");
  49. cy.get("div[class^='EndpointListItem__Wrapper']").should(
  50. "have.length",
  51. endpoints.filter(
  52. e => e.type === "vmware_vsphere" && e.name.includes("cor")
  53. ).length
  54. );
  55. cy.get("div[class^='TextInput__Close']").click();
  56. cy.get("div[class^='MainListFilter__FilterItem']")
  57. .contains("All")
  58. .click();
  59. cy.get("div[class^='EndpointListItem__Wrapper']").should(
  60. "have.length",
  61. endpoints.length
  62. );
  63. cy.get("div[class^='SearchButton__Wrapper']").click();
  64. cy.get("input[class*='SearchInput']").type("cor");
  65. cy.get("div[class^='EndpointListItem__Wrapper']").should(
  66. "have.length",
  67. endpoints.filter(e => e.name.includes("cor")).length
  68. );
  69. });
  70. });
  71. it("does bulk actions", () => {
  72. cy.visit("/endpoints");
  73. waitForAll();
  74. cy.get("div[class^='SearchButton__Wrapper']").click();
  75. cy.get("input[class*='SearchInput']").type("cor");
  76. cy.get(
  77. "div[class^='MainListFilter__Wrapper'] div[class^='Checkbox__Wrapper']"
  78. ).click();
  79. cy.fixture("endpoints/endpoints").then((endpointsFixture: any) => {
  80. const endpoints = endpointsFixture.endpoints;
  81. const corEndpoints = endpoints.filter(e => e.name.includes("cor"));
  82. cy.get("div[class^='MainListFilter__SelectionText']").should(
  83. "contain.text",
  84. `${corEndpoints.length} of ${corEndpoints.length}`
  85. );
  86. cy.get("div[class^='ActionDropdown__Wrapper']").click();
  87. cy.get("div[class^='ActionDropdown__ListItem']")
  88. .contains("Delete")
  89. .click();
  90. cy.get("div[class^='AlertModal__Message']").should(
  91. "contain.text",
  92. "they are in use by replicas or migrations"
  93. );
  94. });
  95. });
  96. });