|
| 1 | +/* |
| 2 | + * This Source Code Form is subject to the terms of the Mozilla Public |
| 3 | + * License, v. 2.0. If a copy of the MPL was not distributed with this |
| 4 | + * file, you can obtain one at https://mozilla.org/MPL/2.0/. |
| 5 | + * |
| 6 | + * Copyright Oxide Computer Company |
| 7 | + */ |
| 8 | +import { expect, test } from '@playwright/test' |
| 9 | + |
| 10 | +import { expectObscured } from './utils' |
| 11 | + |
| 12 | +test('Dropdown content can scroll off page and doesn’t hide TopBar', async ({ page }) => { |
| 13 | + // load the page |
| 14 | + await page.goto('/utilization') |
| 15 | + await expect(page.getByText('Capacity & Utilization')).toBeVisible() |
| 16 | + |
| 17 | + const button = page.getByRole('button', { name: 'All projects' }) |
| 18 | + |
| 19 | + // click on the 'All projects' dropdown |
| 20 | + await button.click() |
| 21 | + const options = ['All projects', 'mock-project', 'other-project'] |
| 22 | + for (const name of options) { |
| 23 | + const option = page.getByRole('option', { name }) |
| 24 | + await expect(option).toBeVisible() |
| 25 | + await expect(option).toBeInViewport() |
| 26 | + } |
| 27 | + |
| 28 | + // scroll the page down by 275px |
| 29 | + await page.mouse.wheel(0, 275) |
| 30 | + |
| 31 | + // if we don't do this, the test doesn't wait long enough for the following |
| 32 | + // assertions to become true |
| 33 | + await expect(button).not.toBeInViewport() |
| 34 | + |
| 35 | + // now the top the listbox option is obscured by the topbar |
| 36 | + await expectObscured(page.getByRole('option', { name: 'All projects' })) |
| 37 | + |
| 38 | + // but we can still click the bottom one |
| 39 | + await page.getByRole('option', { name: 'other-project' }).click() |
| 40 | + await expect(page.getByRole('button', { name: 'other-project' })).toBeVisible() |
| 41 | +}) |
| 42 | + |
| 43 | +test('Dropdown content in SidebarModal shows on screen', async ({ page }) => { |
| 44 | + // go to an instance’s Network Interfaces page |
| 45 | + await page.goto('/projects/mock-project/instances/db1/network-interfaces') |
| 46 | + |
| 47 | + // stop the instance |
| 48 | + await page.getByRole('button', { name: 'Instance actions' }).click() |
| 49 | + await page.getByRole('menuitem', { name: 'Stop' }).click() |
| 50 | + |
| 51 | + // open the add network interface side modal |
| 52 | + await page.getByRole('button', { name: 'Add network interface' }).click() |
| 53 | + |
| 54 | + // fill out the form |
| 55 | + await page.getByLabel('Name').fill('alt-nic') |
| 56 | + |
| 57 | + // select the VPC and subnet via the dropdowns. The fact that the options are |
| 58 | + // clickable means they are not obscured due to having a too-low z-index |
| 59 | + await page.getByRole('button', { name: 'VPC' }).click() |
| 60 | + await page.getByRole('option', { name: 'mock-vpc' }).click() |
| 61 | + await page.getByRole('button', { name: 'Subnet' }).click() |
| 62 | + await page.getByRole('option', { name: 'mock-subnet' }).click() |
| 63 | + |
| 64 | + const sidebar = page.getByRole('dialog', { name: 'Add network interface' }) |
| 65 | + |
| 66 | + // verify that the SideModal header is positioned above the TopBar |
| 67 | + await expectObscured(page.getByRole('button', { name: 'User menu' })) |
| 68 | + |
| 69 | + // test that the form can be submitted and a new network interface is created |
| 70 | + await sidebar.getByRole('button', { name: 'Add network interface' }).click() |
| 71 | + await expect(sidebar).toBeHidden() |
| 72 | + await expect(page.getByText('alt-nic')).toBeVisible() |
| 73 | +}) |
0 commit comments