Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
62 changes: 58 additions & 4 deletions e2e/tests/onboarding-form.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,19 @@

async function openOnboarding(
browser: Browser,
opts: { source?: boolean; account: AccountState; delayMs?: number },
opts: {
source?: boolean;
account: AccountState;
delayMs?: number;
edition?: string;
expectOnboarding?: boolean;
},
): Promise<{ page: Page; close: () => Promise<void> }> {
const context = await browser.newContext({
storageState: "e2e/fixtures/auth/owner.json",
});
await context.addInitScript(
([sourceKey, sourceValue, withSource]) => {
([sourceKey, sourceValue, withSource, edition]) => {
try {
window.localStorage.setItem("netbird-test-onboarding", "true");
if (withSource) {
Expand All @@ -87,13 +93,23 @@
sourceValue as string,
);
}
if (edition) {
window.localStorage.setItem("netbird-test-edition", edition as string);
}
} catch (e) {}
},
[SIGNUP_SOURCE_KEY, AGENT_NETWORK_SOURCE, !!opts.source] as const,
[
SIGNUP_SOURCE_KEY,
AGENT_NETWORK_SOURCE,
!!opts.source,
opts.edition ?? "",
] as const,
);
const page = await context.newPage();
mockAccounts(page, opts.account, opts.delayMs ?? 0);
await loginToApp(page, "owner", { expectOnboarding: true });
await loginToApp(page, "owner", {
expectOnboarding: opts.expectOnboarding ?? true,
});
Comment thread
coderabbitai[bot] marked this conversation as resolved.
return { page, close: () => context.close() };
}

Expand Down Expand Up @@ -143,6 +159,44 @@
}
});

test("a self-hosted account with onboarding pending shows the regular flow at the intent step", async ({
browser,
}) => {
const { page, close } = await openOnboarding(browser, {
source: false,
edition: "oss",
account: { onboardingFlowPending: true },
});
try {
await expect(page.getByTestId(REGULAR_FORM)).toBeVisible();
await expect(page.getByTestId(AGENT_FORM)).toHaveCount(0);
// The signup survey relies on a JWT domain claim self-hosted IdPs don't
// emit, so the flow skips it and opens on the intent step.
await expect(page.getByText("Get started with NetBird")).toBeVisible();

Check failure on line 175 in e2e/tests/onboarding-form.spec.ts

View workflow job for this annotation

GitHub Actions / playwright-run

[e2e] › e2e/tests/onboarding-form.spec.ts:162:7 › Onboarding form selection @onboarding › a self-hosted account with onboarding pending shows the regular flow at the intent step

1) [e2e] › e2e/tests/onboarding-form.spec.ts:162:7 › Onboarding form selection @onboarding › a self-hosted account with onboarding pending shows the regular flow at the intent step Retry #1 ─────────────────────────────────────────────────────────────────────────────────────── Error: expect(locator).toBeVisible() failed Locator: getByText('Get started with NetBird') Expected: visible Error: strict mode violation: getByText('Get started with NetBird') resolved to 2 elements: 1) <h1 class="text-3xl font-medium max-w-lg mx-auto mt-3">Get Started with NetBird</h1> aka getByText('Get Started with NetBird', { exact: true }) 2) <h1 class="text-xl text-center">Get started with NetBird</h1> aka getByRole('heading', { name: 'Get started with NetBird' }) Call log: - Expect "toBeVisible" with timeout 5000ms - waiting for getByText('Get started with NetBird') 173 | // The signup survey relies on a JWT domain claim self-hosted IdPs don't 174 | // emit, so the flow skips it and opens on the intent step. > 175 | await expect(page.getByText("Get started with NetBird")).toBeVisible(); | ^ 176 | } finally { 177 | await close(); 178 | } at /home/runner/work/dashboard/dashboard/e2e/tests/onboarding-form.spec.ts:175:64

Check failure on line 175 in e2e/tests/onboarding-form.spec.ts

View workflow job for this annotation

GitHub Actions / playwright-run

[e2e] › e2e/tests/onboarding-form.spec.ts:162:7 › Onboarding form selection @onboarding › a self-hosted account with onboarding pending shows the regular flow at the intent step

1) [e2e] › e2e/tests/onboarding-form.spec.ts:162:7 › Onboarding form selection @onboarding › a self-hosted account with onboarding pending shows the regular flow at the intent step Error: expect(locator).toBeVisible() failed Locator: getByText('Get started with NetBird') Expected: visible Error: strict mode violation: getByText('Get started with NetBird') resolved to 2 elements: 1) <h1 class="text-3xl font-medium max-w-lg mx-auto mt-3">Get Started with NetBird</h1> aka getByText('Get Started with NetBird', { exact: true }) 2) <h1 class="text-xl text-center">Get started with NetBird</h1> aka getByRole('heading', { name: 'Get started with NetBird' }) Call log: - Expect "toBeVisible" with timeout 5000ms - waiting for getByText('Get started with NetBird') 173 | // The signup survey relies on a JWT domain claim self-hosted IdPs don't 174 | // emit, so the flow skips it and opens on the intent step. > 175 | await expect(page.getByText("Get started with NetBird")).toBeVisible(); | ^ 176 | } finally { 177 | await close(); 178 | } at /home/runner/work/dashboard/dashboard/e2e/tests/onboarding-form.spec.ts:175:64

