You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

41 line
1.1 KiB

  1. const list_view = "/app/todo";
  2. // test round trip with filter types
  3. const test_queries = [
  4. "?status=Open",
  5. `?date=%5B"Between"%2C%5B"2022-06-01"%2C"2022-06-30"%5D%5D`,
  6. `?date=%5B">"%2C"2022-06-01"%5D`,
  7. `?name=%5B"like"%2C"%2542%25"%5D`,
  8. `?status=%5B"not%20in"%2C%5B"Open"%2C"Closed"%5D%5D`,
  9. ];
  10. describe("SPA Routing", { scrollBehavior: false }, () => {
  11. before(() => {
  12. cy.login();
  13. cy.go_to_list("ToDo");
  14. });
  15. after(() => {
  16. cy.clear_filters(); // avoid flake in future tests
  17. });
  18. it("should apply filter on list view from route", () => {
  19. test_queries.forEach((query) => {
  20. const full_url = `${list_view}${query}`;
  21. cy.visit(full_url);
  22. cy.findByTitle("To Do").should("exist");
  23. const expected = new URLSearchParams(query);
  24. cy.location().then((loc) => {
  25. const actual = new URLSearchParams(loc.search);
  26. // This might appear like a dumb test checking visited URL to itself
  27. // but it's actually doing a round trip
  28. // URL with params -> parsed filters -> new URL
  29. // if it's same that means everything worked in between.
  30. expect(actual.toString()).to.eq(expected.toString());
  31. });
  32. });
  33. });
  34. });