-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
/
Copy pathall.cy.ts
75 lines (59 loc) · 2.22 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
/// <reference types="cypress" />
/// <reference types="../../cypress/support" />
describe("form-mantine-use-form", () => {
const submitForm = () => {
return cy.getSaveButton().click();
};
beforeEach(() => {
cy.clearAllCookies();
cy.clearAllLocalStorage();
cy.clearAllSessionStorage();
cy.visit("/");
});
it("should create form render errors", () => {
cy.getCreateButton().click();
submitForm();
cy.getMantineFormItemError({ id: "title" }).contains(/short/gi);
cy.getMantineFormItemError({ id: "status" }).contains(/required/gi);
cy.getMantineFormItemError({ id: "categoryId" }).contains(/required/gi);
cy.get(".mantine-Text-root").contains(/too short content/i);
});
it("should edit form render errors", () => {
cy.getEditButton().first().click();
// wait loading state and render to be finished
cy.wait("@getPost");
cy.getSaveButton().should("not.be.disabled");
cy.getMantineLoadingOverlay().should("not.exist");
cy.get("#content textarea").clear();
cy.get("#title").clear();
//cy.get("#categoryId").clear();
cy.clearMantineSelect("#categoryId");
submitForm();
cy.getMantineFormItemError({ id: "title" }).contains(/short/gi);
cy.getMantineFormItemError({ id: "categoryId" }).contains(/required/gi);
cy.get(".mantine-Text-root").contains(/too short content/i);
});
it("should create form warn when unsaved changes", () => {
cy.wait("@getPosts");
cy.getCreateButton().click();
cy.get("#title").type("any value");
cy.getPageHeaderTitle().siblings().first().click();
cy.on("window:confirm", (str) => {
expect(str).to.includes("You have unsaved changes");
});
});
it("should edit form warn when unsaved changes", () => {
cy.wait("@getPosts");
cy.getEditButton().first().click();
// wait loading state and render to be finished
cy.wait("@getPost");
cy.getSaveButton().should("not.be.disabled");
cy.getMantineLoadingOverlay().should("not.exist");
cy.get("#title").clear();
cy.get("#title").type("any value");
cy.getPageHeaderTitle().siblings().first().click();
cy.on("window:confirm", (str) => {
expect(str).to.includes("You have unsaved changes");
});
});
});