-
Notifications
You must be signed in to change notification settings - Fork 11
/
disks.e2e.ts
97 lines (83 loc) · 3.33 KB
/
disks.e2e.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
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
/*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, you can obtain one at https://mozilla.org/MPL/2.0/.
*
* Copyright Oxide Computer Company
*/
import {
clickRowAction,
expect,
expectNoToast,
expectRowVisible,
expectToast,
expectVisible,
test,
} from './utils'
test('List disks and snapshot', async ({ page }) => {
await page.goto('/projects/mock-project/disks')
const table = page.getByRole('table')
await expect(table.getByRole('row')).toHaveCount(12) // 11 + header
// check one attached and one not attached
await expectRowVisible(table, {
'Attached to': 'db1',
name: 'disk-1',
size: '2 GiB',
state: 'attached',
})
await expectRowVisible(table, {
'Attached to': '',
name: 'disk-3',
size: '6 GiB',
state: 'detached',
})
await clickRowAction(page, 'disk-1 db1', 'Snapshot')
await expectToast(page, 'Creating snapshot of disk disk-1')
// expectToast should have closed the toast already, but verify
await expectNoToast(page, 'Creating snapshot of disk disk-1')
// Next line is a little awkward, but we don't actually know what the snapshot name will be
await expectToast(page, /Snapshot disk-1-[a-z0-9]{6} created/)
})
test('Disk snapshot error', async ({ page }) => {
await page.goto('/projects/mock-project/disks')
// special disk that triggers snapshot error
await clickRowAction(page, 'disk-snapshot-error', 'Snapshot')
await expectToast(page, 'Creating snapshot of disk disk-snapshot-error')
// just including an actual expect to satisfy the linter
await expect(page.getByRole('cell', { name: 'disk-snapshot-error' })).toBeVisible()
// expectToast should have closed the toast already, but let's just verify …
await expectNoToast(page, 'Creating snapshot of disk disk-snapshot-error')
// … before we can check for the error toast
await expectToast(page, 'Failed to create snapshotCannot snapshot disk')
})
test.describe('Disk create', () => {
test.beforeEach(async ({ page }) => {
await page.goto('/projects/mock-project/disks-new')
await page.getByRole('textbox', { name: 'Name' }).fill('a-new-disk')
})
test.afterEach(async ({ page }) => {
await page.getByRole('button', { name: 'Create disk' }).click()
await expectToast(page, 'Disk a-new-disk created')
await expectVisible(page, ['role=cell[name="a-new-disk"]'])
})
// expects are in the afterEach
/* eslint-disable playwright/expect-expect */
test('from blank', async ({ page }) => {
await page.getByRole('radio', { name: '512' }).click()
})
test('from snapshot', async ({ page }) => {
await page.getByRole('radio', { name: 'Snapshot' }).click()
await page.getByRole('button', { name: 'Source snapshot' }).click()
await page.getByRole('option', { name: 'delete-500' }).click()
})
test('from image', async ({ page }) => {
await page.getByRole('radio', { name: 'Image' }).click()
await page.getByRole('button', { name: 'Source image' }).click()
await page.getByRole('option', { name: 'image-3' }).click()
})
test('switching to snapshot and back to blank', async ({ page }) => {
await page.getByRole('radio', { name: 'Snapshot' }).click()
await page.getByRole('radio', { name: 'Blank' }).click()
})
/* eslint-enable playwright/expect-expect */
})