|
| 1 | +import { expect, test } from '@playwright/test'; |
| 2 | + |
| 3 | +import { appConfigs } from '../presets'; |
| 4 | +import type { FakeUser } from '../testUtils'; |
| 5 | +import { createTestUtils, testAgainstRunningApps } from '../testUtils'; |
| 6 | + |
| 7 | +testAgainstRunningApps({ withPattern: ['next.appRouterBundledUI.*'] })( |
| 8 | + 'bundled UI smoke tests @bundled-ui', |
| 9 | + ({ app }) => { |
| 10 | + test.describe.configure({ mode: 'serial' }); |
| 11 | + |
| 12 | + let fakeUser: FakeUser; |
| 13 | + |
| 14 | + test.beforeAll(async () => { |
| 15 | + const u = createTestUtils({ app }); |
| 16 | + fakeUser = u.services.users.createFakeUser(); |
| 17 | + await u.services.users.createBapiUser(fakeUser); |
| 18 | + }); |
| 19 | + |
| 20 | + test.afterAll(async () => { |
| 21 | + await fakeUser.deleteIfExists(); |
| 22 | + await app.teardown(); |
| 23 | + }); |
| 24 | + |
| 25 | + test('Clerk client loads and renders sign-in/sign-up buttons on home page', async ({ page, context }) => { |
| 26 | + const u = createTestUtils({ app, page, context }); |
| 27 | + await u.page.goToAppHome(); |
| 28 | + await u.page.waitForClerkJsLoaded(); |
| 29 | + await u.po.expect.toBeSignedOut(); |
| 30 | + |
| 31 | + await expect(u.page.getByRole('button', { name: /Sign in/i })).toBeVisible(); |
| 32 | + await expect(u.page.getByRole('button', { name: /Sign up/i })).toBeVisible(); |
| 33 | + }); |
| 34 | + |
| 35 | + test('SignIn component renders on /sign-in page', async ({ page, context }) => { |
| 36 | + const u = createTestUtils({ app, page, context }); |
| 37 | + await u.po.signIn.goTo(); |
| 38 | + await u.po.signIn.waitForMounted(); |
| 39 | + }); |
| 40 | + |
| 41 | + test('SignUp component renders on /sign-up page', async ({ page, context }) => { |
| 42 | + const u = createTestUtils({ app, page, context }); |
| 43 | + await u.po.signUp.goTo(); |
| 44 | + await u.po.signUp.waitForMounted(); |
| 45 | + }); |
| 46 | + |
| 47 | + test('can sign in with email and password', async ({ page, context }) => { |
| 48 | + const u = createTestUtils({ app, page, context }); |
| 49 | + await u.po.signIn.goTo(); |
| 50 | + await u.po.signIn.signInWithEmailAndInstantPassword({ email: fakeUser.email, password: fakeUser.password }); |
| 51 | + await u.po.expect.toBeSignedIn(); |
| 52 | + }); |
| 53 | + |
| 54 | + test('UserButton renders after sign in', async ({ page, context }) => { |
| 55 | + const u = createTestUtils({ app, page, context }); |
| 56 | + await u.po.signIn.goTo(); |
| 57 | + await u.po.signIn.signInWithEmailAndInstantPassword({ email: fakeUser.email, password: fakeUser.password }); |
| 58 | + await u.po.expect.toBeSignedIn(); |
| 59 | + |
| 60 | + await u.page.goToRelative('/user-button'); |
| 61 | + await u.po.userButton.waitForMounted(); |
| 62 | + await expect(u.page.getByRole('button', { name: /Open user menu/i })).toBeVisible(); |
| 63 | + }); |
| 64 | + |
| 65 | + test('can sign out through user button', async ({ page, context }) => { |
| 66 | + const u = createTestUtils({ app, page, context }); |
| 67 | + await u.po.signIn.goTo(); |
| 68 | + await u.po.signIn.signInWithEmailAndInstantPassword({ email: fakeUser.email, password: fakeUser.password }); |
| 69 | + await u.po.expect.toBeSignedIn(); |
| 70 | + |
| 71 | + await u.page.goToAppHome(); |
| 72 | + await u.po.userButton.waitForMounted(); |
| 73 | + await u.po.userButton.toggleTrigger(); |
| 74 | + await u.po.userButton.waitForPopover(); |
| 75 | + await u.po.userButton.triggerSignOut(); |
| 76 | + await u.po.expect.toBeSignedOut(); |
| 77 | + }); |
| 78 | + |
| 79 | + test('themes page renders SignIn components with all themes', async ({ page, context }) => { |
| 80 | + const u = createTestUtils({ app, page, context }); |
| 81 | + await u.page.goToRelative('/themes'); |
| 82 | + await u.page.waitForClerkJsLoaded(); |
| 83 | + |
| 84 | + await expect(u.page.getByText('Dark')).toBeVisible(); |
| 85 | + await expect(u.page.getByText('Neobrutalism')).toBeVisible(); |
| 86 | + await expect(u.page.getByText('Shades of Purple')).toBeVisible(); |
| 87 | + await expect(u.page.getByText('Shadcn')).toBeVisible(); |
| 88 | + }); |
| 89 | + }, |
| 90 | +); |
0 commit comments