Check failure on line 175 in e2e/tests/onboarding-form.spec.ts

View workflow job for this annotation

GitHub Actions / playwright-run

[e2e] › e2e/tests/onboarding-form.spec.ts:162:7 › Onboarding form selection @onboarding › a self-hosted account with onboarding pending shows the regular flow at the intent step

1) [e2e] › e2e/tests/onboarding-form.spec.ts:162:7 › Onboarding form selection @onboarding › a self-hosted account with onboarding pending shows the regular flow at the intent step Retry #1 ─────────────────────────────────────────────────────────────────────────────────────── Error: expect(locator).toBeVisible() failed Locator: getByText('Get started with NetBird') Expected: visible Error: strict mode violation: getByText('Get started with NetBird') resolved to 2 elements: 1) <h1 class="text-3xl font-medium max-w-lg mx-auto mt-3">Get Started with NetBird</h1> aka getByText('Get Started with NetBird', { exact: true }) 2) <h1 class="text-xl text-center">Get started with NetBird</h1> aka getByRole('heading', { name: 'Get started with NetBird' }) Call log: - Expect "toBeVisible" with timeout 5000ms - waiting for getByText('Get started with NetBird') 173 | // The signup survey relies on a JWT domain claim self-hosted IdPs don't 174 | // emit, so the flow skips it and opens on the intent step. > 175 | await expect(page.getByText("Get started with NetBird")).toBeVisible(); | ^ 176 | } finally { 177 | await close(); 178 | } at /home/runner/work/dashboard/dashboard/e2e/tests/onboarding-form.spec.ts:175:64

Check failure on line 175 in e2e/tests/onboarding-form.spec.ts

View workflow job for this annotation

GitHub Actions / playwright-run

[e2e] › e2e/tests/onboarding-form.spec.ts:162:7 › Onboarding form selection @onboarding › a self-hosted account with onboarding pending shows the regular flow at the intent step

1) [e2e] › e2e/tests/onboarding-form.spec.ts:162:7 › Onboarding form selection @onboarding › a self-hosted account with onboarding pending shows the regular flow at the intent step Error: expect(locator).toBeVisible() failed Locator: getByText('Get started with NetBird') Expected: visible Error: strict mode violation: getByText('Get started with NetBird') resolved to 2 elements: 1) <h1 class="text-3xl font-medium max-w-lg mx-auto mt-3">Get Started with NetBird</h1> aka getByText('Get Started with NetBird', { exact: true }) 2) <h1 class="text-xl text-center">Get started with NetBird</h1> aka getByRole('heading', { name: 'Get started with NetBird' }) Call log: - Expect "toBeVisible" with timeout 5000ms - waiting for getByText('Get started with NetBird') 173 | // The signup survey relies on a JWT domain claim self-hosted IdPs don't 174 | // emit, so the flow skips it and opens on the intent step. > 175 | await expect(page.getByText("Get started with NetBird")).toBeVisible(); | ^ 176 | } finally { 177 | await close(); 178 | } at /home/runner/work/dashboard/dashboard/e2e/tests/onboarding-form.spec.ts:175:64

Check failure on line 175 in e2e/tests/onboarding-form.spec.ts

View workflow job for this annotation

GitHub Actions / playwright-run

[e2e] › e2e/tests/onboarding-form.spec.ts:162:7 › Onboarding form selection @onboarding › a self-hosted account with onboarding pending shows the regular flow at the intent step

