-
Notifications
You must be signed in to change notification settings - Fork 17
Expand file tree
/
Copy pathopenApp.spec.ts
More file actions
72 lines (55 loc) · 2.52 KB
/
openApp.spec.ts
File metadata and controls
72 lines (55 loc) · 2.52 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
import { test, expect } from '@playwright/test';
import {
checkSchemaTitleForText,
checkToolbarTitleForText,
getCurrentEditorMode,
openApp,
openAppWithMode
} from "./utils";
import {SessionMode} from "../src/store/sessionMode";
import {tpGetData} from "./utilsTestPanel";
test('Open the app and check that the initial mode is Data Editor', async ({ page }) => {
// Go to the app
await openApp(page)
// Check that the current mode is Data Editor
const currentMode = await getCurrentEditorMode(page)
expect(currentMode).toBe(SessionMode.DataEditor)
});
test('Open the app in the schema editor mode and check that the initial mode is Schema Editor', async ({ page }) => {
// Go to the app
await openAppWithMode(page, SessionMode.SchemaEditor)
// Check that the current mode is Schema Editor
const newMode = await getCurrentEditorMode(page)
expect(newMode).toBe(SessionMode.SchemaEditor)
});
test('Open the app in the settings mode and check that the initial mode is Settings', async ({ page }) => {
// Go to the app
await openAppWithMode(page, SessionMode.Settings)
// Check that the current mode is Settings
const newMode = await getCurrentEditorMode(page)
expect(newMode).toBe(SessionMode.Settings)
});
test('Open the app with pre-loaded data, schema and settings', async ({ page }) => {
// Go to the app with pre-loaded data, schema and settings
await openApp(page, 'settings_testpanel.json', 'data_minimal.json', 'schema_minimal.schema.json')
// Wait for the app to load
await page.waitForTimeout(2000)
// Check that the current mode is Data Editor
const currentMode = await getCurrentEditorMode(page)
expect(currentMode).toBe(SessionMode.DataEditor)
// Check that the data is loaded correctly
const currentData = await tpGetData(page, SessionMode.DataEditor);
expect(currentData).toEqual({ name: 'Alex', age: 25 });
// Check that the correct schema is loaded via the schema title
await checkSchemaTitleForText(page, 'Person');
// Check that the settings are loaded correctly using the toolbar title
await checkToolbarTitleForText(page, 'Test');
});
test('Go through the initial schema selection dialog', async ({ page }) => {
// Go to the app
await openApp(page)
// Wait for the dialog with "Select your preferences" to appear
await expect(page.getByText('Select a Schema')).toBeVisible()
// Click the button with "Example Schema"
await page.getByRole('button', { name: 'Example Schema' }).click()
});