mirror of
https://github.com/langbot-app/LangBot.git
synced 2026-09-26 19:36:35 +08:00
fix(web): stabilize invitation error assertions
The invitation error copy also renders as a transient sonner toast, so the plain text locator resolved to two elements and tripped Playwright strict mode while the toast was on screen. Tag the inline error region with data-testid="invitation-error" and assert against it, keeping the check deterministic under CI parallelism.
This commit is contained in:
@@ -296,7 +296,7 @@ export default function AcceptInvitationPage() {
|
||||
<div className="space-y-4">
|
||||
<div className="flex items-start gap-2 rounded-lg border border-destructive/20 bg-destructive/5 p-3 text-sm text-destructive">
|
||||
<AlertCircle className="mt-0.5 size-4 shrink-0" />
|
||||
<span>{errorMessage}</span>
|
||||
<span data-testid="invitation-error">{errorMessage}</span>
|
||||
</div>
|
||||
<Button
|
||||
variant="outline"
|
||||
@@ -313,7 +313,7 @@ export default function AcceptInvitationPage() {
|
||||
{errorMessage && (
|
||||
<div className="flex items-start gap-2 rounded-lg border border-destructive/20 bg-destructive/5 p-3 text-sm text-destructive">
|
||||
<AlertCircle className="mt-0.5 size-4 shrink-0" />
|
||||
<span>{errorMessage}</span>
|
||||
<span data-testid="invitation-error">{errorMessage}</span>
|
||||
</div>
|
||||
)}
|
||||
|
||||
|
||||
@@ -27,9 +27,9 @@ test('terminal invitation errors refresh on a new fragment and allow account swi
|
||||
});
|
||||
|
||||
await page.goto('/invitations/accept#token=used-invitation');
|
||||
await expect(
|
||||
page.getByText('This invitation was already used.'),
|
||||
).toBeVisible();
|
||||
await expect(page.getByTestId('invitation-error')).toContainText(
|
||||
'This invitation was already used.',
|
||||
);
|
||||
await expect
|
||||
.poll(() =>
|
||||
page.evaluate(() =>
|
||||
@@ -41,7 +41,9 @@ test('terminal invitation errors refresh on a new fragment and allow account swi
|
||||
await page.evaluate(() => {
|
||||
window.location.hash = 'token=revoked-invitation';
|
||||
});
|
||||
await expect(page.getByText('This invitation was revoked.')).toBeVisible();
|
||||
await expect(page.getByTestId('invitation-error')).toContainText(
|
||||
'This invitation was revoked.',
|
||||
);
|
||||
|
||||
await page.getByRole('button', { name: 'Back to sign in' }).click();
|
||||
await expect(page).toHaveURL(/\/login$/);
|
||||
@@ -101,9 +103,11 @@ test('login preserves an explicit invitation email mismatch error', async ({
|
||||
await expect(page).toHaveURL(
|
||||
/\/invitations\/accept\?error=invitation_email_mismatch$/,
|
||||
);
|
||||
await expect(
|
||||
page.getByText('This invitation belongs to a different email address.'),
|
||||
).toBeVisible();
|
||||
// The same copy is also shown as a transient toast, so target the page's
|
||||
// inline error region to keep the assertion deterministic.
|
||||
await expect(page.getByTestId('invitation-error')).toContainText(
|
||||
'This invitation belongs to a different email address.',
|
||||
);
|
||||
await expect(page.getByText('Login successful')).toHaveCount(0);
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user