1) [e2e] › e2e/tests/onboarding-form.spec.ts:162:7 › Onboarding form selection @onboarding › a self-hosted account with onboarding pending shows the regular flow at the intent step Retry #1 ─────────────────────────────────────────────────────────────────────────────────────── Error: expect(locator).toBeVisible() failed Locator: getByText('Get started with NetBird') Expected: visible Error: strict mode violation: getByText('Get started with NetBird') resolved to 2 elements: 1) <h1 class="text-3xl font-medium max-w-lg mx-auto mt-3">Get Started with NetBird</h1> aka getByText('Get Started with NetBird', { exact: true }) 2) <h1 class="text-xl text-center">Get started with NetBird</h1> aka getByTestId('regular-onboarding').getByText('Get started with NetBird') Call log: - Expect "toBeVisible" with timeout 5000ms - waiting for getByText('Get started with NetBird') 173 | // The signup survey relies on a JWT domain claim self-hosted IdPs don't 174 | // emit, so the flow skips it and opens on the intent step. > 175 | await expect(page.getByText("Get started with NetBird")).toBeVisible(); | ^ 176 | } finally { 177 | await close(); 178 | } at /home/runner/work/dashboard/dashboard/e2e/tests/onboarding-form.spec.ts:175:64

Check failure on line 175 in e2e/tests/onboarding-form.spec.ts

View workflow job for this annotation

GitHub Actions / playwright-run

[e2e] › e2e/tests/onboarding-form.spec.ts:162:7 › Onboarding form selection @onboarding › a self-hosted account with onboarding pending shows the regular flow at the intent step

1) [e2e] › e2e/tests/onboarding-form.spec.ts:162:7 › Onboarding form selection @onboarding › a self-hosted account with onboarding pending shows the regular flow at the intent step Error: expect(locator).toBeVisible() failed Locator: getByText('Get started with NetBird') Expected: visible Error: strict mode violation: getByText('Get started with NetBird') resolved to 2 elements: 1) <h1 class="text-3xl font-medium max-w-lg mx-auto mt-3">Get Started with NetBird</h1> aka getByText('Get Started with NetBird', { exact: true }) 2) <h1 class="text-xl text-center">Get started with NetBird</h1> aka getByRole('heading', { name: 'Get started with NetBird' }) Call log: - Expect "toBeVisible" with timeout 5000ms - waiting for getByText('Get started with NetBird') 173 | // The signup survey relies on a JWT domain claim self-hosted IdPs don't 174 | // emit, so the flow skips it and opens on the intent step. > 175 | await expect(page.getByText("Get started with NetBird")).toBeVisible(); | ^ 176 | } finally { 177 | await close(); 178 | } at /home/runner/work/dashboard/dashboard/e2e/tests/onboarding-form.spec.ts:175:64

Check failure on line 175 in e2e/tests/onboarding-form.spec.ts

View workflow job for this annotation

GitHub Actions / playwright-run

[e2e] › e2e/tests/onboarding-form.spec.ts:162:7 › Onboarding form selection @onboarding › a self-hosted account with onboarding pending shows the regular flow at the intent step

1) [e2e] › e2e/tests/onboarding-form.spec.ts:162:7 › Onboarding form selection @onboarding › a self-hosted account with onboarding pending shows the regular flow at the intent step Retry #1 ─────────────────────────────────────────────────────────────────────────────────────── Error: expect(locator).toBeVisible() failed Locator: getByText('Get started with NetBird') Expected: visible Error: strict mode violation: getByText('Get started with NetBird') resolved to 2 elements: 1) <h1 class="text-3xl font-medium max-w-lg mx-auto mt-3">Get Started with NetBird</h1> aka getByText('Get Started with NetBird', { exact: true }) 2) <h1 class="text-xl text-center">Get started with NetBird</h1> aka getByTestId('regular-onboarding').getByText('Get started with NetBird') Call log: - Expect "toBeVisible" with timeout 5000ms - waiting for getByText('Get started with NetBird') 173 | // The signup survey relies on a JWT domain claim self-hosted IdPs don't 174 | // emit, so the flow skips it and opens on the intent step. > 175 | await expect(page.getByText("Get started with NetBird")).toBeVisible(); | ^ 176 | } finally { 177 | await close(); 178 | } at /home/runner/work/dashboard/dashboard/e2e/tests/onboarding-form.spec.ts:175:64

Check failure on line 175 in e2e/tests/onboarding-form.spec.ts

View workflow job for this annotation

GitHub Actions / playwright-run

[e2e] › e2e/tests/onboarding-form.spec.ts:162:7 › Onboarding form selection @onboarding › a self-hosted account with onboarding pending shows the regular flow at the intent step

