-
Notifications
You must be signed in to change notification settings - Fork 12
/
snapshots.e2e.ts
122 lines (92 loc) · 4.21 KB
/
snapshots.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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
/*
* 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 { expect, expectNotVisible, expectRowVisible, expectVisible, test } from './utils'
test('Click through snapshots', async ({ page }) => {
await page.goto('/projects/mock-project')
await page.click('role=link[name*="Snapshots"]')
await expectVisible(page, [
'role=heading[name*="Snapshots"]',
'role=cell[name="snapshot-1"]',
'role=cell[name="snapshot-2"]',
'role=cell[name="delete-500"]',
'role=cell[name="snapshot-4"]',
'role=cell[name="snapshot-disk-deleted"]',
])
// test async disk name fetch
const table = page.getByRole('table')
await expectRowVisible(table, { name: 'snapshot-1', disk: 'disk-1' })
await expectRowVisible(table, { name: 'snapshot-disk-deleted', disk: 'Deleted' })
})
test('Confirm delete snapshot', async ({ page }) => {
await page.goto('/projects/mock-project/snapshots')
const row = page.getByRole('row', { name: 'disk-1-snapshot-7' })
// scroll a little so the dropdown menu isn't behind the pagination bar
await page.getByRole('table').click() // focus the content pane
await page.mouse.wheel(0, 200)
async function clickDelete() {
await row.getByRole('button', { name: 'Row actions' }).click()
await page.getByRole('menuitem', { name: 'Delete' }).click()
}
await clickDelete()
const modal = page.getByRole('dialog', { name: 'Confirm delete' })
await expect(modal).toBeVisible()
// cancel works
await page.getByRole('button', { name: 'Cancel' }).click()
await expect(modal).toBeHidden()
// get back in there
await clickDelete()
await page.getByRole('button', { name: 'Confirm' }).click()
// modal closes, row is gone
await expectNotVisible(page, [modal, row])
})
test('Error on delete snapshot', async ({ page }) => {
await page.goto('/projects/mock-project/snapshots')
const row = page.getByRole('row', { name: 'delete-500' })
await row.getByRole('button', { name: 'Row actions' }).click()
await page.getByRole('menuitem', { name: 'Delete' }).click()
const modal = page.getByRole('dialog', { name: 'Confirm delete' })
await expect(modal).toBeVisible()
const spinner = page.getByRole('dialog').getByLabel('Spinner')
await expect(spinner).toBeHidden()
await page.getByRole('button', { name: 'Confirm' }).click()
await expect(spinner).toBeVisible()
// modal closes, but row is not gone and error toast is visible
await expect(modal).toBeHidden()
await expectVisible(page, [
row,
page.getByText('Could not delete resource', { exact: true }),
])
})
test('Create image from snapshot', async ({ page }) => {
await page.goto('/projects/mock-project/snapshots')
const row = page.getByRole('row', { name: 'snapshot-4' })
await row.getByRole('button', { name: 'Row actions' }).click()
await page.getByRole('menuitem', { name: 'Create image' }).click()
await expectVisible(page, ['role=dialog[name="Create image from snapshot"]'])
await page.fill('role=textbox[name="Name"]', 'image-from-snapshot-4')
await page.fill('role=textbox[name="Description"]', 'image description')
await page.fill('role=textbox[name="OS"]', 'Ubuntu')
await page.fill('role=textbox[name="Version"]', '20.02')
await page.click('role=button[name="Create image"]')
await expect(page).toHaveURL('/projects/mock-project/snapshots')
await page.click('role=link[name*="Images"]')
await expectRowVisible(page.getByRole('table'), {
name: 'image-from-snapshot-4',
description: 'image description',
})
})
test('Create image from snapshot, name taken', async ({ page }) => {
await page.goto('/projects/mock-project/snapshots')
const row = page.getByRole('row', { name: 'snapshot-4' })
await row.getByRole('button', { name: 'Row actions' }).click()
await page.getByRole('menuitem', { name: 'Create image' }).click()
await expectVisible(page, ['role=dialog[name="Create image from snapshot"]'])
await page.fill('role=textbox[name="Name"]', 'image-1')
await page.click('role=button[name="Create image"]')
await expect(page.getByText('name already exists').nth(0)).toBeVisible()
})