From 4f6b136dfca9f0842902b7631e47b0600197023e Mon Sep 17 00:00:00 2001 From: panteliselef Date: Thu, 11 Jul 2024 17:13:55 +0300 Subject: [PATCH 1/3] chore(e2e): Test control components for Astro and Astro + React This commit also changes `astro.node.withEmailCodes` to `astro.node.withCustomRoles`. Additionally the `withCustomRoles` now will use the production Backend API --- .changeset/ten-planes-run.md | 2 + integration/presets/envs.ts | 2 - integration/presets/longRunningApps.ts | 2 +- .../astro-node/src/pages/index.astro | 15 +-- .../astro-node/src/pages/react/discover.astro | 14 +++ .../astro-node/src/pages/react/index.astro | 117 ++++++++++++++++++ .../src/pages/react/only-admins.astro | 19 +++ .../src/pages/react/only-members.astro | 19 +++ .../components.test.ts} | 20 ++- integration/tests/astro/protect.test.ts | 49 ++++++++ .../tests/astro/react/components.test.ts | 35 ++++++ integration/tests/astro/react/protect.test.ts | 49 ++++++++ 12 files changed, 326 insertions(+), 17 deletions(-) create mode 100644 .changeset/ten-planes-run.md create mode 100644 integration/templates/astro-node/src/pages/react/discover.astro create mode 100644 integration/templates/astro-node/src/pages/react/index.astro create mode 100644 integration/templates/astro-node/src/pages/react/only-admins.astro create mode 100644 integration/templates/astro-node/src/pages/react/only-members.astro rename integration/tests/{astro.test.ts => astro/components.test.ts} (75%) create mode 100644 integration/tests/astro/protect.test.ts create mode 100644 integration/tests/astro/react/components.test.ts create mode 100644 integration/tests/astro/react/protect.test.ts diff --git a/.changeset/ten-planes-run.md b/.changeset/ten-planes-run.md new file mode 100644 index 00000000000..a845151cc84 --- /dev/null +++ b/.changeset/ten-planes-run.md @@ -0,0 +1,2 @@ +--- +--- diff --git a/integration/presets/envs.ts b/integration/presets/envs.ts index 5d62e882059..54724dc005d 100644 --- a/integration/presets/envs.ts +++ b/integration/presets/envs.ts @@ -44,8 +44,6 @@ const withEmailLinks = environmentConfig() const withCustomRoles = environmentConfig() .setId('withCustomRoles') .setEnvVariable('public', 'CLERK_TELEMETRY_DISABLED', true) - // Temporarily use the stage api until the custom roles feature is released to prod - .setEnvVariable('private', 'CLERK_API_URL', 'https://api.clerkstage.dev') .setEnvVariable('private', 'CLERK_SECRET_KEY', envKeys['with-custom-roles'].sk) .setEnvVariable('public', 'CLERK_PUBLISHABLE_KEY', envKeys['with-custom-roles'].pk) .setEnvVariable('public', 'CLERK_SIGN_IN_URL', '/sign-in') diff --git a/integration/presets/longRunningApps.ts b/integration/presets/longRunningApps.ts index b13eafeefac..e6077faa291 100644 --- a/integration/presets/longRunningApps.ts +++ b/integration/presets/longRunningApps.ts @@ -23,7 +23,7 @@ export const createLongRunningApps = () => { { id: 'next.appRouter.withCustomRoles', config: next.appRouter, env: envs.withCustomRoles }, { id: 'quickstart.next.appRouter', config: next.appRouterQuickstart, env: envs.withEmailCodesQuickstart }, { id: 'elements.next.appRouter', config: elements.nextAppRouter, env: envs.withEmailCodes }, - { id: 'astro.node.withEmailCodes', config: astro.node, env: envs.withEmailCodes }, + { id: 'astro.node.withCustomRoles', config: astro.node, env: envs.withCustomRoles }, ] as const; const apps = configs.map(longRunningApplication); diff --git a/integration/templates/astro-node/src/pages/index.astro b/integration/templates/astro-node/src/pages/index.astro index ae6a9ed78b6..b3d2a4e0a19 100644 --- a/integration/templates/astro-node/src/pages/index.astro +++ b/integration/templates/astro-node/src/pages/index.astro @@ -3,7 +3,7 @@ import Layout from "../layouts/Layout.astro"; import Card from "../components/Card.astro"; import SignOutButton from "../lib/astro-components/SignOutButton.astro"; -import { SignedIn, SignedOut } from "@clerk/astro/client/react"; +import { SignedIn, SignedOut } from "@clerk/astro/components/control"; import { OrganizationSwitcher } from "@clerk/astro/components/interactive"; --- @@ -24,17 +24,12 @@ import { OrganizationSwitcher } from "@clerk/astro/components/interactive";
-

- To get started, open the directory src/pages in your project.
- Code Challenge: Tweak the "Welcome to Astro" message above. -