1) [e2e] › e2e/tests/onboarding-form.spec.ts:162:7 › Onboarding form selection @onboarding › a self-hosted account with onboarding pending shows the regular flow at the intent step Error: expect(locator).toBeVisible() failed Locator: getByText('Get started with NetBird') Expected: visible Error: strict mode violation: getByText('Get started with NetBird') resolved to 2 elements: 1) <h1 class="text-3xl font-medium max-w-lg mx-auto mt-3">Get Started with NetBird</h1> aka getByText('Get Started with NetBird', { exact: true }) 2) <h1 class="text-xl text-center">Get started with NetBird</h1> aka getByRole('heading', { name: 'Get started with NetBird' }) Call log: - Expect "toBeVisible" with timeout 5000ms - waiting for getByText('Get started with NetBird') 173 | // The signup survey relies on a JWT domain claim self-hosted IdPs don't 174 | // emit, so the flow skips it and opens on the intent step. > 175 | await expect(page.getByText("Get started with NetBird")).toBeVisible(); | ^ 176 | } finally { 177 | await close(); 178 | } at /home/runner/work/dashboard/dashboard/e2e/tests/onboarding-form.spec.ts:175:64

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf '--- target spec around lines 150-190 ---\n'
sed -n '140,190p' e2e/tests/onboarding-form.spec.ts | nl -ba -v140

printf '\n--- relevant selector occurrences in target spec ---\n'
rg -n 'getByText\(|getByTestId\(|Get started with NetBird|intent step|intent' e2e/tests/onboarding-form.spec.ts || true

printf '\n--- getStarted text occurrences in repo ---\n'
rg -n '"?Get started with NetBird"?|Get started with NetBird' . --glob '!node_modules' --glob '!dist' --glob '!build' || true

Repository: netbirdio/dashboard

Length of output: 248


🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf '%s\n' '--- target spec around lines 150-190 ---'
sed -n '140,190p' e2e/tests/onboarding-form.spec.ts | nl -ba -v140

printf '%s\n' '\n--- relevant selector occurrences in target spec ---'
rg -n 'getByText\(|getByTestId\(|Get started with NetBird|intent step|intent' e2e/tests/onboarding-form.spec.ts || true

printf '%s\n' '\n--- Get started with NetBird occurrences in repo ---'
rg -n 'Get started with NetBird' . --glob '!node_modules' --glob '!dist' --glob '!build' || true

Repository: netbirdio/dashboard

Length of output: 238


🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf '%s\n' '--- target spec around lines 150-190 ---'
awk '{printf "%5d\t%s\n", NR, $0}' e2e/tests/onboarding-form.spec.ts | sed -n '140,190p'

printf '%s\n' '--- relevant selector occurrences in target spec ---'
rg -n 'getByText\(|getByTestId\(|Get started with NetBird|intent step|intent' e2e/tests/onboarding-form.spec.ts || true

printf '%s\n' '--- Get started with NetBird occurrences in repo ---'
rg -n 'Get started with NetBird' . --glob '!node_modules' --glob '!dist' --glob '!build' || true

Repository: netbirdio/dashboard

Length of output: 3835


🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf '%s\n' '--- OnboardingIntent.tsx relevant section ---'
awk '{printf "%5d\t%s\n", NR, $0}' src/modules/onboarding/OnboardingIntent.tsx | sed -n '1,140p'

printf '%s\n' '--- current e2e data-testid usage for onboarding/OnboardingIntent ---'
rg -n 'data-testid|byTestId|OnboardingIntent|Get started with NetBird' src/modules/onboarding e2e/tests/onboarding-form.spec.ts | head -n 200

Repository: netbirdio/dashboard

Length of output: 7474


Use a data-testid selector for the intent-step assertion.

OnboardingIntent.tsx exposes the root as data-testid="regular-onboarding", so replace the brittle getByText("Get started with NetBird") assertion with page.getByTestId("regular-onboarding").

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@e2e/tests/onboarding-form.spec.ts` around lines 173 - 175, Update the
intent-step assertion in the onboarding test to use
page.getByTestId("regular-onboarding") instead of the text-based getByText
selector, while preserving the existing visibility expectation.

Source: Coding guidelines

} finally {
await close();
}
});

test("a self-hosted account with only the signup form pending shows no onboarding", async ({
browser,
}) => {
const { page, close } = await openOnboarding(browser, {
source: false,
edition: "oss",
account: { signupFormPending: true },
expectOnboarding: false,
});
try {
// loginToApp resolved the dashboard, so the account state has been
// applied — neither flow should have opened.
await expect(page.getByTestId(REGULAR_FORM)).toHaveCount(0);
await expect(page.getByTestId(AGENT_FORM)).toHaveCount(0);
} finally {
await close();
}
});

test("a slow backend never flashes the regular form for a netbird.ai signup", async ({
browser,
}) => {
Expand Down
Loading
Loading