|
5 | 5 | *
|
6 | 6 | * Copyright Oxide Computer Company
|
7 | 7 | */
|
8 |
| -import { clickRowAction, expect, expectRowVisible, test, type Page } from './utils' |
| 8 | +import { |
| 9 | + clickRowAction, |
| 10 | + expect, |
| 11 | + expectRowVisible, |
| 12 | + openRowActions, |
| 13 | + test, |
| 14 | + type Page, |
| 15 | +} from './utils' |
9 | 16 |
|
10 | 17 | const expectInstanceState = async (page: Page, instance: string, state: string) => {
|
11 | 18 | await expectRowVisible(page.getByRole('table'), {
|
@@ -33,10 +40,7 @@ test('can start a failed instance', async ({ page }) => {
|
33 | 40 | await page.goto('/projects/mock-project/instances')
|
34 | 41 |
|
35 | 42 | // check the start button disabled message on a running instance
|
36 |
| - await page |
37 |
| - .getByRole('row', { name: 'db1', exact: false }) |
38 |
| - .getByRole('button', { name: 'Row actions' }) |
39 |
| - .click() |
| 43 | + await openRowActions(page, 'db1') |
40 | 44 | await page.getByRole('menuitem', { name: 'Start' }).hover()
|
41 | 45 | await expect(
|
42 | 46 | page.getByText('Only stopped or failed instances can be started')
|
@@ -99,6 +103,42 @@ test('can stop a starting instance, then start it again', async ({ page }) => {
|
99 | 103 | await expectInstanceState(page, 'not-there-yet', 'running')
|
100 | 104 | })
|
101 | 105 |
|
| 106 | +test('can reboot a running instance', async ({ page }) => { |
| 107 | + await page.goto('/projects/mock-project/instances') |
| 108 | + await expect(page).toHaveTitle('Instances / mock-project / Projects / Oxide Console') |
| 109 | + |
| 110 | + await expectInstanceState(page, 'db1', 'running') |
| 111 | + await clickRowAction(page, 'db1', 'Reboot') |
| 112 | + await page.getByRole('button', { name: 'Confirm' }).click() |
| 113 | + await expectInstanceState(page, 'db1', 'rebooting') |
| 114 | + await expectInstanceState(page, 'db1', 'running') |
| 115 | +}) |
| 116 | + |
| 117 | +test('cannot reboot a failed instance', async ({ page }) => { |
| 118 | + await page.goto('/projects/mock-project/instances') |
| 119 | + await expectInstanceState(page, 'you-fail', 'failed') |
| 120 | + await openRowActions(page, 'you-fail') |
| 121 | + await expect(page.getByRole('menuitem', { name: 'Reboot' })).toBeDisabled() |
| 122 | +}) |
| 123 | + |
| 124 | +test('cannot reboot a starting instance, or a stopped instance', async ({ page }) => { |
| 125 | + await page.goto('/projects/mock-project/instances') |
| 126 | + await expectInstanceState(page, 'not-there-yet', 'starting') |
| 127 | + await openRowActions(page, 'not-there-yet') |
| 128 | + await expect(page.getByRole('menuitem', { name: 'Reboot' })).toBeDisabled() |
| 129 | + // hit escape to close the menu so clickRowAction succeeds |
| 130 | + await page.keyboard.press('Escape') |
| 131 | + |
| 132 | + // stop it so we can try rebooting a stopped instance |
| 133 | + await clickRowAction(page, 'not-there-yet', 'Stop') |
| 134 | + await page.getByRole('button', { name: 'Confirm' }).click() |
| 135 | + await expectInstanceState(page, 'not-there-yet', 'stopping') |
| 136 | + await expectInstanceState(page, 'not-there-yet', 'stopped') |
| 137 | + // reboot is still disabled for a stopped instance |
| 138 | + await openRowActions(page, 'not-there-yet') |
| 139 | + await expect(page.getByRole('menuitem', { name: 'Reboot' })).toBeDisabled() |
| 140 | +}) |
| 141 | + |
102 | 142 | test('delete from instance detail', async ({ page }) => {
|
103 | 143 | await page.goto('/projects/mock-project/instances/you-fail')
|
104 | 144 |
|
|
0 commit comments