-
Notifications
You must be signed in to change notification settings - Fork 12
/
floating-ip-create.e2e.ts
98 lines (78 loc) · 3.31 KB
/
floating-ip-create.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
/*
* 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, expectRowVisible, expectVisible, test } from './utils'
const floatingIpsPage = '/projects/mock-project/floating-ips'
test('can create a floating IP', async ({ page }) => {
await page.goto(floatingIpsPage)
await page.locator('text="New Floating IP"').click()
await expectVisible(page, [
'role=heading[name*="Create floating IP"]',
'role=textbox[name="Name"]',
'role=textbox[name="Description"]',
'role=button[name="Advanced"]',
'role=button[name="Create floating IP"]',
])
const floatingIpName = 'my-floating-ip'
await page.fill('input[name=name]', floatingIpName)
await page
.getByRole('textbox', { name: 'Description' })
.fill('A description for this Floating IP')
const label = page.getByLabel('IP pool')
// accordion content should be hidden
await expect(label).toBeHidden()
// open accordion
await page.getByRole('button', { name: 'Advanced' }).click()
// accordion content should be visible
await expect(label).toBeVisible()
// choose pool and submit
await label.click()
await page.getByRole('option', { name: 'ip-pool-1' }).click()
await page.getByRole('button', { name: 'Create floating IP' }).click()
await expect(page).toHaveURL(floatingIpsPage)
await expectRowVisible(page.getByRole('table'), {
name: floatingIpName,
description: 'A description for this Floating IP',
'IP pool': 'ip-pool-1',
})
})
test('can detach and attach a floating IP', async ({ page }) => {
// check floating IP is visible on instance detail
await page.goto('/projects/mock-project/instances/db1')
await expect(page.getByText('123.4.56.5')).toBeVisible()
// now go detach it
await page.goto(floatingIpsPage)
await expectRowVisible(page.getByRole('table'), {
name: 'cola-float',
'IP address': '123.4.56.5',
'Attached to instance': 'db1',
})
await clickRowAction(page, 'cola-float', 'Detach')
await page.getByRole('button', { name: 'Confirm' }).click()
await expect(page.getByRole('dialog')).toBeHidden()
// Since we detached it, we don't expect to see db1 any longer
await expect(page.getByRole('cell', { name: 'db1' })).toBeHidden()
// click back over to instance page (can't use goto because it refreshes) and
// confirm the IP is no longer there either
await page.getByRole('link', { name: 'Instances' }).click()
await page.getByRole('link', { name: 'db1' }).click()
await expect(page.getByRole('heading', { name: 'db1' })).toBeVisible()
await expect(page.getByText('123.4.56.5')).toBeHidden()
// Now click back to floating IPs and reattach it to db1
await page.getByRole('link', { name: 'Floating IPs' }).click()
await clickRowAction(page, 'cola-float', 'Attach')
await page.getByLabel('Instance').click()
await page.getByRole('option', { name: 'db1' }).click()
await page.getByRole('button', { name: 'Attach' }).click()
// The dialog should be gone
await expect(page.getByRole('dialog')).toBeHidden()
await expectRowVisible(page.getByRole('table'), {
name: 'cola-float',
'IP address': '123.4.56.5',
'Attached to instance': 'db1',
})
})