-
Notifications
You must be signed in to change notification settings - Fork 253
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(clerk-react): Fix forceRedirectUrl and fallbackRedirectUrl when p…
…assed to button components (#3508) Co-authored-by: Lennart <lekoarts@gmail.com>
- Loading branch information
Showing
9 changed files
with
203 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@clerk/clerk-react': patch | ||
--- | ||
|
||
Update `SignUpButton` and `SignInButton` to respect `forceRedirect` and `fallbackRedirect` props. Previously, these were getting ignored and successful completions of the flows would fallback to the default redirect URL. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@clerk/clerk-js': patch | ||
--- | ||
|
||
Fixed a bug where Clerk components rendered in modals were wrapped with `aria-hidden`. |
35 changes: 35 additions & 0 deletions
35
integration/templates/next-app-router/src/app/buttons/page.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { SignInButton, SignUpButton } from '@clerk/nextjs'; | ||
|
||
export default function Home() { | ||
return ( | ||
<main> | ||
<SignInButton | ||
mode='modal' | ||
forceRedirectUrl='/protected' | ||
> | ||
Sign in button (force) | ||
</SignInButton> | ||
|
||
<SignInButton | ||
mode='modal' | ||
fallbackRedirectUrl='/protected' | ||
> | ||
Sign in button (fallback) | ||
</SignInButton> | ||
|
||
<SignUpButton | ||
mode='modal' | ||
forceRedirectUrl='/protected' | ||
> | ||
Sign up button (force) | ||
</SignUpButton> | ||
|
||
<SignUpButton | ||
mode='modal' | ||
fallbackRedirectUrl='/protected' | ||
> | ||
Sign up button (fallback) | ||
</SignUpButton> | ||
</main> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,130 @@ | ||
import { test } from '@playwright/test'; | ||
|
||
import { appConfigs } from '../presets'; | ||
import type { FakeUser } from '../testUtils'; | ||
import { createTestUtils, testAgainstRunningApps } from '../testUtils'; | ||
|
||
testAgainstRunningApps({ withEnv: [appConfigs.envs.withEmailCodes] })('redirect props @nextjs', ({ app }) => { | ||
test.describe.configure({ mode: 'serial' }); | ||
|
||
let fakeUser: FakeUser; | ||
|
||
test.beforeAll(async () => { | ||
const u = createTestUtils({ app }); | ||
fakeUser = u.services.users.createFakeUser({ | ||
fictionalEmail: true, | ||
withPhoneNumber: true, | ||
withUsername: true, | ||
}); | ||
await u.services.users.createBapiUser(fakeUser); | ||
}); | ||
|
||
test.afterAll(async () => { | ||
await fakeUser.deleteIfExists(); | ||
await app.teardown(); | ||
}); | ||
|
||
test.afterEach(async ({ page, context }) => { | ||
const u = createTestUtils({ app, page, context }); | ||
await u.page.signOut(); | ||
await u.page.context().clearCookies(); | ||
}); | ||
|
||
test.describe('SignInButton', () => { | ||
test('sign in button respects forceRedirectUrl', async ({ page, context }) => { | ||
const u = createTestUtils({ app, page, context }); | ||
|
||
await u.page.goToRelative('/buttons'); | ||
await u.page.waitForClerkJsLoaded(); | ||
await u.po.expect.toBeSignedOut(); | ||
|
||
await u.page.getByText('Sign in button (force)').click(); | ||
|
||
await u.po.signIn.waitForMounted(); | ||
await u.po.signIn.signInWithEmailAndInstantPassword({ email: fakeUser.email, password: fakeUser.password }); | ||
|
||
await u.page.waitForAppUrl('/protected'); | ||
|
||
await u.po.expect.toBeSignedIn(); | ||
}); | ||
|
||
test('sign in button respects fallbackRedirectUrl', async ({ page, context }) => { | ||
const u = createTestUtils({ app, page, context }); | ||
|
||
await u.page.goToRelative('/buttons'); | ||
await u.page.waitForClerkJsLoaded(); | ||
await u.po.expect.toBeSignedOut(); | ||
|
||
await u.page.getByText('Sign in button (fallback)').click(); | ||
|
||
await u.po.signIn.waitForMounted(); | ||
await u.po.signIn.signInWithEmailAndInstantPassword({ email: fakeUser.email, password: fakeUser.password }); | ||
|
||
await u.page.waitForAppUrl('/protected'); | ||
|
||
await u.po.expect.toBeSignedIn(); | ||
}); | ||
}); | ||
|
||
test.describe('SignUpButton', () => { | ||
test('sign up button respects forceRedirectUrl', async ({ page, context }) => { | ||
const u = createTestUtils({ app, page, context }); | ||
const fakeUser = u.services.users.createFakeUser({ | ||
fictionalEmail: true, | ||
withPhoneNumber: true, | ||
withUsername: true, | ||
}); | ||
|
||
await u.page.goToRelative('/buttons'); | ||
await u.page.waitForClerkJsLoaded(); | ||
|
||
await u.page.getByText('Sign up button (force)').click(); | ||
|
||
// Fill in sign up form | ||
await u.po.signUp.signUpWithEmailAndPassword({ | ||
email: fakeUser.email, | ||
password: fakeUser.password, | ||
}); | ||
|
||
// Verify email | ||
await u.po.signUp.enterTestOtpCode(); | ||
|
||
await u.page.waitForAppUrl('/protected'); | ||
|
||
// Check if user is signed in | ||
await u.po.expect.toBeSignedIn(); | ||
|
||
await fakeUser.deleteIfExists(); | ||
}); | ||
|
||
test('sign up button respects fallbackRedirectUrl', async ({ page, context }) => { | ||
const u = createTestUtils({ app, page, context }); | ||
const fakeUser = u.services.users.createFakeUser({ | ||
fictionalEmail: true, | ||
withPhoneNumber: true, | ||
withUsername: true, | ||
}); | ||
|
||
await u.page.goToRelative('/buttons'); | ||
await u.page.waitForClerkJsLoaded(); | ||
|
||
await u.page.getByText('Sign up button (fallback)').click(); | ||
|
||
// Fill in sign up form | ||
await u.po.signUp.signUpWithEmailAndPassword({ | ||
email: fakeUser.email, | ||
password: fakeUser.password, | ||
}); | ||
|
||
// Verify email | ||
await u.po.signUp.enterTestOtpCode(); | ||
|
||
await u.page.waitForAppUrl('/protected'); | ||
|
||
// Check if user is signed in | ||
await u.po.expect.toBeSignedIn(); | ||
|
||
await fakeUser.deleteIfExists(); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters