-
Notifications
You must be signed in to change notification settings - Fork 23
Expand file tree
/
Copy pathsystem-update.e2e.ts
More file actions
138 lines (101 loc) · 5.59 KB
/
system-update.e2e.ts
File metadata and controls
138 lines (101 loc) · 5.59 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
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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
/*
* 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, expectToast, getPageAsUser, test } from './utils'
test('Update status displays correctly', async ({ page }) => {
await page.goto('/system/update')
await expect(page.getByRole('heading', { name: 'System Update' })).toBeVisible()
// Verify target release is 17.0.0 in the properties table
await expect(page.getByLabel('Properties table')).toContainText('17.0.0')
await expect(page.getByText('Progress')).toBeVisible()
await expect(page.getByText('60%')).toBeVisible() // 12/20 = 60%
await expect(page.getByText('(12 of 20)')).toBeVisible()
await expect(page.getByText('Suspended No')).toBeVisible()
await expect(page.getByText('Releases')).toBeVisible()
await expect(page.getByText('rack-18.0.0.zip')).toBeVisible()
await expect(page.getByText('rack-17.0.0.zip')).toBeVisible()
await expect(page.getByText('rack-16.0.0.zip')).toBeVisible()
// Verify the Target badge is specifically on the 17.0.0 entry
const release17 = page.getByRole('listitem').filter({ hasText: '17.0.0' })
await expect(release17.getByText('Target')).toBeVisible()
// Verify the badge is NOT on the 18.0.0 entry
const release18 = page.getByRole('listitem').filter({ hasText: '18.0.0' })
await expect(release18.getByText('Target')).toBeHidden()
})
test('Set target release', async ({ page }) => {
await page.goto('/system/update')
await expect(page.getByText('Releases')).toBeVisible()
// Verify initial state: 17.0.0 is the target
await expect(page.getByLabel('Properties table')).toContainText('17.0.0')
const release17 = page.getByRole('listitem').filter({ hasText: '17.0.0' })
await expect(release17.getByText('Target')).toBeVisible()
// Current target (17.0.0) should be disabled
await page.getByRole('button', { name: '17.0.0 actions' }).click()
const disabledItem = page.getByRole('menuitem', { name: 'Set as target release' })
await expect(disabledItem).toBeDisabled()
await disabledItem.hover()
await expect(page.getByText('Already set as target')).toBeVisible()
await page.keyboard.press('Escape')
// Upgrade to 18.0.0
await page.getByRole('button', { name: '18.0.0 actions' }).click()
await page.getByRole('menuitem', { name: 'Set as target release' }).click()
const modal = page.getByRole('dialog', { name: 'Confirm set target release' })
await expect(modal).toBeVisible()
await expect(
modal.getByText('Are you sure you want to set 18.0.0 as the target release?')
).toBeVisible()
await page.getByRole('button', { name: 'Confirm' }).click()
await expectToast(page, 'Target release updated')
// Verify the target release updated in the properties table
await expect(page.getByLabel('Properties table')).toContainText('18.0.0')
// Verify the badge moved from 17.0.0 to 18.0.0
await expect(release17.getByText('Target')).toBeHidden()
const release18 = page.getByRole('listitem').filter({ hasText: '18.0.0' })
await expect(release18.getByText('Target')).toBeVisible()
// Set target on 17 should still be disabled, but now for a different reason
await page.getByRole('button', { name: '17.0.0 actions' }).click()
const setTargetItem = page.getByRole('menuitem', { name: 'Set as target release' })
await expect(setTargetItem).toBeDisabled()
await setTargetItem.hover()
await expect(page.getByText('Cannot set older release as target')).toBeVisible()
})
test('Cannot downgrade to older release', async ({ page }) => {
await page.goto('/system/update')
// Verify initial state: 17.0.0 is the target
await expect(page.getByLabel('Properties table')).toContainText('17.0.0')
const release17 = page.getByRole('listitem').filter({ hasText: '17.0.0' })
await expect(release17.getByText('Target')).toBeVisible()
// Try to downgrade to 16.0.0 - button should be disabled
await page.getByRole('button', { name: '16.0.0 actions' }).click()
const setTargetItem = page.getByRole('menuitem', { name: 'Set as target release' })
await expect(setTargetItem).toBeDisabled()
await setTargetItem.hover()
await expect(page.getByText('Cannot set older release as target')).toBeVisible()
// Verify the target release has NOT changed - still 17.0.0
await expect(page.getByLabel('Properties table')).toContainText('17.0.0')
await expect(release17.getByText('Target')).toBeVisible()
const release16 = page.getByRole('listitem').filter({ hasText: '16.0.0' })
await expect(release16.getByText('Target')).toBeHidden()
})
test('Fleet viewer cannot set target release', async ({ browser }) => {
const page = await getPageAsUser(browser, 'Jane Austen')
await page.goto('/system/update')
// Verify initial state: 17.0.0 is the target
await expect(page.getByLabel('Properties table')).toContainText('17.0.0')
// Try to set 18.0.0 as target
await page.getByRole('button', { name: '18.0.0 actions' }).click()
await page.getByRole('menuitem', { name: 'Set as target release' }).click()
await page.getByRole('button', { name: 'Confirm' }).click()
// can't do it
await expectToast(page, 'Action not authorized')
// Verify the target release has NOT changed - still 17.0.0
await expect(page.getByLabel('Properties table')).toContainText('17.0.0')
const release17 = page.getByRole('listitem').filter({ hasText: '17.0.0' })
await expect(release17.getByText('Target')).toBeVisible()
const release18 = page.getByRole('listitem').filter({ hasText: '18.0.0' })
await expect(release18.getByText('Target')).toBeHidden()
})