-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
/
Copy pathall.cy.ts
128 lines (97 loc) · 2.85 KB
/
all.cy.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
/// <reference types="cypress" />
/// <reference types="../../cypress/support" />
describe("table-mantine-basic", () => {
beforeEach(() => {
cy.visit("/");
});
it("should work with sorter", () => {
cy.wait("@getPosts");
cy.intercept(
{
url: "/posts*",
query: {
_sort: "id",
_order: "desc",
},
},
{
fixture: "posts.json",
},
).as("getDescPosts");
cy.get(".tabler-icon-selector").first().click();
cy.url().should("include", "sorters[0][field]=id&sorters[0][order]=desc");
cy.wait("@getDescPosts");
cy.intercept(
{
url: "/posts*",
query: {
_sort: "id",
_order: "asc",
},
},
{
fixture: "posts.json",
},
).as("getAscPosts");
cy.get(".tabler-icon-chevron-down").first().click();
cy.url().should("include", "sorters[0][field]=id&sorters[0][order]=asc");
cy.wait("@getAscPosts");
cy.get(".tabler-icon-chevron-down").first().click();
cy.url().should(
"not.include",
"sorters[0][field]=id&sorters[0][order]=desc",
);
cy.wait("@getPosts").then((interception) => {
const { request } = interception;
expect(request.query).not.to.ownProperty("_sort");
});
});
it("should work with filter", () => {
cy.wait("@getPosts");
cy.intercept(
{
url: "/posts*",
query: {
title_like: "lorem",
},
},
{
fixture: "posts.json",
},
).as("getFilteredPosts");
cy.get(".tabler-icon-filter").eq(1).click();
cy.get("#title").type("lorem");
cy.get(".tabler-icon-check").click();
cy.url().should(
"include",
"filters[1][field]=title&filters[1][operator]=contains&filters[1][value]=lorem",
);
cy.wait("@getFilteredPosts");
});
it("should work with pagination", () => {
cy.get(".mantine-Pagination-control").contains("2").click();
cy.url().should("include", "current=2");
cy.wait("@getPosts").then((interception) => {
const { request } = interception;
const { _start, _end } = request.query;
expect(_start).to.equal("10");
expect(_end).to.equal("20");
});
cy.get(".mantine-Pagination-control").contains("1").click();
cy.url().should("include", "current=1");
cy.wait("@getPosts").then((interception) => {
const { request } = interception;
const { _start, _end } = request.query;
expect(_start).to.equal("0");
expect(_end).to.equal("10");
});
});
it("should set current `1` when filter changed", () => {
cy.wait("@getPosts");
cy.get(".mantine-Pagination-control").contains("2").click();
cy.get(".tabler-icon-filter").eq(1).click();
cy.get("#title").type("lorem");
cy.get(".tabler-icon-check").click();
cy.url().should("include", "current=1");
});
});