-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Handle empty IP Address field in Network Interface create flow (#1854)
* Add onBlur to better handle empty IP Address field * Add test for network-interface-create flow * Use transform rather than onChange * More succinct prop description * small tweaks --------- Co-authored-by: David Crespo <[email protected]>
- Loading branch information
1 parent
b9013a3
commit 7c6f53d
Showing
3 changed files
with
91 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
/* | ||
* 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 { test } from '@playwright/test' | ||
|
||
import { expect, expectRowVisible } from './utils' | ||
|
||
test('can create a NIC with a specified IP address', async ({ page }) => { | ||
// go to an instance’s Network Interfaces page | ||
await page.goto('/projects/mock-project/instances/db1/network-interfaces') | ||
|
||
// stop the instance | ||
await page.getByRole('button', { name: 'Instance actions' }).click() | ||
await page.getByRole('menuitem', { name: 'Stop' }).click() | ||
|
||
// open the add network interface side modal | ||
await page.getByRole('button', { name: 'Add network interface' }).click() | ||
|
||
// fill out the form | ||
await page.getByLabel('Name').fill('nic-1') | ||
await page.getByRole('button', { name: 'VPC' }).click() | ||
await page.getByRole('option', { name: 'mock-vpc' }).click() | ||
await page.getByRole('button', { name: 'Subnet' }).click() | ||
await page.getByRole('option', { name: 'mock-subnet' }).click() | ||
await page.getByLabel('IP Address').fill('1.2.3.4') | ||
|
||
const sidebar = page.getByRole('dialog', { name: 'Add network interface' }) | ||
|
||
// test that the form can be submitted and a new network interface is created | ||
await sidebar.getByRole('button', { name: 'Add network interface' }).click() | ||
await expect(sidebar).toBeHidden() | ||
|
||
await expectRowVisible(page.getByRole('table'), { name: 'nic-1', ip: '1.2.3.4' }) | ||
}) | ||
|
||
test('can create a NIC with a blank IP address', async ({ page }) => { | ||
// go to an instance’s Network Interfaces page | ||
await page.goto('/projects/mock-project/instances/db1/network-interfaces') | ||
|
||
// stop the instance | ||
await page.getByRole('button', { name: 'Instance actions' }).click() | ||
await page.getByRole('menuitem', { name: 'Stop' }).click() | ||
|
||
// open the add network interface side modal | ||
await page.getByRole('button', { name: 'Add network interface' }).click() | ||
|
||
// fill out the form | ||
await page.getByLabel('Name').fill('nic-2') | ||
await page.getByRole('button', { name: 'VPC' }).click() | ||
await page.getByRole('option', { name: 'mock-vpc' }).click() | ||
await page.getByRole('button', { name: 'Subnet' }).click() | ||
await page.getByRole('option', { name: 'mock-subnet' }).click() | ||
|
||
// make sure the IP address field has a non-conforming bit of text in it | ||
await page.getByLabel('IP Address').fill('x') | ||
|
||
// try to submit it | ||
const sidebar = page.getByRole('dialog', { name: 'Add network interface' }) | ||
await sidebar.getByRole('button', { name: 'Add network interface' }).click() | ||
|
||
// it should error out | ||
// todo: improve error message from API | ||
await expect(sidebar.getByText('Unknown server error')).toBeVisible() | ||
|
||
// make sure the IP address field has spaces in it | ||
await page.getByLabel('IP Address').fill(' ') | ||
|
||
// test that the form can be submitted and a new network interface is created | ||
await sidebar.getByRole('button', { name: 'Add network interface' }).click() | ||
await expect(sidebar).toBeHidden() | ||
|
||
// ip address is auto-assigned | ||
await expectRowVisible(page.getByRole('table'), { name: 'nic-2', ip: '123.45.68.8' }) | ||
}) |