Skip to content
Open
3 changes: 3 additions & 0 deletions .changeset/olive-oranges-march.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
'@clerk/clerk-js': patch
---
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
export default async function Page({ params }: { params: Promise<{ orgId: string }> }) {
const { orgId } = await params;

return (
<div>
<p data-testid='current-org-id'>{orgId}</p>
</div>
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
'use client';

import { OrganizationSwitcher, useAuth } from '@clerk/nextjs';
import { useState } from 'react';
import { usePathname } from 'next/navigation';

function EmissionLog() {
const { orgId } = useAuth();
const pathname = usePathname();
const [log, setLog] = useState<string[]>([]);

const entry = `${pathname} - ${orgId}`;
if (entry !== log[log.length - 1]) {
setLog(prev => [...prev, entry]);
}

return (
<ul data-testid='emission-log'>
{log.map((entry, i) => (
<li
key={i}
data-testid={`emission-${i}`}
>
{entry}
</li>
))}
</ul>
);
}

export default function Layout({ children }: { children: React.ReactNode }) {
return (
<div style={{ margin: '40px' }}>
<div style={{ marginBottom: '20px' }}>
<OrganizationSwitcher
fallback={<div>Loading organization switcher</div>}
afterSelectOrganizationUrl='/transitive-state/organization-switcher/:id'
/>
</div>
<div style={{ marginBottom: '20px' }}>
<h2>Emission log</h2>
<EmissionLog />
</div>
{children}
</div>
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
'use client';

import { useAuth } from '@clerk/nextjs';
import { useState } from 'react';
import { usePathname } from 'next/navigation';

function EmissionLog() {
const { userId } = useAuth();
const pathname = usePathname();
const [log, setLog] = useState<string[]>([]);

const entry = `${pathname} - ${String(userId)}`;
if (entry !== log[log.length - 1]) {
setLog(prev => [...prev, entry]);
}

return (
<ul data-testid='emission-log'>
{log.map((entry, i) => (
<li
key={i}
data-testid={`emission-${i}`}
>
{entry}
</li>
))}
</ul>
);
}

export default function Layout({ children }: { children: React.ReactNode }) {
return (
<div style={{ margin: '40px' }}>
<div style={{ marginBottom: '20px' }}>
<h2>Emission log</h2>
<EmissionLog />
</div>
{children}
</div>
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { SignOutButton } from '@clerk/nextjs';

export default function Page() {
return (
<div>
<p data-testid='page-name'>sign-out</p>
<SignOutButton redirectUrl='/transitive-state/sign-out/sign-in' />
</div>
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export default function Page() {
return <p data-testid='page-name'>sign-in</p>;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
'use client';

import { UserButton, useAuth } from '@clerk/nextjs';
import { useState } from 'react';
import { usePathname } from 'next/navigation';

function EmissionLog() {
const { userId } = useAuth();
const pathname = usePathname();
const [log, setLog] = useState<string[]>([]);

const entry = `${pathname} - ${userId}`;
if (entry !== log[log.length - 1]) {
setLog(prev => [...prev, entry]);
}

return (
<ul data-testid='emission-log'>
{log.map((entry, i) => (
<li
key={i}
data-testid={`emission-${i}`}
>
{entry}
</li>
))}
</ul>
);
}

export default function Layout({ children }: { children: React.ReactNode }) {
return (
<div style={{ margin: '40px' }}>
<div style={{ marginBottom: '20px' }}>
<UserButton
fallback={<div>Loading user button</div>}
afterSwitchSessionUrl='/transitive-state/user-button/switched'
/>
</div>
<div style={{ marginBottom: '20px' }}>
<h2>Emission log</h2>
<EmissionLog />
</div>
{children}
</div>
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export default function Page() {
return <p data-testid='page-name'>initial</p>;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export default function Page() {
return <p data-testid='page-name'>switched</p>;
}
1 change: 1 addition & 0 deletions integration/tests/sign-out-smoke.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ testAgainstRunningApps({ withEnv: [appConfigs.envs.withEmailCodes] })('sign out
await u.page.getByRole('button', { name: 'Open user menu' }).click();

await u.page.getByRole('menuitem', { name: 'Sign out' }).click();
await u.po.expect.toBeSignedOut();
await u.page.getByRole('link', { name: 'Protected', exact: true }).click();
await u.page.waitForURL(url => url.href.includes('/sign-in?redirect_url'));
});
Expand Down
Loading
Loading