Skip to content

Commit 815e0e8

Browse files
committed
test(clerk-js): Remove skipped integration tests related to navigation
1 parent 13cfbf4 commit 815e0e8

File tree

3 files changed

+142
-127
lines changed

3 files changed

+142
-127
lines changed

.changeset/early-dryers-lay.md

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
---
2+
---

integration/testUtils/userProfilePageObject.ts

+12
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,18 @@ export const createUserProfileComponentPageObject = (testArgs: TestArgs) => {
1515
waitForMounted: () => {
1616
return page.waitForSelector('.cl-userProfile-root', { state: 'attached' });
1717
},
18+
clickSetUsername: () => {
19+
return page.getByText(/Set username/i).click();
20+
},
21+
typeUsername: (value: string) => {
22+
return page.getByLabel(/username/i).fill(value);
23+
},
24+
clickAddEmailAddress: () => {
25+
return page.getByText(/Add email address/i).click();
26+
},
27+
typeEmailAddress: (value: string) => {
28+
return page.getByLabel(/Email address/i).fill(value);
29+
},
1830
};
1931
return self;
2032
};

integration/tests/navigation.test.ts

+128-127
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ export default function RootLayout({ children }: { children: React.ReactNode })
5050
}`,
5151
)
5252
.addFile(
53-
'src/app/hash/user/[[...catchall]]/page.tsx',
53+
'src/app/hash/user/page.tsx',
5454
() => `
5555
import { UserProfile, UserButton } from '@clerk/nextjs';
5656
@@ -64,7 +64,7 @@ export default function Page() {
6464
}`,
6565
)
6666
.addFile(
67-
'src/app/hash/sign-in/[[...catchall]]/page.tsx',
67+
'src/app/hash/sign-in/page.tsx',
6868
() => `
6969
import { SignIn } from '@clerk/nextjs';
7070
@@ -91,129 +91,130 @@ export default function Page() {
9191
await app.teardown();
9292
});
9393

