Skip to content

Commit

Permalink
test(repo): Add tests for Sign Out functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
octoper committed Nov 9, 2023
1 parent 69a9c2b commit da6936f
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 2 deletions.
2 changes: 0 additions & 2 deletions integration/testUtils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,11 @@ const createExpectPageObject = ({ page }: TestArgs) => {
return {
toBeSignedOut: () => {
return page.waitForFunction(() => {
// @ts-ignore
return !window.Clerk?.user;
});
},
toBeSignedIn: async () => {
return page.waitForFunction(() => {
// @ts-ignore
return !!window.Clerk?.user;
});
},
Expand Down
46 changes: 46 additions & 0 deletions integration/tests/sign-out-smoke.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import { test } from '@playwright/test';

import { appConfigs } from '../presets';
import type { FakeUser } from '../testUtils';
import { createTestUtils, testAgainstRunningApps } from '../testUtils';

testAgainstRunningApps({ withEnv: [appConfigs.envs.withEmailCodes] })('sign out smoke test @generic', ({ app }) => {
test.describe.configure({ mode: 'serial' });

let fakeUser: FakeUser;

test.beforeAll(async () => {
const u = createTestUtils({ app });
fakeUser = u.services.users.createFakeUser();
await u.services.users.createBapiUser(fakeUser);
});

test.afterAll(async () => {
await fakeUser.deleteIfExists();
await app.teardown();
});

test('sign out throught all open tabs at once', async ({ page, context }) => {
const mainTab = createTestUtils({ app, page, context });
await mainTab.po.signIn.goTo();
await mainTab.po.signIn.setIdentifier(fakeUser.email);
await mainTab.po.signIn.continue();
await mainTab.po.signIn.setPassword(fakeUser.password);
await mainTab.po.signIn.continue();
await mainTab.po.expect.toBeSignedIn();

await mainTab.tabs.runInNewTab(async m => {
await m.page.goToStart();

await m.page.waitForClerkJsLoaded();

await m.po.expect.toBeSignedIn();

await m.page.evaluate(async () => {
await window.Clerk.signOut();
});
});

expect(await mainTab.page.evaluate('!window.Clerk.user')).toBe(false);
});
});

0 comments on commit da6936f

Please sign in to comment.