Skip to content
Open
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: 126 additions & 0 deletions frontend/e2e/tests/identities-test.pw.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
import type { Page } from '@playwright/test'

@cubic-dev-ai cubic-dev-ai Bot Nov 18, 2026 •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P3: These tests omit the required # Given, # When, and # Then sections. Add those sections to each test body to make setup, actions, and outcomes explicit.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At frontend/e2e/tests/identities-test.pw.ts, line 40:

<comment>These tests omit the required `# Given`, `# When`, and `# Then` sections. Add those sections to each test body to make setup, actions, and outcomes explicit.</comment>

<file context>
@@ -0,0 +1,126 @@
+  }
+}
+
+test.describe('Identities', () => {
+  test('Identities can be created, searched and deleted @oss', async ({
+    page,
</file context>
Fix with cubic

import { test, expect } from '../test-setup'
import { createHelpers, log, LONG_TIMEOUT } from '../helpers'
import { E2E_USER, PASSWORD } from '../config'

// Each test gets its own project, so the identities it creates are the only
// ones on the page.
const uniqueName = (name: string) => `${name} ${Date.now()}`

const setUp = async (page: Page, projectName: string) => {
const helpers = createHelpers(page)
log('Login as admin')
await helpers.login(E2E_USER, PASSWORD)
await helpers.createProject(projectName)
return helpers
}

const gotoIdentities = async (helpers: ReturnType<typeof createHelpers>) => {
await helpers.click('#features-link')
await helpers.click('#users-link')
}

const identityLink = (page: Page, identifier: string) =>
page.getByRole('link', { exact: true, name: identifier })

const createIdentities = async (page: Page, identifiers: string[]) => {
await page.getByRole('button', { name: 'Create Identities' }).click()
const input = page.getByPlaceholder('User1, User2, User3')
// The placeholder goes once a chip exists, so press Enter on the focused input.
await input.fill(identifiers.join(','))
await page.keyboard.press('Enter')
await page.getByRole('button', { name: 'Create users' }).click()
for (const identifier of identifiers) {
await expect(identityLink(page, identifier)).toBeVisible({
timeout: LONG_TIMEOUT,
})
}
}

test.describe('Identities', () => {
test('Identities can be created, searched and deleted @oss', async ({
page,
}) => {
const helpers = await setUp(page, uniqueName('Identities List'))
await gotoIdentities(helpers)

log('Create two identities')
await createIdentities(page, ['alice_e2e', 'bob_e2e'])

log('Search finds one and hides the other')
await page.getByPlaceholder('Search').fill('alice_e2e')
await expect(identityLink(page, 'alice_e2e')).toBeVisible({
timeout: LONG_TIMEOUT,
})
await expect(identityLink(page, 'bob_e2e')).toBeHidden()

log('Loading the page directly shows the identities')
await page.goto(page.url())
await expect(identityLink(page, 'bob_e2e')).toBeVisible({
timeout: LONG_TIMEOUT,
})

log('Delete one')
await page.getByRole('button', { name: 'Delete identity bob_e2e' }).click()
await page.getByRole('button', { exact: true, name: 'Confirm' }).click()
await expect(identityLink(page, 'bob_e2e')).toBeHidden({
timeout: LONG_TIMEOUT,
})
await expect(identityLink(page, 'alice_e2e')).toBeVisible()
})

test('An identity page loads directly and its traits can be added and removed @oss', async ({
page,
}) => {
const helpers = await setUp(page, uniqueName('Identity Traits'))
await gotoIdentities(helpers)
await createIdentities(page, ['carol_e2e'])

log('Open the identity')
await identityLink(page, 'carol_e2e').click()
await expect(
page.getByRole('button', { name: 'Add new trait' }).first(),
).toBeVisible({ timeout: LONG_TIMEOUT })

log('Loading the identity page directly shows it')
await page.goto(page.url())
await expect(page.getByText('carol_e2e').first()).toBeVisible({
timeout: LONG_TIMEOUT,
})
await expect(
page.getByRole('button', { name: 'Add new trait' }).first(),
).toBeVisible({ timeout: LONG_TIMEOUT })

log('Add a trait, then remove it')
await helpers.createTrait('plan', 'pro')
await helpers.deleteTrait('plan')
})

test('A flag can be overridden for an identity and reset @oss', async ({
page,
}) => {
const helpers = await setUp(page, uniqueName('Identity Overrides'))
await helpers.createFeature({ name: 'identity_flag' })
await gotoIdentities(helpers)
await createIdentities(page, ['dave_e2e'])
await identityLink(page, 'dave_e2e').click()

log('The flag starts off, as in the environment')
await helpers.waitForUserFeatureSwitch('identity_flag', 'off')

@cubic-dev-ai cubic-dev-ai Bot Nov 18, 2026 •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: This only confirms the effective value is off; an off-valued identity override would pass while still overriding the environment. Also assert that the override description or Reset control disappears after reset.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At frontend/e2e/tests/identities-test.pw.ts, line 109:

<comment>This only confirms the effective value is off; an off-valued identity override would pass while still overriding the environment. Also assert that the override description or Reset control disappears after reset.</comment>

<file context>
@@ -0,0 +1,126 @@
+    await identityLink(page, 'dave_e2e').click()
+
+    log('The flag starts off, as in the environment')
+    await helpers.waitForUserFeatureSwitch('identity_flag', 'off')
+
+    log('Turn it on for this identity only')
</file context>
Fix with cubic


log('Turn it on for this identity only')
await helpers.clickUserFeatureSwitch('identity_flag', 'off')
await page.locator('#confirm-toggle-feature-btn').click()
await helpers.waitForUserFeatureSwitch('identity_flag', 'on')
await expect(
page.getByText('This feature is being overridden for this identity'),
).toBeVisible({ timeout: LONG_TIMEOUT })

log('Reset it to the environment value')
await page.getByRole('button', { name: 'Reset' }).first().click()
const confirm = page.locator('#confirm-remove-feature-modal')
await confirm.getByRole('textbox').fill('identity_flag')
await confirm.getByRole('button', { name: 'Confirm' }).click()
await helpers.waitForUserFeatureSwitch('identity_flag', 'off')

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Trivial · Maintainability & Code Quality · Quick win

Also check that reset removes the override.

The final assertion also passes if reset leaves a disabled identity override. The override description depends on override ownership, not the enabled value. (raw.githubusercontent.com)

After the switch becomes off, assert that This feature is being overridden for this identity is hidden. This strengthens the reset coverage before the migration.

})
})
Loading