forked from freeCodeCamp/freeCodeCamp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathreset-editor-layout.spec.ts
48 lines (36 loc) · 1.5 KB
/
reset-editor-layout.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
import { test, expect } from '@playwright/test';
test.describe('Reset Editor Layout', () => {
test('drag layout and reset', async ({ page, isMobile }) => {
test.skip(
isMobile,
'The mobile layout does not have resizable panes, so this test is not applicable.'
);
await page.goto(
'/learn/2022/responsive-web-design/learn-basic-css-by-building-a-cafe-menu/step-15'
);
const desktopLayout = page.getByTestId('desktop-layout');
const splitter = page.getByTestId('preview-left-splitter');
const editorPane = desktopLayout.getByTestId('editor-pane');
const initialStyle = await editorPane.getAttribute('style');
expect(initialStyle).toContain('flex: 1');
// Drag the splitter to resize the editor pane
await splitter.hover();
await page.mouse.down();
await page.mouse.move(100, 100);
await page.mouse.up();
const newStyle = await editorPane.getAttribute('style');
expect(newStyle).not.toContain('flex: 1');
await page.goto('/settings#privacy-settings');
const resetButton = page.getByTestId('reset-layout-btn');
await resetButton.click();
await expect(page.getByTestId('flash-message')).toContainText(
'Your editor layout has been reset'
);
await expect(resetButton).toBeDisabled();
await page.goto(
'/learn/2022/responsive-web-design/learn-basic-css-by-building-a-cafe-menu/step-15'
);
const afterReset = await editorPane.getAttribute('style');
expect(afterReset).toContain('flex: 1');
});
});