Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions test/e2e/image-upload.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ async function fillForm(page: Page, name: string) {
await page.fill('role=textbox[name="Description"]', 'image description')
await page.fill('role=textbox[name="OS"]', 'Ubuntu')
await page.fill('role=textbox[name="Version"]', 'Dapper Drake')
await chooseFile(page, page.getByLabel('Image file'))
await chooseFile(page.getByLabel('Image file'))
}

test.describe('Image upload', () => {
Expand Down Expand Up @@ -114,7 +114,7 @@ test.describe('Image upload', () => {
await expectNotVisible(page, [nameRequired])

// now set the file, clear it, and submit again
await chooseFile(page, page.getByLabel('Image file'))
await chooseFile(page.getByLabel('Image file'))
await expectNotVisible(page, [fileRequired])

await page.click('role=button[name="Clear file"]')
Expand Down
8 changes: 4 additions & 4 deletions test/e2e/silos.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,8 @@ test('Create silo', async ({ page }) => {
// Validation error for missing name + key and cert files
await expectVisible(page, [certRequired, keyRequired, nameRequired])

await chooseFile(page, page.getByLabel('Cert', { exact: true }), 'small')
await chooseFile(page, page.getByLabel('Key'), 'small')
await chooseFile(page.getByLabel('Cert', { exact: true }), 'small')
await chooseFile(page.getByLabel('Key'), 'small')
const certName = certDialog.getByRole('textbox', { name: 'Name' })
await certName.fill('test-cert')

Expand All @@ -118,8 +118,8 @@ test('Create silo', async ({ page }) => {

// Change the name so it's unique
await certName.fill('test-cert-2')
await chooseFile(page, page.getByLabel('Cert', { exact: true }), 'small')
await chooseFile(page, page.getByLabel('Key'), 'small')
await chooseFile(page.getByLabel('Cert', { exact: true }), 'small')
await chooseFile(page.getByLabel('Key'), 'small')
await certSubmit.click()
await expect(page.getByRole('cell', { name: 'test-cert-2', exact: true })).toBeVisible()

Expand Down
15 changes: 4 additions & 11 deletions test/e2e/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -254,15 +254,8 @@ export const sleep = (ms: number) => new Promise((resolve) => setTimeout(resolve
const bigFile = Buffer.alloc(3 * MiB, 'a')
const smallFile = Buffer.alloc(0.1 * MiB, 'a')

export async function chooseFile(
page: Page,
inputLocator: Locator,
size: 'large' | 'small' = 'large'
) {
const fileChooserPromise = page.waitForEvent('filechooser')
await inputLocator.click({ force: true })
const fileChooser = await fileChooserPromise
await fileChooser.setFiles({
export async function chooseFile(input: Locator, size: 'large' | 'small' = 'large') {
await input.setInputFiles({
name: 'my-image.iso',
mimeType: 'application/octet-stream',
// fill with nonzero content, otherwise we'll skip the whole thing, which
Expand All @@ -288,8 +281,8 @@ export async function addTlsCert(page: Page) {
.getByRole('dialog', { name: 'Add TLS certificate' })
.getByRole('textbox', { name: 'Name' })
.fill('test-cert')
await chooseFile(page, page.getByLabel('Cert', { exact: true }), 'small')
await chooseFile(page, page.getByLabel('Key'), 'small')
await chooseFile(page.getByLabel('Cert', { exact: true }), 'small')
await chooseFile(page.getByLabel('Key'), 'small')
await page.getByRole('button', { name: 'Add Certificate' }).click()
}

Expand Down
Loading