94-
//TODO-RETHEME: Refactor this, because this path doesn't exist anymore
95-
// test('user profile with path routing', async ({ page, context }) => {
96-
// const u = createTestUtils({ app, page, context });
97-
// await u.po.signIn.goTo();
98-
// await u.po.signIn.waitForMounted();
99-
// await u.po.signIn.signInWithEmailAndInstantPassword({ email: fakeUser.email, password: fakeUser.password });
100-
// await u.po.expect.toBeSignedIn();
101-
//
102-
// await u.po.userProfile.goTo();
103-
// await u.po.userProfile.waitForMounted();
104-
//
105-
// await u.page.getByText(/Set username/i).click();
106-
//
107-
// await u.page.waitForURL(`${app.serverUrl}/user/username`);
108-
//
109-
// await u.page.getByText(/Cancel/i).click();
110-
//
111-
// await u.page.waitForURL(`${app.serverUrl}/user`);
112-
//
113-
// await u.page.getByText(/Add email address/i).click();
114-
//
115-
// await u.page.waitForURL(`${app.serverUrl}/user/email-address`);
116-
//
117-
// await u.page.getByText(/Cancel/i).click();
118-
//
119-
// await u.page.waitForURL(`${app.serverUrl}/user`);
120-
// });
121-
122-
//TODO-RETHEME: Refactor this, because this path doesn't exist anymore
123-
// test('user profile with hash routing', async ({ page, context }) => {
124-
// const u = createTestUtils({ app, page, context });
125-
// await u.po.signIn.goTo();
126-
// await u.po.signIn.waitForMounted();
127-
// await u.po.signIn.signInWithEmailAndInstantPassword({ email: fakeUser.email, password: fakeUser.password });
128-
// await u.po.expect.toBeSignedIn();
129-
//
130-
// await u.page.goToRelative('/hash/user');
131-
// await u.po.userProfile.waitForMounted();
132-
//
133-
// await u.page.getByText(/Set username/i).click();
134-
//
135-
// expect(u.page.url()).toBe(`${app.serverUrl}/hash/user#/username`);
136-
//
137-
// await u.page.getByText(/Cancel/i).click();
138-
//
139-
// expect(u.page.url()).toBe(`${app.serverUrl}/hash/user#`);
140-
//
141-
// await u.page.getByText(/Add email address/i).click();
142-
//
143-
// expect(u.page.url()).toBe(`${app.serverUrl}/hash/user#/email-address`);
144-
//
145-
// await u.page.getByText(/Cancel/i).click();
146-
//
147-
// expect(u.page.url()).toBe(`${app.serverUrl}/hash/user#`);
148-
// });
149-
150-
// TODO-RETHEME: fix this test
151-
// test('sign in with path routing', async ({ page, context }) => {
152-
// const u = createTestUtils({ app, page, context });
153-
// await u.po.signIn.goTo();
154-
// await u.po.signIn.waitForMounted();
155-
//
156-
// await u.po.signIn.setIdentifier(fakeUser.email);
157-
// await u.po.signIn.continue();
158-
// await u.page.waitForURL(`${app.serverUrl}/sign-in/factor-one`);
159-
//
160-
// await u.po.signIn.setPassword(fakeUser.password);
161-
// await u.po.signIn.continue();
162-
//
163-
// await u.po.expect.toBeSignedIn();
164-
// });
165-
166-
// TODO-RETHEME: fix this test
167-
// test('sign in with hash routing', async ({ page, context }) => {
168-
// const u = createTestUtils({ app, page, context });
169-
// await u.page.goToRelative('/hash/sign-in');
170-
// await u.po.signIn.waitForMounted();
171-
//
172-
// await u.po.signIn.setIdentifier(fakeUser.email);
173-
// await u.po.signIn.continue();
174-
// await u.page.waitForURL(`${app.serverUrl}/hash/sign-in#/factor-one`);
175-
//
176-
// await u.po.signIn.setPassword(fakeUser.password);
177-
// await u.po.signIn.continue();
178-
//
179-
// await u.po.expect.toBeSignedIn();
180-
// });
181-
182-
// TODO-RETHEME: fix this test
183-
// test('user profile from user button navigates correctly', async ({ page, context }) => {
184-
// const u = createTestUtils({ app, page, context });
185-
// await u.po.signIn.goTo();
186-
// await u.po.signIn.waitForMounted();
187-
// await u.po.signIn.signInWithEmailAndInstantPassword({ email: fakeUser.email, password: fakeUser.password });
188-
// await u.po.expect.toBeSignedIn();
189-
//
190-
// await u.page.goToRelative('/');
191-
// await u.page.waitForClerkComponentMounted();
192-
//
193-
// await u.page.getByRole('button', { name: 'Open user button' }).click();
194-
//
195-
// await u.page.getByText(/Manage account/).click();
196-
//
197-
// await u.page.waitForSelector('.cl-modalContent > .cl-userProfile-root', { state: 'attached' });
198-
//
199-
// await u.page.getByText(/Set username/i).click();
200-
// await u.page.getByText(/Cancel/i).click();
201-
//
202-
// await u.page.getByText(/Add email address/i).click();
203-
// await u.page.getByText(/Cancel/i).click();
204-
// });
205-
//
206-
// test('sign in with path routing navigates to previous page', async ({ page, context }) => {
207-
// const u = createTestUtils({ app, page, context });
208-
// await u.po.signIn.goTo();
209-
// await u.po.signIn.waitForMounted();
210-
//
211-
// await u.po.signIn.getGoToSignUp().click();
212-
// await u.po.signUp.waitForMounted();
213-
// await u.page.waitForURL(`${app.serverUrl}/sign-up?redirect_url=${encodeURIComponent(app.serverUrl + '/')}`);
214-
//
215-
// await page.goBack();
216-
// await u.po.signIn.waitForMounted();
217-
// await u.page.waitForURL(`${app.serverUrl}/sign-in`);
218-
// });
94+
test('user profile with path routing', async ({ page, context }) => {
95+
const u = createTestUtils({ app, page, context });
96+
await u.po.signIn.goTo();
97+
await u.po.signIn.waitForMounted();
98+
await u.po.signIn.signInWithEmailAndInstantPassword({ email: fakeUser.email, password: fakeUser.password });
99+
await u.po.expect.toBeSignedIn();
100+
101+
await u.po.userProfile.goTo();
102+
await u.po.userProfile.waitForMounted();
103+
104+
await u.po.userProfile.clickSetUsername();
105+
106+
u.page.getByText(/Update username/i);
107+
108+
await u.po.userProfile.typeUsername('some_username');
109+
110+
await u.page.getByText(/Cancel/i).click();
111+
112+
await u.page.waitForSelector('.cl-profileSectionContent__username .cl-headerTitle', { state: 'detached' });
113+
114+
await u.po.userProfile.clickAddEmailAddress();
115+
116+
u.page.getByText(/an email containing/i);
117+
118+
await u.po.userProfile.typeEmailAddress('some@email.com');
119+
120+
await u.page.getByText(/Cancel/i).click();
121+
});
122+
123+
test('user profile with hash routing', async ({ page, context }) => {
124+
const u = createTestUtils({ app, page, context });
125+
await u.po.signIn.goTo();
126+
await u.po.signIn.waitForMounted();
127+
await u.po.signIn.signInWithEmailAndInstantPassword({ email: fakeUser.email, password: fakeUser.password });
128+
await u.po.expect.toBeSignedIn();
129+
130+
await u.page.goToRelative('/hash/user');
131+
await u.po.userProfile.waitForMounted();
132+
133+
await u.po.userProfile.clickSetUsername();
134+
135+
u.page.getByText(/Update username/i);
136+
137+
await u.po.userProfile.typeUsername('some_username');
138+
139+
await u.page.getByText(/Cancel/i).click();
140+
141+
await u.page.waitForSelector('.cl-profileSectionContent__username .cl-headerTitle', { state: 'detached' });
142+
143+
await u.po.userProfile.clickAddEmailAddress();
144+
145+
u.page.getByText(/an email containing/i);
146+
147+
await u.po.userProfile.typeEmailAddress('some@email.com');
148+
149+
await u.page.getByText(/Cancel/i).click();
150+
});
151+
152+
test('sign in with path routing', async ({ page, context }) => {
153+
const u = createTestUtils({ app, page, context });
154+
await u.po.signIn.goTo();
155+
await u.po.signIn.waitForMounted();
156+
157+
await u.po.signIn.setIdentifier(fakeUser.email);
158+
await u.po.signIn.continue();
159+
await u.page.waitForURL(`${app.serverUrl}/sign-in/factor-one`);
160+
161+
await u.po.signIn.setPassword(fakeUser.password);
162+
await u.po.signIn.continue();
163+
164+
await u.po.expect.toBeSignedIn();
165+
});
166+
167+
test('sign in with hash routing', async ({ page, context }) => {
168+
const u = createTestUtils({ app, page, context });
169+
await u.page.goToRelative('/hash/sign-in');
170+
await u.po.signIn.waitForMounted();
171+
172+
await u.po.signIn.setIdentifier(fakeUser.email);
173+
await u.po.signIn.continue();
174+
await u.page.waitForURL(`${app.serverUrl}/hash/sign-in#/factor-one`);
175+
176+
await u.po.signIn.setPassword(fakeUser.password);
177+
await u.po.signIn.continue();
178+
179+
await u.po.expect.toBeSignedIn();
180+
});
181+
182+
test('user profile from user button navigates correctly', async ({ page, context }) => {
183+
const u = createTestUtils({ app, page, context });
184+
await u.po.signIn.goTo();
185+
await u.po.signIn.waitForMounted();
186+
await u.po.signIn.signInWithEmailAndInstantPassword({ email: fakeUser.email, password: fakeUser.password });
187+
await u.po.expect.toBeSignedIn();
188+
189+
await u.page.goToRelative('/');
190+
await u.page.waitForClerkComponentMounted();
191+
192+
await u.page.getByRole('button', { name: 'Open user button' }).click();
193+
194+
await u.page.getByText(/Manage account/).click();
195+
196+
await u.page.waitForSelector('.cl-modalContent > .cl-userProfile-root', { state: 'attached' });
197+
198+
await u.po.userProfile.clickSetUsername();
199+
await u.page.getByText(/Cancel/i).click();
200+
201+
await u.page.waitForSelector('.cl-profileSectionContent__username .cl-headerTitle', { state: 'detached' });
202+
203+
await u.po.userProfile.clickAddEmailAddress();
204+
await u.page.getByText(/Cancel/i).click();
205+
});
206+
207+
test('sign in with path routing navigates to previous page', async ({ page, context }) => {
208+
const u = createTestUtils({ app, page, context });
209+
await u.po.signIn.goTo();
210+
await u.po.signIn.waitForMounted();
211+
212+
await u.po.signIn.getGoToSignUp().click();
213+
await u.po.signUp.waitForMounted();
214+
await u.page.waitForURL(`${app.serverUrl}/sign-up?redirect_url=${encodeURIComponent(app.serverUrl + '/')}`);
215+
216+
await page.goBack();
217+
await u.po.signIn.waitForMounted();
218+
await u.page.waitForURL(`${app.serverUrl}/sign-in`);
219+
});
219220
});

0 commit comments

Comments
 (0)