Files
payload/test/plugin-cloud-storage/e2e.spec.ts
Jacob Fletcher 0be1a1d880 test: semantically splits admin e2e (#10213)
Improves the admin e2e test splitting by grouping them by type with
semantic names as opposed to numerically. This will provide much needed
clarity to exactly _where_ new admin tests should be written and help to
quickly distinguish the areas of failure within the CI overview.
2024-12-28 05:28:37 +00:00

58 lines
1.8 KiB
TypeScript

import type { Page } from '@playwright/test'
import { expect, test } from '@playwright/test'
import * as path from 'path'
import { fileURLToPath } from 'url'
import { ensureCompilationIsDone, saveDocAndAssert } from '../helpers.js'
import { AdminUrlUtil } from '../helpers/adminUrlUtil.js'
import { initPayloadE2ENoConfig } from '../helpers/initPayloadE2ENoConfig.js'
import { TEST_TIMEOUT_LONG } from '../playwright.config.js'
import { mediaSlug } from './shared.js'
const filename = fileURLToPath(import.meta.url)
const dirname = path.dirname(filename)
test.describe('Cloud Storage Plugin', () => {
let page: Page
let mediaURL: AdminUrlUtil
test.beforeAll(async ({ browser }, testInfo) => {
testInfo.setTimeout(TEST_TIMEOUT_LONG)
const { serverURL } = await initPayloadE2ENoConfig({ dirname })
mediaURL = new AdminUrlUtil(serverURL, mediaSlug)
const context = await browser.newContext()
page = await context.newPage()
await ensureCompilationIsDone({ page, serverURL })
})
test('should create file upload', async () => {
await page.goto(mediaURL.create)
await page.setInputFiles('input[type="file"]', path.resolve(dirname, './image.png'))
const filename = page.locator('.file-field__filename')
await expect(filename).toHaveValue('image.png')
await saveDocAndAssert(page)
})
test('should update an existing upload', async () => {
await page.goto(mediaURL.create)
await page.setInputFiles('input[type="file"]', path.resolve(dirname, './image.png'))
const filename = page.locator('.file-field__filename')
await expect(filename).toHaveValue('image.png')
await saveDocAndAssert(page)
// Update alt text
await page.locator('#field-alt').fill('updated text')
// Save again
await saveDocAndAssert(page)
})
})