forked from freeCodeCamp/freeCodeCamp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscrollbar-width.spec.ts
58 lines (49 loc) · 1.94 KB
/
scrollbar-width.spec.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
import { test, expect } from '@playwright/test';
test.describe('Editor scrollbar width', () => {
test.beforeEach(async ({ page }) => {
await page.goto('/settings');
});
test('Default editor scrollbar width should be 5px', async ({ page }) => {
await expect(page.locator('#scrollbar-width-slider')).toHaveValue('5');
await page.goto(
'/learn/2022/responsive-web-design/learn-html-by-building-a-cat-photo-app/step-2'
);
const upperJawElement = page.locator('.editor-upper-jaw');
const upperJawWidth = await upperJawElement.evaluate(
(node: HTMLElement) => node.offsetWidth
);
const lowerJawElement = page.locator('#editor-lower-jaw');
expect(
await lowerJawElement.evaluate((node: HTMLElement) => node.offsetWidth)
).toEqual(upperJawWidth);
const scrollableElement = page.locator('.monaco-scrollable-element');
expect(
await scrollableElement.evaluate(
(node: HTMLElement) => node.offsetWidth - 5
)
).toEqual(upperJawWidth);
});
test('Should allow you to change editor scrollbar width to 25px', async ({
page
}) => {
await page.locator('.scrollbar-width-numbers > [data-value="25"]').click();
await expect(page.locator('#scrollbar-width-slider')).toHaveValue('25');
await page.goto(
'/learn/2022/responsive-web-design/learn-html-by-building-a-cat-photo-app/step-2'
);
const upperJawElement = page.locator('.editor-upper-jaw');
const upperJawWidth = await upperJawElement.evaluate(
(node: HTMLElement) => node.offsetWidth
);
const lowerJawElement = page.locator('#editor-lower-jaw');
expect(
await lowerJawElement.evaluate((node: HTMLElement) => node.offsetWidth)
).toEqual(upperJawWidth);
const scrollableElement = page.locator('.monaco-scrollable-element');
expect(
await scrollableElement.evaluate(
(node: HTMLElement) => node.offsetWidth - 25
)
).toEqual(upperJawWidth);
});
});