Skip to content

Commit 0ad9831

Browse files
Merge branch 'main' into heat/grow-668-additional-metadata-headers-for-keyless-app-creation-post
2 parents d599b9c + e78c73e commit 0ad9831

File tree

15 files changed

+854
-67
lines changed

15 files changed

+854
-67
lines changed

.changeset/easy-parrots-slide.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
---
2+
'@clerk/testing': minor
3+
---
4+
5+
Introduce new helper to allow signing a user in via email address:
6+
7+
```ts
8+
import { clerk } from '@clerk/testing/playwright'
9+
10+
test('sign in', async ({ page }) => {
11+
await clerk.signIn({ emailAddress: '[email protected]', page })
12+
})
13+
```

.changeset/few-eagles-grab.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@clerk/clerk-js': patch
3+
---
4+
5+
Remove flickers from PricingTable when signed in.

.changeset/fresh-breads-fall.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@clerk/clerk-js': patch
3+
---
4+
5+
Display trial subscriptions in UserProfile and OrganizationProfile.

packages/clerk-js/sandbox/integration/helpers.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,19 @@ export async function signInWithEmailCode(page: Page): Promise<void> {
1919
signInParams: { strategy: 'email_code', identifier: '[email protected]' },
2020
});
2121
}
22+
23+
/**
24+
* Signs in a user using the new email-based ticket strategy for integration tests.
25+
* Finds the user by email, creates a sign-in token, and uses the ticket strategy.
26+
* @param page - The Playwright page instance
27+
* @param emailAddress - The email address of the user to sign in (defaults to sandbox test user)
28+
* @example
29+
* ```ts
30+
* await signInWithEmail(page);
31+
* await page.goto('/protected-page');
32+
* ```
33+
*/
34+
export async function signInWithEmail(page: Page, emailAddress = '[email protected]'): Promise<void> {
35+
await page.goto('/sign-in');
36+
await clerk.signIn({ emailAddress, page });
37+
}

packages/clerk-js/sandbox/integration/sign-in.spec.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,26 @@ test('sign in', async ({ page }) => {
1818
await page.locator(actionLinkElement).hover();
1919
await expect(page.locator(rootElement)).toHaveScreenshot('sign-in-action-link-hover.png');
2020
});
21+
22+
test('sign in with email', async ({ page }) => {
23+
await page.goto('/sign-in');
24+
25+
await clerk.signIn({
26+
emailAddress: '[email protected]',
27+
page,
28+
});
29+
30+
await page.waitForFunction(() => window.Clerk?.user !== null);
31+
32+
const userInfo = await page.evaluate(() => ({
33+
isSignedIn: window.Clerk?.user !== null && window.Clerk?.user !== undefined,
34+
email: window.Clerk?.user?.primaryEmailAddress?.emailAddress,
35+
userId: window.Clerk?.user?.id,
36+
isLoaded: window.Clerk?.loaded,
37+
}));
38+
39+
expect(userInfo.isSignedIn).toBe(true);
40+
expect(userInfo.email).toBe('[email protected]');
41+
expect(userInfo.userId).toBeTruthy();
42+
expect(userInfo.isLoaded).toBe(true);
43+
});

packages/clerk-js/src/ui/components/PricingTable/PricingTable.tsx

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,18 @@ const PricingTableRoot = (props: PricingTableProps) => {
1212
const clerk = useClerk();
1313
const { mode = 'mounted', signInMode = 'redirect' } = usePricingTableContext();
1414
const isCompact = mode === 'modal';
15-
const { subscriptionItems } = useSubscription();
15+
const { data: subscription, subscriptionItems } = useSubscription();
1616
const { data: plans } = usePlans();
1717
const { handleSelectPlan } = usePlansContext();
1818

19+
const plansToRender = useMemo(() => {
20+
return clerk.isSignedIn
21+
? subscription // All users in billing-enabled applications have a subscription
22+
? plans
23+
: []
24+
: plans;
25+
}, [clerk.isSignedIn, plans, subscription]);
26+
1927
const defaultPlanPeriod = useMemo(() => {
2028
if (isCompact) {
2129
const upcomingSubscription = subscriptionItems?.find(sub => sub.status === 'upcoming');
@@ -72,15 +80,15 @@ const PricingTableRoot = (props: PricingTableProps) => {
7280
>
7381
{mode !== 'modal' && (props as any).layout === 'matrix' ? (
7482
<PricingTableMatrix
75-
plans={plans}
83+
plans={plansToRender}
7684
planPeriod={planPeriod}
7785
setPlanPeriod={setPlanPeriod}
7886
onSelect={selectPlan}
7987
highlightedPlan={(props as any).highlightPlan}
8088
/>
8189
) : (
8290
<PricingTableDefault
83-
plans={plans}
91+
plans={plansToRender}
8492
planPeriod={planPeriod}
8593
setPlanPeriod={setPlanPeriod}
8694
onSelect={selectPlan}

packages/clerk-js/src/ui/components/PricingTable/PricingTableDefault.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ function Card(props: CardProps) {
240240
? localizationKeys('badge__trialEndsAt', {
241241
date: subscription.periodEnd,
242242
})
243-
: localizationKeys('badge__startsAt', { date: subscription?.periodStart })
243+
: localizationKeys('badge__startsAt', { date: subscription.periodStart })
244244
}
245245
colorScheme='secondary'
246246
sx={t => ({

0 commit comments

Comments
 (0)