-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathMenu.spec.ts
More file actions
92 lines (73 loc) · 3.47 KB
/
Copy pathMenu.spec.ts
File metadata and controls
92 lines (73 loc) · 3.47 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
import { expect, test } from './fixtures'
import { BASE_URL, loadTestImage, waitForImageLoad } from './utils'
test.describe('Menu', () => {
test('displays home screen', { tag: '@dom' }, async ({ page }) => {
await page.goto(BASE_URL)
// The brand doubles as the viewer menu (Reset Viewer / About).
expect(await page.$('[data-testid="menu-brand"]')).toBeTruthy()
expect(await page.textContent('text=/Add Image/i')).toBeTruthy()
expect(await page.textContent('text=/View/i')).toBeTruthy()
expect(await page.textContent('text=/Bookmarklet/i')).toBeTruthy()
expect(await page.textContent('text=/Drop Files to load images/i')).toBeTruthy()
})
test('brand menu opens Reset Viewer and About', { tag: '@dom' }, async ({ page }) => {
await page.goto(BASE_URL)
await page.click('data-testid=menu-brand')
expect(await page.textContent('text=/Reset Viewer/i')).toBeTruthy()
await page.click('text=/About/i')
await expect(page.getByTestId('about-dialog')).toBeVisible()
expect(await page.textContent('text=/NeuroDesk/i')).toBeTruthy()
})
test('menubar updates with loading images', async ({ page }) => {
await page.goto(BASE_URL)
// initially only these menu items are visible
expect(await page.textContent('text=/Add Image/i')).toBeTruthy()
expect(await page.textContent('text=/View/i')).toBeTruthy()
// initially these menu items do not exist
expect(await page.$('text=/ColorScale/i')).toBeNull()
expect(await page.$('text=/Overlay/i')).toBeNull()
expect(await page.$('text=/Header/i')).toBeNull()
expect(await page.$('text=/Select/i')).toBeNull()
// load an image
await loadTestImage(page)
expect(
await page.textContent('text=/matrix size:.*voxelsize:/i'),
).toBeTruthy()
// after loading an image these are visible
expect(await page.textContent('text=/Add Image/i')).toBeTruthy()
expect(await page.textContent('text=/View/i')).toBeTruthy()
expect(await page.textContent('text=/ColorScale/i')).toBeTruthy()
expect(await page.textContent('text=/Overlay/i')).toBeTruthy()
expect(await page.textContent('text=/Header/i')).toBeTruthy()
// the select menu item is only visible after loading 2 images
expect(await page.$('text=/Select/i')).toBeNull()
await loadTestImage(page)
expect(await page.textContent('text=/Select/i')).toBeTruthy()
})
test('loads an image and checks the menu bar', async ({ page }) => {
await page.goto(BASE_URL)
await loadTestImage(page)
expect(await page.$$('canvas')).toHaveLength(1)
expect(
await page.textContent('text=/matrix size:.*voxelsize:/i'),
).toBeTruthy()
const menuBar = ['Add Image', 'View', 'ColorScale', 'Overlay', 'Header']
for (const item of menuBar) {
expect(await page.textContent(`text=/${item}/i`)).toBeTruthy()
}
})
test('opens the example image via the menu bar', async ({ page }) => {
// Intercept the remote example image and serve it from local assets to avoid timeouts in CI
await page.route('https://niivue.github.io/niivue-demo-images/mni152.nii.gz', async (route) => {
await route.fulfill({ path: 'public/lesion.nii.gz' })
})
await page.goto(BASE_URL)
await page.click('data-testid=menu-item-dropdown-Add Image')
await page.click('text=/Example Image/i')
await waitForImageLoad(page, 30000)
expect(await page.$$('canvas')).toHaveLength(1)
expect(
await page.textContent('text=/matrix size:.*voxelsize:/i'),
).toBeTruthy()
})
})