-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: refactor all fixtures into boxed steps
- Loading branch information
1 parent
9e9d2bc
commit e3c50c6
Showing
37 changed files
with
1,328 additions
and
1,006 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@siafoundation/e2e': minor | ||
--- | ||
|
||
Refactored all fixtures into boxed steps. |
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 |
---|---|---|
@@ -1,21 +1,24 @@ | ||
import { Page, expect } from '@playwright/test' | ||
import { fillTextInputByName } from '@siafoundation/e2e' | ||
import { fillTextInputByName, step } from '@siafoundation/e2e' | ||
|
||
export async function login({ | ||
page, | ||
address, | ||
password, | ||
}: { | ||
page: Page | ||
address: string | ||
password: string | ||
}) { | ||
await page.goto('/login') | ||
await expect(page).toHaveTitle('hostd') | ||
await page.getByLabel('login settings').click() | ||
await page.getByRole('menuitem', { name: 'Show custom API' }).click() | ||
await fillTextInputByName(page, 'api', address) | ||
await fillTextInputByName(page, 'password', password) | ||
await page.locator('input[name=password]').press('Enter') | ||
await expect(page.getByTestId('navbar').getByText('Overview')).toBeVisible() | ||
} | ||
export const login = step( | ||
'login', | ||
async ({ | ||
page, | ||
address, | ||
password, | ||
}: { | ||
page: Page | ||
address: string | ||
password: string | ||
}) => { | ||
await page.goto('/login') | ||
await expect(page).toHaveTitle('hostd') | ||
await page.getByLabel('login settings').click() | ||
await page.getByRole('menuitem', { name: 'Show custom API' }).click() | ||
await fillTextInputByName(page, 'api', address) | ||
await fillTextInputByName(page, 'password', password) | ||
await page.locator('input[name=password]').press('Enter') | ||
await expect(page.getByTestId('navbar').getByText('Overview')).toBeVisible() | ||
} | ||
) |
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 |
---|---|---|
@@ -1,23 +1,36 @@ | ||
import { Page, expect } from '@playwright/test' | ||
import { step } from '@siafoundation/e2e' | ||
|
||
export async function navigateToDashboard({ page }: { page: Page }) { | ||
await page.getByTestId('sidenav').getByLabel('Overview').click() | ||
await expect(page.getByTestId('navbar').getByText('Overview')).toBeVisible() | ||
} | ||
export const navigateToDashboard = step( | ||
'navigate to dashboard', | ||
async ({ page }: { page: Page }) => { | ||
await page.getByTestId('sidenav').getByLabel('Overview').click() | ||
await expect(page.getByTestId('navbar').getByText('Overview')).toBeVisible() | ||
} | ||
) | ||
|
||
export async function navigateToConfig({ page }: { page: Page }) { | ||
await page.getByTestId('sidenav').getByLabel('Configuration').click() | ||
await expect( | ||
page.getByTestId('navbar').getByText('Configuration') | ||
).toBeVisible() | ||
} | ||
export const navigateToConfig = step( | ||
'navigate to config', | ||
async ({ page }: { page: Page }) => { | ||
await page.getByTestId('sidenav').getByLabel('Configuration').click() | ||
await expect( | ||
page.getByTestId('navbar').getByText('Configuration') | ||
).toBeVisible() | ||
} | ||
) | ||
|
||
export async function navigateToVolumes({ page }: { page: Page }) { | ||
await page.getByTestId('sidenav').getByLabel('Volumes').click() | ||
await expect(page.getByTestId('navbar').getByText('Volumes')).toBeVisible() | ||
} | ||
export const navigateToVolumes = step( | ||
'navigate to volumes', | ||
async ({ page }: { page: Page }) => { | ||
await page.getByTestId('sidenav').getByLabel('Volumes').click() | ||
await expect(page.getByTestId('navbar').getByText('Volumes')).toBeVisible() | ||
} | ||
) | ||
|
||
export async function navigateToWallet(page: Page) { | ||
await page.getByTestId('sidenav').getByLabel('Wallet').click() | ||
await expect(page.getByTestId('navbar').getByText('Wallet')).toBeVisible() | ||
} | ||
export const navigateToWallet = step( | ||
'navigate to wallet', | ||
async (page: Page) => { | ||
await page.getByTestId('sidenav').getByLabel('Wallet').click() | ||
await expect(page.getByTestId('navbar').getByText('Wallet')).toBeVisible() | ||
} | ||
) |
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 |
---|---|---|
@@ -1,67 +1,82 @@ | ||
import { Page, expect } from '@playwright/test' | ||
import { navigateToVolumes } from './navigate' | ||
import { fillTextInputByName } from '@siafoundation/e2e' | ||
import { fillTextInputByName, step } from '@siafoundation/e2e' | ||
|
||
export async function createVolume(page: Page, name: string, path: string) { | ||
const fullPath = `${path}/${name}` | ||
await navigateToVolumes({ page }) | ||
await page.getByText('Create volume').click() | ||
await fillTextInputByName(page, 'name', name) | ||
await fillTextInputByName(page, 'immediatePath', path) | ||
// immediatePath updates path after 500ms | ||
// eslint-disable-next-line playwright/no-wait-for-timeout | ||
await page.waitForTimeout(1000) | ||
await fillTextInputByName(page, 'size', '11') | ||
await expect( | ||
page.getByRole('dialog').getByText('Must be between 10.00 GB') | ||
).toBeHidden() | ||
await page.locator('input[name=size]').press('Enter') | ||
await expect(page.getByRole('dialog')).toBeHidden() | ||
const row = page.getByRole('row', { name: fullPath }) | ||
await expect(page.getByText('Volume created')).toBeVisible() | ||
await expect(row.getByText('ready')).toBeVisible() | ||
await expect(page.getByRole('cell', { name: fullPath })).toBeVisible() | ||
} | ||
export const createVolume = step( | ||
'create volume', | ||
async (page: Page, name: string, path: string) => { | ||
const fullPath = `${path}/${name}` | ||
await navigateToVolumes({ page }) | ||
await page.getByText('Create volume').click() | ||
await fillTextInputByName(page, 'name', name) | ||
await fillTextInputByName(page, 'immediatePath', path) | ||
// immediatePath updates path after 500ms | ||
// eslint-disable-next-line playwright/no-wait-for-timeout | ||
await page.waitForTimeout(1000) | ||
await fillTextInputByName(page, 'size', '11') | ||
await expect( | ||
page.getByRole('dialog').getByText('Must be between 10.00 GB') | ||
).toBeHidden() | ||
await page.locator('input[name=size]').press('Enter') | ||
await expect(page.getByRole('dialog')).toBeHidden() | ||
const row = page.getByRole('row', { name: fullPath }) | ||
await expect(page.getByText('Volume created')).toBeVisible() | ||
await expect(row.getByText('ready')).toBeVisible() | ||
await expect(page.getByRole('cell', { name: fullPath })).toBeVisible() | ||
} | ||
) | ||
|
||
export async function deleteVolume(page: Page, name: string, path: string) { | ||
const fullPath = `${path}/${name}` | ||
await openVolumeContextMenu(page, fullPath) | ||
const menuDelete = page.getByRole('menuitem', { name: 'Delete' }) | ||
await menuDelete.click({ timeout: 10_000 }) | ||
await fillTextInputByName(page, 'path', fullPath) | ||
await page.locator('input[name=path]').press('Enter') | ||
await expect(page.getByRole('dialog')).toBeHidden() | ||
await expect( | ||
page.getByText('Volume is now being permanently deleted') | ||
).toBeVisible() | ||
await volumeNotInList(page, fullPath) | ||
} | ||
export const deleteVolume = step( | ||
'delete volume', | ||
async (page: Page, name: string, path: string) => { | ||
const fullPath = `${path}/${name}` | ||
await openVolumeContextMenu(page, fullPath) | ||
const menuDelete = page.getByRole('menuitem', { name: 'Delete' }) | ||
await menuDelete.click({ timeout: 10_000 }) | ||
await fillTextInputByName(page, 'path', fullPath) | ||
await page.locator('input[name=path]').press('Enter') | ||
await expect(page.getByRole('dialog')).toBeHidden() | ||
await expect( | ||
page.getByText('Volume is now being permanently deleted') | ||
).toBeVisible() | ||
await volumeNotInList(page, fullPath) | ||
} | ||
) | ||
|
||
export async function deleteVolumeIfExists( | ||
page: Page, | ||
name: string, | ||
path: string | ||
) { | ||
const doesVolumeExist = await page | ||
.getByRole('table') | ||
.getByText(path + '/' + name) | ||
.isVisible() | ||
if (doesVolumeExist) { | ||
await deleteVolume(page, name, path) | ||
export const deleteVolumeIfExists = step( | ||
'delete volume if exists', | ||
async (page: Page, name: string, path: string) => { | ||
const doesVolumeExist = await page | ||
.getByRole('table') | ||
.getByText(path + '/' + name) | ||
.isVisible() | ||
if (doesVolumeExist) { | ||
await deleteVolume(page, name, path) | ||
} | ||
} | ||
} | ||
) | ||
|
||
export async function openVolumeContextMenu(page: Page, name: string) { | ||
await page | ||
.getByRole('row', { name }) | ||
.getByLabel('volume context menu') | ||
.click() | ||
} | ||
export const openVolumeContextMenu = step( | ||
'open volume context menu', | ||
async (page: Page, name: string) => { | ||
const menu = page | ||
.getByRole('row', { name }) | ||
.getByLabel('volume context menu') | ||
await expect(menu).toBeVisible() | ||
await menu.click() | ||
} | ||
) | ||
|
||
export async function volumeInList(page: Page, name: string) { | ||
await expect(page.getByRole('table').getByText(name)).toBeVisible() | ||
} | ||
export const volumeInList = step( | ||
'volume in list', | ||
async (page: Page, name: string) => { | ||
await expect(page.getByRole('table').getByText(name)).toBeVisible() | ||
} | ||
) | ||
|
||
export async function volumeNotInList(page: Page, name: string) { | ||
await expect(page.getByRole('table').getByText(name)).toBeHidden() | ||
} | ||
export const volumeNotInList = step( | ||
'volume not in list', | ||
async (page: Page, name: string) => { | ||
await expect(page.getByRole('table').getByText(name)).toBeHidden() | ||
} | ||
) |
Oops, something went wrong.