-
Notifications
You must be signed in to change notification settings - Fork 461
Expand file tree
/
Copy pathcomponents.test.ts
More file actions
119 lines (109 loc) · 3.31 KB
/
Copy pathcomponents.test.ts
File metadata and controls
119 lines (109 loc) · 3.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
import { expect, test } from '@playwright/test';
import { appConfigs } from '../presets';
import type { FakeOrganization, FakeUser } from '../testUtils';
import { createTestUtils, testAgainstRunningApps } from '../testUtils';
testAgainstRunningApps({ withEnv: [appConfigs.envs.withEmailCodes] })('component smoke tests @generic', ({ app }) => {
let fakeUser: FakeUser;
let fakeOrganization: FakeOrganization;
test.beforeAll(async () => {
const u = createTestUtils({ app });
fakeUser = u.services.users.createFakeUser({
withPhoneNumber: true,
withUsername: true,
});
const user = await u.services.users.createBapiUser(fakeUser);
fakeOrganization = await u.services.users.createFakeOrganization(user.id);
});
test.afterAll(async () => {
await app.teardown();
await fakeUser?.deleteIfExists();
await fakeOrganization?.delete();
});
const components = [
{
name: 'SignIn',
path: '/sign-in',
fallback: 'Loading sign in',
},
{
name: 'SignUp',
path: '/sign-up',
fallback: 'Loading sign up',
},
{
name: 'UserProfile',
path: '/user',
protected: true,
fallback: 'Loading user profile',
},
{
name: 'UserAvatar',
path: '/user-avatar',
protected: true,
fallback: 'Loading user avatar',
},
{
name: 'UserButton',
path: '/user-button',
protected: true,
fallback: 'Loading user button',
},
{
name: 'Waitlist',
path: '/waitlist',
fallback: 'Loading waitlist',
},
{
name: 'OrganizationSwitcher',
path: '/organization-switcher',
fallback: 'Loading organization switcher',
protected: true,
},
{
name: 'OrganizationProfile',
path: '/organization-profile',
fallback: 'Loading organization profile',
protected: true,
},
{
name: 'OrganizationList',
path: '/organization-list',
fallback: 'Loading organization list',
protected: true,
},
{
name: 'CreateOrganization',
path: '/create-organization',
fallback: 'Loading create organization',
protected: true,
},
];
const signIn = async ({ app, page, context }) => {
const u = createTestUtils({ app, page, context });
await u.po.signIn.goTo();
await u.po.signIn.signInWithEmailAndInstantPassword({ email: fakeUser.email, password: fakeUser.password });
await u.po.expect.toBeSignedIn();
};
const signOut = async ({ app, page, context }) => {
const u = createTestUtils({ app, page, context });
await u.page.waitForClerkJsLoaded();
await u.page.evaluate(async () => {
await window.Clerk.signOut();
});
};
for (const component of components) {
test(`${component.name} supports fallback`, async ({ page, context }) => {
// eslint-disable-next-line playwright/no-conditional-in-test
if (component.protected) {
await signIn({ app, page, context });
}
const u = createTestUtils({ app, page, context });
await u.page.goToRelative(component.path, { waitUntil: 'commit' });
await expect(u.page.getByText(component.fallback)).toBeVisible();
// eslint-disable-next-line playwright/no-conditional-in-test
if (component.protected) {
await signOut({ app, page, context });
}
});
}
});