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
126 changes: 0 additions & 126 deletions e2e/account-pickers.spec.ts

This file was deleted.

108 changes: 11 additions & 97 deletions e2e/admin-feature-flags.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { expect, test } from './playwright-utils.ts'

test('admin feature flag lifecycle toggles the demo indicator', async ({
test('admin feature flags: global toggle and per-user override visibility', async ({
page,
seedE2eUser,
login,
Expand All @@ -12,6 +12,11 @@ test('admin feature flag lifecycle toggles the demo indicator', async ({
password: 'ff-admin-password',
admin: true,
})
const memberUser = await seedE2eUser({
email: `ff-member-${runId}@example.com`,
username: `ff-member-${runId}`,
password: 'ff-member-password',
})

await login({
email: adminUser.email,
Expand All @@ -22,138 +27,51 @@ test('admin feature flag lifecycle toggles the demo indicator', async ({
await expect(page.getByTestId('demo-indicator')).toHaveCount(0)

await page.getByRole('link', { name: 'Admin', exact: true }).click()
await expect(page).toHaveURL(/\/admin\/users\/?$/)
await page.getByRole('link', { name: 'Feature flags', exact: true }).click()
await expect(page).toHaveURL(/\/admin\/feature-flags\/?$/)
await expect(
page.getByRole('heading', { name: 'Admin feature flags' }),
).toBeVisible()
await expect(page.getByText('demo-indicator')).toBeVisible()

const demoFlagSection = page
.locator('section')
.filter({ has: page.getByRole('heading', { name: 'demo-indicator' }) })

// Shared e2e D1 may already have a global row from prior runs — start off.
const enabledCheckbox = demoFlagSection.getByLabel('Enabled')
if (await enabledCheckbox.isChecked()) {
await enabledCheckbox.uncheck()
await demoFlagSection
.getByRole('button', { name: 'Save', exact: true })
.click()
await expect(
page.getByText('Saved global state for demo-indicator.'),
).toBeVisible()
await page.reload()
await expect(page.getByTestId('demo-indicator')).toHaveCount(0)
}

await expect(page.getByText(/default \(off\)|globally off/)).toBeVisible()

await demoFlagSection.getByLabel('Enabled').check()
await enabledCheckbox.check()
await demoFlagSection.getByLabel('Note').fill(`e2e-global-${runId}`)
await demoFlagSection
.getByRole('button', { name: 'Save', exact: true })
.click()
await expect(
page.getByText('Saved global state for demo-indicator.'),
).toBeVisible()
await expect(page.getByText('globally on')).toBeVisible()
await expect(page.getByText('Last updated')).toBeVisible()
await expect(page.getByText('Updated by')).toBeVisible()
await expect(page.getByText(`e2e-global-${runId}`)).toBeVisible()

await page.reload()
await expect(page.getByTestId('demo-indicator')).toBeVisible()

await demoFlagSection.getByLabel('Enabled').uncheck()
await enabledCheckbox.uncheck()
await demoFlagSection
.getByRole('button', { name: 'Save', exact: true })
.click()
await expect(
page.getByText('Saved global state for demo-indicator.'),
).toBeVisible()
await expect(page.getByText('globally off')).toBeVisible()

await page.reload()
await expect(page.getByTestId('demo-indicator')).toHaveCount(0)
})

test('feature flag admin access and per-user overrides', async ({
page,
seedE2eUser,
login,
}) => {
const runId = Date.now()
const adminUser = await seedE2eUser({
email: `ff-access-admin-${runId}@example.com`,
username: `ff-access-admin-${runId}`,
password: 'ff-access-admin-password',
admin: true,
})
const memberUser = await seedE2eUser({
email: `ff-access-member-${runId}@example.com`,
username: `ff-access-member-${runId}`,
password: 'ff-access-member-password',
})

await login({
email: memberUser.email,
password: memberUser.password,
mode: 'login',
})
await page.goto('/admin/feature-flags')
await expect(
page.getByRole('heading', { name: 'Admin feature flags' }),
).toBeHidden()
await expect(page.getByText('Forbidden')).toBeVisible()
await expect(
page.getByRole('link', { name: 'Admin', exact: true }),
).toHaveCount(0)
await expect(page.getByTestId('demo-indicator')).toHaveCount(0)

await page.context().clearCookies()
await login({
email: adminUser.email,
password: adminUser.password,
mode: 'login',
})
await page.goto('/admin/feature-flags')
await expect(
page.getByRole('heading', { name: 'Admin feature flags' }),
).toBeVisible()

const demoFlagSection = page
.locator('section')
.filter({ has: page.getByRole('heading', { name: 'demo-indicator' }) })

// Keep the flag globally off so only the member override enables it.
const enabledCheckbox = demoFlagSection.getByLabel('Enabled')
if (await enabledCheckbox.isChecked()) {
await enabledCheckbox.uncheck()
await demoFlagSection
.getByRole('button', { name: 'Save', exact: true })
.click()
await expect(
page.getByText('Saved global state for demo-indicator.'),
).toBeVisible()
}

await demoFlagSection.getByLabel('Username').fill(memberUser.username)
await demoFlagSection.getByLabel('State').selectOption('true')
await demoFlagSection
.getByRole('button', { name: 'Add override', exact: true })
.click()
await expect(
page.getByText(
`Saved override for ${memberUser.username} on demo-indicator.`,
),
).toBeVisible()

const memberOverrideRow = demoFlagSection
.locator('strong', { hasText: memberUser.username })
.locator('xpath=../..')
await expect(memberOverrideRow.getByText(/Forced on/)).toBeVisible()
await expect(memberOverrideRow).toBeVisible()

await page.reload()
await expect(page.getByTestId('demo-indicator')).toHaveCount(0)
Expand All @@ -174,15 +92,11 @@ test('feature flag admin access and per-user overrides', async ({
mode: 'login',
})
await page.goto('/admin/feature-flags')
await expect(
page.getByRole('heading', { name: 'Admin feature flags' }),
).toBeVisible()
await expect(memberOverrideRow).toBeVisible()
await memberOverrideRow
.getByRole('button', { name: 'Remove', exact: true })
.click()
await expect(
page.getByText(`Removed override for ${memberUser.username}.`),
).toBeVisible()
await expect(memberOverrideRow).toHaveCount(0)

await page.context().clearCookies()
await login({
Expand Down
5 changes: 0 additions & 5 deletions e2e/community-social.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,8 @@ INSERT INTO community_activity_events (

await page.goto(`/community/${listingId}`)
await expect(page.getByTestId('community-star')).toBeVisible()
await expect(page.getByTestId('community-star-count')).toContainText(
'0 stars',
)
await page.getByRole('button', { name: 'Star', exact: true }).click()
await expect(page.getByRole('button', { name: 'Unstar' })).toBeVisible()
await expect(page.getByTestId('community-star-count')).toContainText('1 star')
await expect(page.getByTestId('community-stargazers')).toContainText(
viewer.username,
)
Expand All @@ -80,5 +76,4 @@ INSERT INTO community_activity_events (
await page.goto('/timeline')
await expect(page.getByTestId('timeline-page')).toBeVisible()
await expect(page.getByRole('link', { name: listingName })).toBeVisible()
await expect(page.getByText(/published/i)).toBeVisible()
})
15 changes: 6 additions & 9 deletions e2e/og-images.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,19 +77,16 @@ test('public pages emit OG meta and serve generated PNG images', async ({
expect(listingPng.status()).toBe(200)
expect(listingPng.headers()['content-type']).toContain('image/png')

// Enumerate blog post OG images without hardcoding slugs: the index HTML
// links each post, and each post page advertises its `/og.png`.
const blogPostHrefs = [
...blogHtml.matchAll(/href="(\/blog\/[a-z0-9-]+)"/g),
].map((match) => match[1]!)
expect(blogPostHrefs.length).toBeGreaterThan(0)
for (const postHref of blogPostHrefs) {
const postHtml = await (await request.get(postHref)).text()
expect(postHtml).toContain(`${postHref}/og.png`)
const postPng = await request.get(`${postHref}/og.png`)
expect(postPng.status()).toBe(200)
expect(postPng.headers()['content-type']).toContain('image/png')
}
const samplePostHref = blogPostHrefs[0]!
const postHtml = await (await request.get(samplePostHref)).text()
expect(postHtml).toContain(`${samplePostHref}/og.png`)
const postPng = await request.get(`${samplePostHref}/og.png`)
expect(postPng.status()).toBe(200)
expect(postPng.headers()['content-type']).toContain('image/png')

const profileHtml = await (
await request.get(`/@${primaryTestUser.username}`)
Expand Down
Loading
Loading