Merge claude/login-page-whitelabel-616f3d: the panel's sign-in look (whiteLabel.signIn), the client's logo, hardened brand image fetch

Conflicts kept both sides: the 2FA texts (twoFactorBusy from A, twoFactorCodeDigit here), the reference index rows,
and the e2e:built line (closed doors from C and the sign-in look here). routes.snapshot.json judges the new public
GET /api/ipal/admin-language.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
Radosław Smoliński
2026-11-26 22:04:30 +01:00
co-authored by Claude Opus 5.5
126 changed files with 2283 additions and 46 deletions
+1
View File
@@ -77,6 +77,7 @@
"GET /api/globals/site-settings/versions": "versions: readVersions = read (anyone (brand, homepage, construction mode)); no version history kept here",
"GET /api/globals/site-settings/versions/:id": "versionByID: readVersions = read (anyone (brand, homepage, construction mode)); no version history kept here",
"GET /api/iapl/mail-relay/status": "mail service status in the panel: admin",
"GET /api/ipal/admin-language": "public by design: the sign-in panel's language links (whiteLabel.signIn); writes Payload's payload-lng cookie for a supported language and 303s to a path inside the admin route; 400 otherwise",
"GET /api/ipal/admin-icon": "public by design: the panel's favicon (white-label)",
"GET /api/ipal/admin-og": "public by design: the panel's link-preview image",
"GET /api/ipal/cookie-approval": "cookie approval list: editor+ with the second factor (cookieScanner.access)",
+146
View File
@@ -0,0 +1,146 @@
import { expect, type Page, test } from '@playwright/test'
/**
* The sign-in look (whiteLabel.signIn, white-label.md): the dark panel with the site's name or logo beside the
* form, on every sign-in screen (this site sets `allScreens`), in the page's first HTML, on a phone above the
* form, with working language links; and the 2FA code screen behind it, unchanged in what it does.
* No 2FA code is entered here: the account's verify attempts are left for the other specs.
* E2E_BASE_URL=http://localhost:3310 pnpm exec playwright test e2e/sign-in-look.spec.ts
*/
const { E2E_ADMIN_EMAIL: email, E2E_ADMIN_PASSWORD: password } = process.env
const PHONE = { height: 844, width: 390 }
const panel = (page: Page) => page.locator('.iapl-signin')
const box = async (page: Page, selector: string) => {
const b = await page.locator(selector).first().boundingBox()
if (!b) {throw new Error(`${selector} is not on the page`)}
return b
}
/** Nothing is wider than the window: no sideways scroll. */
const noSidewaysScroll = async (page: Page) => expect(await page.evaluate(() => document.documentElement.scrollWidth <= window.innerWidth)).toBe(true)
test('sign-in look — login: the look comes with the form (no flash of the plain screen), one panel, the form beside it', async ({ page, request }) => {
// the stylesheet and the panel are in the page's own response: no second request brings the look
const html = await (await request.get('/admin/login')).text()
expect(html).toContain('iapl-sign-in')
expect(html).toContain('iapl-signin__label')
const errors: string[] = []
page.on('console', (m) => m.type() === 'error' && errors.push(m.text()))
// Payload draws its screens in the browser. Whenever the form's template is in the page, the panel and its
// stylesheet must be there too — checked after every change of the page, before the browser paints it.
await page.addInitScript(() => {
const seen = { plain: 0, styled: 0 }
;(window as unknown as { iaplLook: typeof seen }).iaplLook = seen
new MutationObserver(() => {
if (!document.querySelector('.template-minimal')) {return}
const styled = document.querySelector('.iapl-signin') && document.querySelector('style[data-href="iapl-sign-in"]')
seen[styled ? 'styled' : 'plain'] += 1
}).observe(document, { childList: true, subtree: true })
})
await page.goto('/admin/login')
await page.locator('#field-email').waitFor()
const seen = await page.evaluate(() => (window as unknown as { iaplLook: { plain: number; styled: number } }).iaplLook)
expect(seen.plain).toBe(0)
expect(seen.styled).toBeGreaterThan(0)
await expect(panel(page)).toHaveCount(1)
await expect(panel(page)).toBeVisible()
await expect(panel(page).locator('.iapl-signin__label')).toHaveText(/Administration panel|Panel administracyjny/)
// the site's name (no logo in the seed) is a link to the site; nothing else on the panel leaves the admin
await expect(panel(page).locator('.iapl-signin__brand')).toHaveText('Example Studio')
await expect(panel(page).locator('.iapl-signin__brand')).toHaveAttribute('href', '/')
const p = await box(page, '.iapl-signin')
const form = await box(page, '#field-email')
expect(p.x + p.width).toBeLessThanOrEqual(form.x)
expect(p.height).toBeGreaterThan(600)
await noSidewaysScroll(page)
// the button carries the accent, the fields their labels
await expect(page.locator('.form-submit button')).toHaveCSS('background-color', 'rgb(0, 112, 192)')
await expect(page.getByLabel(/^(Email|E-mail)/)).toBeVisible()
expect(errors).toEqual([])
})
test('sign-in look — login on a phone: the panel is a band above the form, in both themes', async ({ baseURL, browser }) => {
for (const theme of ['light', 'dark'] as const) {
const context = await browser.newContext({ baseURL, viewport: PHONE })
await context.addCookies([{ name: 'payload-theme', url: baseURL!, value: theme }])
const page = await context.newPage()
await page.goto('/admin/login')
const p = await box(page, '.iapl-signin')
const form = await box(page, '#field-email')
expect(p.y).toBe(0)
expect(Math.round(p.width)).toBe(PHONE.width)
expect(p.y + p.height).toBeLessThanOrEqual(form.y)
await noSidewaysScroll(page)
await expect(page.locator('html')).toHaveAttribute('data-theme', theme)
// the page behind the form follows the theme; the panel is dark in both
const bg = await page.locator('.template-minimal').evaluate((el) => getComputedStyle(el).backgroundColor)
expect(bg === 'rgb(255, 255, 255)').toBe(theme === 'light')
await expect(panel(page)).toHaveCSS('background-color', 'rgb(6, 6, 6)')
await context.close()
}
})
test('sign-in look — the other sign-in screens carry the same panel; the rest of the admin does not show it', async ({ page }) => {
for (const path of ['/admin/forgot', '/admin/reset/not-a-real-token', '/admin/logout']) {
await page.goto(path)
await page.waitForLoadState('networkidle')
await expect(panel(page), path).toHaveCount(1)
await expect(panel(page), path).toBeVisible()
await noSidewaysScroll(page)
}
await page.goto('/admin/forgot')
const p = await box(page, '.iapl-signin')
const form = await box(page, '#field-email')
expect(p.x + p.width).toBeLessThanOrEqual(form.x)
})
test('sign-in look — language links: one click changes the panel\'s language and comes back to the same screen', async ({ baseURL, browser, request }) => {
const context = await browser.newContext({ baseURL, locale: 'en-US' })
const page = await context.newPage()
await page.goto('/admin/forgot')
await expect(panel(page).locator('.iapl-signin__label')).toHaveText('Administration panel')
await expect(panel(page).locator('[aria-current="true"]')).toHaveText('English')
// a plain link: the endpoint sets the cookie and redirects, no script of the page takes part
await expect(panel(page).getByRole('link', { name: 'Polski' })).toHaveAttribute('href', '/api/ipal/admin-language?lng=pl')
await panel(page).getByRole('link', { name: 'Polski' }).click()
await expect(page).toHaveURL(/\/admin\/forgot$/)
await expect(panel(page).locator('.iapl-signin__label')).toHaveText('Panel administracyjny')
await expect(panel(page).locator('[aria-current="true"]')).toHaveText('Polski')
await expect(page.locator('html')).toHaveAttribute('lang', 'pl')
await context.close()
// the endpoint writes a supported language only, and never sends the browser off the admin
const unknown = await request.get('/api/ipal/admin-language?lng=xx', { maxRedirects: 0 })
expect(unknown.status()).toBe(400)
expect(unknown.headers()['set-cookie']).toBeUndefined()
const away = await request.get('/api/ipal/admin-language?lng=pl', { headers: { referer: 'https://evil.example/phish' }, maxRedirects: 0 })
expect(away.status()).toBe(303)
expect(away.headers().location).toBe('/admin')
expect(away.headers()['set-cookie']).toMatch(/^payload-lng=pl; Path=\/; Max-Age=31536000; SameSite=Lax/)
})
test('sign-in look — the 2FA code screen: the panel beside it, the code boxes named, the brand without a media request', async ({ page }) => {
test.skip(!email || !password, 'E2E_* test admin not configured')
const media: string[] = []
page.on('request', (r) => r.url().includes('/api/media/') && media.push(r.url()))
await page.goto('/admin/login')
await page.fill('#field-email', email!)
await page.fill('#field-password', password!)
await page.click('.form-submit button')
await page.waitForURL(/verify-totp/)
await expect(panel(page)).toHaveCount(1)
await expect(panel(page)).toBeVisible()
const p = await box(page, '.iapl-signin')
const first = await box(page, '.template-minimal form input[type="text"]')
expect(p.x + p.width).toBeLessThanOrEqual(first.x)
// six boxes, each with a name a screen reader can say, the first one focused as before
const boxes = page.getByRole('textbox')
await expect(boxes).toHaveCount(6)
await expect(boxes.first()).toHaveAttribute('aria-label', /^(Digit 1 of 6|Cyfra 1 z 6)$/)
await expect(boxes.nth(5)).toHaveAttribute('aria-label', /^(Digit 6 of 6|Cyfra 6 z 6)$/)
await expect(boxes.first()).toBeFocused()
// a session that owes its code is refused `media`: the page asks for none
expect(media).toEqual([])
await noSidewaysScroll(page)
})
+2
View File
@@ -512,6 +512,8 @@ test('admin: sign in through 2FA, agency credit, panel link preview', async ({ p
}
await expect(page).toHaveTitle(/Dashboard|Pulpit/, { timeout: 20_000 })
await expect(page.getByText(/Intecion/).first()).toBeVisible()
// the sign-in panel belongs to the sign-in screens: inside the panel it is not shown
await expect(page.locator('.iapl-signin')).toBeHidden()
})
// 2FA covers what the plugin adds, over the API too (REST and GraphQL): a correct password without the code