Skip to content
Original file line number Diff line number Diff line change
Expand Up @@ -221,20 +221,33 @@ export default function WelcomeContent({ isAuthenticated }: WelcomeContentProps)
/>
</div>

{!isAuthenticated ? (
<p
style={{ animationDelay: '540ms' }}
className="text-muted-foreground kilo-fade-up pt-1 text-center text-xs"
>
Already have an account?{' '}
<Link
href={signInHref}
className="text-brand-primary rounded font-semibold outline-none hover:underline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-brand-primary/60"
>
Sign in
</Link>
</p>
) : null}
<p
style={{ animationDelay: '540ms' }}
className="text-muted-foreground kilo-fade-up pt-1 text-center text-xs"
>
{isAuthenticated ? (
<>
Not ready to choose?{' '}
<Link
href="/profile"
className="inline-flex items-center gap-1 rounded font-semibold text-white outline-none hover:underline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-brand-primary/60"
>
Skip to dashboard
<ArrowRight className="h-3 w-3" />
</Link>
</>
) : (
<>
Already have an account?{' '}
<Link
href={signInHref}
className="text-brand-primary rounded font-semibold outline-none hover:underline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-brand-primary/60"
>
Sign in
</Link>
</>
)}
</p>
</section>
</div>
);
Expand Down
44 changes: 44 additions & 0 deletions apps/web/tests/e2e/get-started-dashboard-link.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import { test, expect } from '@chromatic-com/playwright';
import { randomUUID } from 'crypto';

test.describe('/get-started dashboard escape hatch', () => {
test.use({ storageState: { cookies: [], origins: [] } });

test('hides the dashboard link for signed-out users', async ({ page }) => {
await page.goto('/get-started');

const skipLink = page.getByRole('link', { name: /skip to dashboard/i });
await expect(skipLink).toHaveCount(0);

const signInLink = page.getByRole('link', { name: /sign in/i });
await expect(signInLink).toBeVisible();
await expect(signInLink).toHaveAttribute('href', '/users/sign_in?callbackPath=/get-started');
});

test('shows the dashboard link after fake login and survey skip', async ({ page }) => {
const uniqueId = randomUUID().slice(0, 8);
const testEmail = `test-get-started-${uniqueId}+stytchpass@example.com`;

await page.goto(`/users/sign_in?fakeUser=${encodeURIComponent(testEmail)}`);
await page.waitForURL(
url =>
url.pathname === '/customer-source-survey' ||
url.pathname === '/get-started' ||
url.pathname === '/profile',
{ timeout: 30000, waitUntil: 'networkidle' }
);

if (new URL(page.url()).pathname === '/customer-source-survey') {
await page.getByRole('button', { name: 'Skip' }).click();
await page.waitForURL(url => url.pathname === '/get-started' || url.pathname === '/profile', {
timeout: 15000,
waitUntil: 'networkidle',
});
}

await page.goto('/get-started');
const skipLink = page.getByRole('link', { name: /skip to dashboard/i });
await expect(skipLink).toBeVisible();
await expect(skipLink).toHaveAttribute('href', '/profile');
});
});