From 05e9fc8c35f70385ff9fa3f106a2921e28c481b4 Mon Sep 17 00:00:00 2001 From: Charlie Park Date: Tue, 22 Oct 2024 17:30:45 -0700 Subject: [PATCH] Add test for whitespace trimming --- test/e2e/floating-ip-create.e2e.ts | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/test/e2e/floating-ip-create.e2e.ts b/test/e2e/floating-ip-create.e2e.ts index dfe5af2091..b76d65e4e5 100644 --- a/test/e2e/floating-ip-create.e2e.ts +++ b/test/e2e/floating-ip-create.e2e.ts @@ -24,9 +24,8 @@ test('can create a floating IP', async ({ page }) => { 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 description = page.getByRole('textbox', { name: 'Description' }) + await description.fill('A description for this Floating IP') const poolListbox = page.getByRole('button', { name: 'IP pool' }) @@ -51,6 +50,20 @@ test('can create a floating IP', async ({ page }) => { description: 'A description for this Floating IP', 'IP pool': 'ip-pool-1', }) + + // Make sure that descriptions with only whitespace get trimmed + await page.locator('text="New Floating IP"').click() + await page.fill('input[name=name]', 'no-description') + await description.fill(' ') + await description.blur() + await expect(description).toContainText('') + await page.getByRole('button', { name: 'Create floating IP' }).click() + + await expectRowVisible(page.getByRole('table'), { + name: 'no-description', + description: '—', + 'IP pool': 'ip-pool-1', + }) }) test('can detach and attach a floating IP', async ({ page }) => {