Merge remote-tracking branch 'origin/develop' into biome

This commit is contained in:
Henry Jameson 2026-01-08 16:48:27 +02:00
commit 851c100a24
15 changed files with 576 additions and 65 deletions

View file

@ -0,0 +1,50 @@
/* global process */
import { defineConfig, devices } from 'playwright/test'
const baseURL = process.env.E2E_BASE_URL || 'http://localhost:8080'
export default defineConfig({
testDir: './specs',
// Paths are resolved relative to this config file directory.
outputDir: 'test-results',
timeout: 60_000,
expect: {
timeout: 10_000,
},
retries: process.env.CI ? 1 : 0,
reporter: process.env.CI
? [['line'], ['html', { outputFolder: 'playwright-report', open: 'never' }]]
: [
['list'],
['html', { outputFolder: 'playwright-report', open: 'never' }],
],
use: {
baseURL,
screenshot: 'only-on-failure',
trace: 'on-first-retry',
video: 'retain-on-failure',
},
webServer: {
command: 'yarn dev -- --host 0.0.0.0 --port 8080 --strictPort',
url: baseURL,
reuseExistingServer: !process.env.CI,
timeout: 120_000,
env: {
...process.env,
VITE_PROXY_TARGET:
process.env.VITE_PROXY_TARGET || 'http://localhost:4000',
VITE_PROXY_ORIGIN:
process.env.VITE_PROXY_ORIGIN ||
process.env.VITE_PROXY_TARGET ||
'http://localhost:4000',
},
},
projects: [
{
name: 'firefox',
use: {
...devices['Desktop Firefox'],
},
},
],
})

View file

@ -0,0 +1,27 @@
/* global process */
import { expect, test } from 'playwright/test'
const adminUsername = process.env.E2E_ADMIN_USERNAME || 'admin'
const adminPassword = process.env.E2E_ADMIN_PASSWORD || 'adminadmin'
test('admin can open the admin settings modal', async ({ page }) => {
await page.goto('/login')
const loginForm = page.locator('#main-scroller form.login-form')
await loginForm.locator('#username').fill(adminUsername)
await loginForm.locator('#password').fill(adminPassword)
await loginForm.getByRole('button', { name: 'Log in' }).click()
await page.waitForURL(/\/main\/friends/)
await expect(page.getByTitle('Administration')).toBeVisible()
await page.getByTitle('Administration').click()
const modal = page.locator('.settings-modal-panel')
await expect(
modal.getByRole('heading', { name: 'Administration' }),
).toBeVisible()
await modal.getByRole('tab', { name: 'Emoji' }).click()
await expect(modal.getByText('Emoji packs')).toBeVisible()
})

View file

@ -0,0 +1,90 @@
import { randomUUID } from 'node:crypto'
import { expect, test } from 'playwright/test'
const createTestUser = () => {
const id = randomUUID().slice(0, 8)
return {
username: `e2e_${id}`,
fullname: `E2E ${id}`,
email: `e2e_${id}@example.com`,
password: 'e2e-password',
}
}
const register = async (page, user) => {
await page.goto('/registration')
const registrationForm = page.locator('#main-scroller form.registration-form')
await registrationForm.locator('#sign-up-username').fill(user.username)
await registrationForm.locator('#sign-up-fullname').fill(user.fullname)
await registrationForm.locator('#email').fill(user.email)
await registrationForm.locator('#sign-up-password').fill(user.password)
await registrationForm
.locator('#sign-up-password-confirmation')
.fill(user.password)
await Promise.all([
page.waitForURL(/\/main\/friends/),
registrationForm.getByRole('button', { name: 'Register' }).click(),
])
}
const logout = async (page) => {
await page.getByTitle('Log out').click()
const confirmLogout = page.getByRole('button', {
name: 'Logout',
exact: true,
})
if (await confirmLogout.isVisible()) {
await Promise.all([
page.waitForURL(/\/main\/(public|all)/),
confirmLogout.click(),
])
} else {
await page.waitForURL(/\/main\/(public|all)/)
}
await expect(page.locator('#sidebar form.login-form')).toBeVisible()
}
const login = async (page, user) => {
await page.goto('/login')
const loginForm = page.locator('#main-scroller form.login-form')
await loginForm.locator('#username').fill(user.username)
await loginForm.locator('#password').fill(user.password)
await loginForm.getByRole('button', { name: 'Log in' }).click()
await page.waitForURL(/\/main\/friends/)
}
test('user can register, log out, and log back in', async ({ page }) => {
const user = createTestUser()
await register(page, user)
await expect(page.getByTitle('Log out')).toBeVisible()
await logout(page)
await login(page, user)
await expect(page.getByTitle('Log out')).toBeVisible()
})
test('user can post a status', async ({ page }) => {
const user = createTestUser()
await register(page, user)
const statusText = `Hello from ${user.username} (${randomUUID().slice(0, 8)})`
const composer = page.locator('#sidebar .user-panel .post-status-form')
await composer.locator('textarea.form-post-body').fill(statusText)
await Promise.all([
page.waitForResponse(
(resp) =>
resp.request().method() === 'POST' &&
resp.url().includes('/api/v1/statuses') &&
resp.ok(),
),
composer.getByRole('button', { name: 'Post', exact: true }).click(),
])
await page.goto(`/users/${user.username}`)
await expect(page.getByText(statusText)).toBeVisible()
})