-
Notifications
You must be signed in to change notification settings - Fork 0
Add Shopify checkout Playwright integration test #461
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,9 @@ | ||
| import path from 'path'; | ||
| import { Module } from 'module'; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧹 Nitpick | 🔵 Trivial Make
Apply this diff: -import { Module } from 'module';
+import { Module } from 'node:module';
@@
-const nodePathEntries = [path.resolve(__dirname, 'frontend/node_modules'), process.env.NODE_PATH].filter(Boolean) as string[];
+const nodePathEntries = [path.resolve(__dirname, 'frontend/node_modules'), process.env.NODE_PATH]
+ .filter(Boolean) as string[];
if (nodePathEntries.length > 0) {
- process.env.NODE_PATH = nodePathEntries.join(':');
- Module._initPaths();
+ process.env.NODE_PATH = nodePathEntries.join(path.delimiter);
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
+ (Module as any)._initPaths?.();
}Alternatively, avoid Also applies to: 34-38 🤖 Prompt for AI Agents |
||
| import type { PlaywrightTestConfig } from '@playwright/test'; | ||
|
|
||
| const testDir = path.resolve(__dirname, 'frontend/tests/e2e'); | ||
| const frontendTestDir = path.resolve(__dirname, 'frontend/tests/e2e'); | ||
| const shopifyTestDir = path.resolve(__dirname, 'tests'); | ||
| const junitOutputFile = path.resolve(__dirname, 'artifacts/junit.xml'); | ||
| const launchArgs = [ | ||
| '--ignore-gpu-blocklist', | ||
|
|
@@ -10,9 +12,32 @@ const launchArgs = [ | |
| '--disable-gpu-sandbox', | ||
| ]; | ||
|
|
||
| const frontendEnv = { | ||
| NEXT_PUBLIC_BACKEND_HOST: process.env.NEXT_PUBLIC_BACKEND_HOST || 'localhost', | ||
| NEXT_PUBLIC_BACKEND_PORT: process.env.NEXT_PUBLIC_BACKEND_PORT || '3000', | ||
| NEXT_PUBLIC_DISABLE_ENVIRONMENT: 'true', | ||
| NEXT_PUBLIC_DISABLE_MODEL_LOADING: 'true', | ||
| }; | ||
|
|
||
| const sharedUseOptions = { | ||
| headless: true, | ||
| trace: 'retain-on-failure' as const, | ||
| launchOptions: { | ||
| args: launchArgs, | ||
| }, | ||
| }; | ||
|
|
||
| const requestedProjects = collectRequestedProjects(process.argv); | ||
| const skipWebServer = | ||
| requestedProjects.length > 0 && requestedProjects.every((project) => project === 'shopify-integration'); | ||
|
|
||
| const nodePathEntries = [path.resolve(__dirname, 'frontend/node_modules'), process.env.NODE_PATH].filter(Boolean) as string[]; | ||
| if (nodePathEntries.length > 0) { | ||
| process.env.NODE_PATH = nodePathEntries.join(':'); | ||
| Module._initPaths(); | ||
| } | ||
|
|
||
| const config: PlaywrightTestConfig = { | ||
| testDir, | ||
| timeout: 60_000, | ||
| fullyParallel: true, | ||
| expect: { | ||
| timeout: 15_000, | ||
|
|
@@ -22,33 +47,81 @@ const config: PlaywrightTestConfig = { | |
| ['junit', { outputFile: junitOutputFile }], | ||
| ], | ||
| globalSetup: path.resolve(__dirname, 'playwright.global-setup.ts'), | ||
| use: { | ||
| baseURL: process.env.BASE_URL || 'http://localhost:3000', | ||
| headless: true, | ||
| trace: 'retain-on-failure', | ||
| launchOptions: { | ||
| args: launchArgs, | ||
| projects: [ | ||
| { | ||
| name: 'frontend-e2e', | ||
| testDir: frontendTestDir, | ||
| timeout: 60_000, | ||
| use: { | ||
| ...sharedUseOptions, | ||
| baseURL: process.env.BASE_URL || 'http://localhost:3000', | ||
| env: frontendEnv, | ||
| }, | ||
|
Comment on lines
+55
to
+59
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
This will fail type‑checking under
Apply this diff: @@
- use: {
- ...sharedUseOptions,
- baseURL: process.env.BASE_URL || 'http://localhost:3000',
- env: frontendEnv,
- },
+ use: {
+ ...sharedUseOptions,
+ baseURL: process.env.BASE_URL || 'http://localhost:3000',
+ },
@@
- use: {
- ...sharedUseOptions,
- actionTimeout: 0,
- baseURL: process.env.BACKEND_BASE_URL || 'http://localhost:8787',
- env: {
- SHOPIFY_STORE_DOMAIN: process.env.SHOPIFY_STORE_DOMAIN || '',
- SHOPIFY_STOREFRONT_ACCESS_TOKEN: process.env.SHOPIFY_STOREFRONT_ACCESS_TOKEN || '',
- SHOPIFY_STOREFRONT_HELPER_URL: process.env.SHOPIFY_STOREFRONT_HELPER_URL || '',
- SHOPIFY_STOREFRONT_HELPER_TOKEN: process.env.SHOPIFY_STOREFRONT_HELPER_TOKEN || '',
- SHOPIFY_TEST_VARIANT_ID: process.env.SHOPIFY_TEST_VARIANT_ID || '',
- SHOPIFY_TEST_CURRENCY: process.env.SHOPIFY_TEST_CURRENCY || 'USD',
- SHOPIFY_MODULE_CONFIG_TABLE: process.env.SHOPIFY_MODULE_CONFIG_TABLE || 'shopify_module_configurations',
- SHOPIFY_ORDER_TABLE: process.env.SHOPIFY_ORDER_TABLE || 'shopify_orders',
- SUPABASE_URL: process.env.SUPABASE_URL || '',
- SUPABASE_SERVICE_ROLE_KEY: process.env.SUPABASE_SERVICE_ROLE_KEY || '',
- NODE_PATH: [path.resolve(__dirname, 'frontend/node_modules'), process.env.NODE_PATH]
- .filter(Boolean)
- .join(':'),
- },
- },
+ use: {
+ ...sharedUseOptions,
+ actionTimeout: process.env.CI ? 30_000 : 45_000,
+ baseURL: process.env.BACKEND_BASE_URL || 'http://localhost:8787',
+ },Also applies to: 67-86 🤖 Prompt for AI Agents |
||
| }, | ||
| env: { | ||
| NEXT_PUBLIC_BACKEND_HOST: process.env.NEXT_PUBLIC_BACKEND_HOST || 'localhost', | ||
| NEXT_PUBLIC_BACKEND_PORT: process.env.NEXT_PUBLIC_BACKEND_PORT || '3000', | ||
| NEXT_PUBLIC_DISABLE_ENVIRONMENT: 'true', | ||
| NEXT_PUBLIC_DISABLE_MODEL_LOADING: 'true', | ||
| { | ||
| name: 'shopify-integration', | ||
| testDir: shopifyTestDir, | ||
| testMatch: /shopify-checkout\.spec\.ts/, | ||
| timeout: process.env.CI ? 300_000 : 180_000, | ||
| retries: process.env.CI ? 2 : 0, | ||
| use: { | ||
| ...sharedUseOptions, | ||
| actionTimeout: 0, | ||
| baseURL: process.env.BACKEND_BASE_URL || 'http://localhost:8787', | ||
| env: { | ||
| SHOPIFY_STORE_DOMAIN: process.env.SHOPIFY_STORE_DOMAIN || '', | ||
| SHOPIFY_STOREFRONT_ACCESS_TOKEN: process.env.SHOPIFY_STOREFRONT_ACCESS_TOKEN || '', | ||
| SHOPIFY_STOREFRONT_HELPER_URL: process.env.SHOPIFY_STOREFRONT_HELPER_URL || '', | ||
| SHOPIFY_STOREFRONT_HELPER_TOKEN: process.env.SHOPIFY_STOREFRONT_HELPER_TOKEN || '', | ||
| SHOPIFY_TEST_VARIANT_ID: process.env.SHOPIFY_TEST_VARIANT_ID || '', | ||
| SHOPIFY_TEST_CURRENCY: process.env.SHOPIFY_TEST_CURRENCY || 'USD', | ||
| SHOPIFY_MODULE_CONFIG_TABLE: process.env.SHOPIFY_MODULE_CONFIG_TABLE || 'shopify_module_configurations', | ||
| SHOPIFY_ORDER_TABLE: process.env.SHOPIFY_ORDER_TABLE || 'shopify_orders', | ||
| SUPABASE_URL: process.env.SUPABASE_URL || '', | ||
| SUPABASE_SERVICE_ROLE_KEY: process.env.SUPABASE_SERVICE_ROLE_KEY || '', | ||
| NODE_PATH: [path.resolve(__dirname, 'frontend/node_modules'), process.env.NODE_PATH] | ||
| .filter(Boolean) | ||
| .join(':'), | ||
| }, | ||
| }, | ||
| }, | ||
| }, | ||
| webServer: { | ||
| command: 'npm run dev -- --hostname 0.0.0.0', | ||
| url: 'http://127.0.0.1:3000', | ||
| reuseExistingServer: !process.env.CI, | ||
| timeout: 120_000, | ||
| cwd: path.resolve(__dirname, 'frontend'), | ||
| env: { | ||
| NEXT_PUBLIC_BACKEND_HOST: process.env.NEXT_PUBLIC_BACKEND_HOST || 'localhost', | ||
| NEXT_PUBLIC_BACKEND_PORT: process.env.NEXT_PUBLIC_BACKEND_PORT || '3000', | ||
| NEXT_PUBLIC_DISABLE_ENVIRONMENT: 'true', | ||
| NEXT_PUBLIC_DISABLE_MODEL_LOADING: 'true', | ||
| }, | ||
| }, | ||
| ], | ||
| webServer: skipWebServer | ||
| ? undefined | ||
| : { | ||
| command: 'npm run dev -- --hostname 0.0.0.0', | ||
| url: 'http://127.0.0.1:3000', | ||
| reuseExistingServer: !process.env.CI, | ||
| timeout: 120_000, | ||
| cwd: path.resolve(__dirname, 'frontend'), | ||
| env: frontendEnv, | ||
| }, | ||
| }; | ||
|
|
||
| export default config; | ||
|
|
||
| function collectRequestedProjects(argv: string[]): string[] { | ||
| const names: string[] = []; | ||
| for (let index = 0; index < argv.length; index += 1) { | ||
| const arg = argv[index]; | ||
| if (!arg.startsWith('--project')) { | ||
| continue; | ||
| } | ||
|
|
||
| if (arg === '--project') { | ||
| const value = argv[index + 1]; | ||
| if (value) { | ||
| names.push(value); | ||
| } | ||
| index += 1; | ||
| continue; | ||
| } | ||
|
|
||
| const [, value] = arg.split('='); | ||
| if (value) { | ||
| names.push(value); | ||
| } | ||
| } | ||
|
|
||
| return names; | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧹 Nitpick | 🔵 Trivial
Harden secrets handling for CI (service-role key).
Document safeguards for
SUPABASE_SERVICE_ROLE_KEYand other tokens:shopify-integrationonly.Adding these points here prevents accidental leakage during integration runs.
🤖 Prompt for AI Agents