-
Notifications
You must be signed in to change notification settings - Fork 87
Expand file tree
/
Copy pathRichText.spec.js
More file actions
187 lines (166 loc) · 8.77 KB
/
Copy pathRichText.spec.js
File metadata and controls
187 lines (166 loc) · 8.77 KB
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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
import { expect, test } from "@playwright/test";
test.afterEach("Cleanup session", async ({ page }) => {
// Because the test isolation that will open a new session for every test executed, and that exceeds Mendix's license limit of 5 sessions, so we need to force logout after each test.
await page.evaluate(() => window.mx.session.logout());
});
test.describe("RichText", () => {
test.describe.configure({ mode: "serial" });
test("compares with a screenshot baseline and checks if inline basic mode are rendered as expected", async ({
page
}) => {
await page.goto("/");
await page.waitForLoadState("networkidle");
await page.click("text=Generate Data");
await page.goto("/p/basic");
await page.waitForLoadState("networkidle");
await page.locator(".mx-name-richText1").scrollIntoViewIfNeeded();
await expect(page.locator(".mx-name-richText1")).toBeVisible();
await expect(page.locator(".mx-name-richText1")).toHaveScreenshot(`inlineBasicMode.png`, { threshold: 0.4 });
});
test("compares with a screenshot baseline and checks if toolbar basic mode are rendered as expected", async ({
page
}) => {
await page.goto("/p/basic");
await page.waitForLoadState("networkidle");
await expect(page.locator(".mx-name-richText4")).toBeVisible();
await expect(page.locator(".mx-name-richText4")).toHaveScreenshot(`toolbarBasicMode.png`, { threshold: 0.4 });
});
test("compares with a screenshot baseline and checks if bottom toolbar advanced mode are rendered as expected", async ({
page
}) => {
await page.goto("/p/advanced");
await page.waitForLoadState("networkidle");
await expect(page.locator(".mx-name-richText1")).toBeVisible();
await expect(page.locator(".mx-name-richText1")).toHaveScreenshot(`bottomToolbarAdvancedMode.png`, {
threshold: 0.4
});
await page.click(".mx-name-richText1 .ql-toolbar button.ql-image");
await expect(page.locator(".widget-rich-text .widget-rich-text-modal-body").first()).toHaveScreenshot(
`insertImageDialog.png`
);
});
test("compares with a screenshot baseline and checks if toolbar advanced mode are rendered as expected", async ({
page
}) => {
await page.goto("/p/advanced");
await page.waitForLoadState("networkidle");
await page.locator(".mx-name-richText4").scrollIntoViewIfNeeded();
await expect(page.locator(".mx-name-richText4")).toBeVisible();
await expect(page.locator(".mx-name-richText4")).toHaveScreenshot(`toolbarAdvancedMode.png`, {
threshold: 0.4
});
await page.click(".mx-name-richText1 .ql-toolbar button.ql-view-code");
await expect(page.locator(".widget-rich-text .widget-rich-text-modal-body").first()).toHaveScreenshot(
`viewCodeDialog.png`
);
});
test("compares with a screenshot baseline and checks if inline custom mode are rendered as expected", async ({
page
}) => {
await page.goto("/p/custom");
await page.waitForLoadState("networkidle");
await expect(page.locator(".mx-name-richText1")).toBeVisible();
await expect(page.locator(".mx-name-richText1")).toHaveScreenshot(`inlineCustomMode.png`, { threshold: 0.4 });
});
test("compares with a screenshot baseline and checks if toolbar custom mode are rendered as expected", async ({
page
}) => {
await page.goto("/p/custom");
await page.waitForLoadState("networkidle");
await expect(page.locator(".mx-name-richText2")).toBeVisible();
await expect(page.locator(".mx-name-richText2")).toHaveScreenshot(`toolbarCustomMode.png`, { threshold: 0.4 });
});
test("compares with a screenshot baseline and checks if inline custom mode with all options enabled are rendered as expected", async ({
page
}) => {
await page.goto("/p/custom");
await page.waitForLoadState("networkidle");
await page.locator(".mx-name-richText3").scrollIntoViewIfNeeded();
await expect(page.locator(".mx-name-richText3")).toBeVisible();
await expect(page.locator(".mx-name-richText3")).toHaveScreenshot(`customModeAllOptions.png`, {
threshold: 0.4
});
});
test("compares with a screenshot baseline and checks if toolbar custom mode with none option enabled are rendered as expected", async ({
page
}) => {
await page.goto("/p/custom");
await page.waitForLoadState("networkidle");
await page.locator(".mx-name-richText4").scrollIntoViewIfNeeded();
await expect(page.locator(".mx-name-richText4")).toBeVisible();
await expect(page.locator(".mx-name-richText4")).toHaveScreenshot(`customModeNoneOptions.png`, {
threshold: 0.4
});
});
test("compares with a screenshot baseline and checks for readonly mode basic styling", async ({ page }) => {
await page.goto("/p/read-only");
await page.waitForLoadState("networkidle");
await page.locator(".mx-name-richText3").scrollIntoViewIfNeeded();
await expect(page.locator(".mx-name-richText3")).toBeVisible();
await expect(page.locator(".mx-name-richText3")).toHaveScreenshot(`readOnlyModeBasic.png`, {
threshold: 0.4
});
});
test("compares with a screenshot baseline and checks for readonly mode bordered styling", async ({ page }) => {
await page.goto("/p/read-only");
await page.waitForLoadState("networkidle");
await page.locator(".mx-name-richText2").scrollIntoViewIfNeeded();
await expect(page.locator(".mx-name-richText2")).toBeVisible();
await expect(page.locator(".mx-name-richText2")).toHaveScreenshot(`readOnlyModeBordered.png`, {
threshold: 0.4
});
});
test("compares with a screenshot baseline and checks for readonly mode read panel styling", async ({ page }) => {
await page.goto("/p/read-only");
await page.waitForLoadState("networkidle");
await page.locator(".mx-name-richText6").scrollIntoViewIfNeeded();
await expect(page.locator(".mx-name-richText6")).toBeVisible();
await expect(page.locator(".mx-name-richText6")).toHaveScreenshot(`readOnlyModeReadPanel.png`, {
threshold: 0.4
});
});
test("compares with a screenshot baseline and checks if class mode editor is rendered as expected", async ({
page
}) => {
await page.goto("/p/classmode");
await page.waitForLoadState("networkidle");
await expect(page.locator(".mx-name-richText1")).toBeVisible();
await expect(page.locator(".mx-name-richText1")).toHaveScreenshot(`classModeEditor.png`, { threshold: 0.4 });
});
test("checks that class mode editor output uses CSS classes instead of inline styles", async ({ page }) => {
await page.goto("/p/classmode");
await page.waitForLoadState("networkidle");
const html = await page.locator(".mx-name-richText1 .ql-editor").innerHTML();
expect(html).toMatch(/class="ql-color-/);
expect(html).toMatch(/class="ql-bg-/);
expect(html).toMatch(/class="ql-indent-/);
expect(html).toMatch(/data-style-format="class"/);
expect(html).not.toMatch(/style="color:/);
expect(html).not.toMatch(/style="background-color:/);
expect(html).not.toMatch(/style="padding-left:/);
});
test("compares with a screenshot baseline of the View/Edit Code dialog in class mode", async ({ page }) => {
await page.goto("/p/classmode");
await page.waitForLoadState("networkidle");
await page.click(".mx-name-richText1 .ql-toolbar button.ql-view-code");
await expect(page.locator(".widget-rich-text .widget-rich-text-modal-body").first()).toHaveScreenshot(
`classModeViewCodeDialog.png`
);
});
test("compares with a screenshot for rich text inside modal popup layout", async ({ page }) => {
await page.goto("/");
await page.waitForLoadState("networkidle");
await page.click(".mx-navbar-item [title='Demo']");
await page.click(".mx-name-customWidget1 .ql-toolbar button.ql-video");
await expect(page.locator(".widget-rich-text .widget-rich-text-modal-body").first()).toHaveScreenshot(
`richTextDialogInsidePopup.png`
);
await page.click(".widget-rich-text .widget-rich-text-modal-body #rich-text-video-src-input");
await page
.locator(".widget-rich-text .widget-rich-text-modal-body #rich-text-video-src-input")
.fill("https://www.mendix.com");
await expect(page.locator(".widget-rich-text .widget-rich-text-modal-body").first()).toHaveScreenshot(
`richTextDialogInsidePopupEdit.png`
);
});
});