Skip to content

Commit

Permalink
fix: enforce via env vars
Browse files Browse the repository at this point in the history
  • Loading branch information
federicobadini committed Jun 29, 2023
1 parent 34d1bdb commit 30eeea8
Show file tree
Hide file tree
Showing 13 changed files with 21 additions and 21 deletions.
2 changes: 1 addition & 1 deletion .github/actions/build-test-frontend/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ runs:
- name: Build Next.js
env:
NODE_ENV: test
NEXT_PUBLIC_STRAPI_ORIGIN: http://127.0.0.1:1337
NEXT_PUBLIC_STRAPI_ORIGIN: http://localhost:1337
ALGOLIA_API_KEY: ${{ inputs.ALGOLIA_API_KEY }}
run: cd frontend && pnpm build
shell: bash
2 changes: 1 addition & 1 deletion .github/workflows/jest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@ jobs:
- name: Run Jest tests
run: pnpm test
env:
NEXT_PUBLIC_STRAPI_ORIGIN: http://127.0.0.1:1337
NEXT_PUBLIC_STRAPI_ORIGIN: http://localhost:1337
ALGOLIA_API_KEY: ${{ secrets.ALGOLIA_API_KEY }}
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ jobs:
- name: Run Playwright Tests
env:
NODE_ENV: test
NEXT_PUBLIC_STRAPI_ORIGIN: http://127.0.0.1:1337
NEXT_PUBLIC_STRAPI_ORIGIN: http://localhost:1337
ALGOLIA_API_KEY: ${{ secrets.ALGOLIA_API_KEY }}
run: cd frontend && pnpm playwright:run --project="${{ matrix.project }}"

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/stress_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ jobs:
- name: Run Playwright Tests
env:
NODE_ENV: test
NEXT_PUBLIC_STRAPI_ORIGIN: http://127.0.0.1:1337
NEXT_PUBLIC_STRAPI_ORIGIN: http://localhost:1337
ALGOLIA_API_KEY: ${{ secrets.ALGOLIA_API_KEY }}
run: cd frontend && pnpm playwright:run --project="${{ matrix.project }}" ${{ needs.check-diff.outputs.modified-playwright-tests }} --repeat-each=5

Expand Down Expand Up @@ -117,5 +117,5 @@ jobs:
- name: Run Jest tests
run: for i in {1..5}; do pnpm test -- ${{ needs.check-diff.outputs.modified-jest-tests }}; done
env:
NEXT_PUBLIC_STRAPI_ORIGIN: http://127.0.0.1:1337
NEXT_PUBLIC_STRAPI_ORIGIN: http://localhost:1337
ALGOLIA_API_KEY: ${{ secrets.ALGOLIA_API_KEY }}
4 changes: 2 additions & 2 deletions frontend/.env.development
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
NEXT_PUBLIC_ALGOLIA_APP_ID=XQEP3AD9ZT
NEXT_PUBLIC_IFIXIT_ORIGIN=https://www.cominor.com
NEXT_PUBLIC_APP_ORIGIN=http://127.0.0.1:3000
NEXT_PUBLIC_STRAPI_ORIGIN=http://127.0.0.1:1337
NEXT_PUBLIC_APP_ORIGIN=http://localhost:3000
NEXT_PUBLIC_STRAPI_ORIGIN=http://localhost:1337
NEXT_PUBLIC_SHOPIFY_STOREFRONT_VERSION=2022-10
STRAPI_IMAGE_DOMAIN=ifixit-dev-strapi-uploads.s3.us-west-1.amazonaws.com
NEXT_PUBLIC_SENTRY_DSN=https://[email protected]/6475315
Expand Down
2 changes: 1 addition & 1 deletion frontend/.env.test
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
NEXT_PUBLIC_ALGOLIA_APP_ID=XQEP3AD9ZT
NEXT_PUBLIC_IFIXIT_ORIGIN=https://www.cominor.com
NEXT_PUBLIC_APP_ORIGIN=http://127.0.0.1:3000
NEXT_PUBLIC_APP_ORIGIN=http://localhost:3000
NEXT_PUBLIC_STRAPI_ORIGIN=https://strapi.cominor.com
NEXT_PUBLIC_SHOPIFY_STOREFRONT_VERSION=2022-10
STRAPI_IMAGE_DOMAIN=ifixit-dev-strapi-uploads.s3.us-west-1.amazonaws.com
Expand Down
2 changes: 1 addition & 1 deletion frontend/codegen/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const config: CodegenConfig = {
overwrite: true,
generates: {
'lib/strapi-sdk/generated/sdk.ts': {
schema: 'http://127.0.0.1:1337/graphql',
schema: 'http://localhost:1337/graphql',
documents: 'lib/strapi-sdk/operations/**/*.graphql',
plugins: [
'typescript',
Expand Down
2 changes: 1 addition & 1 deletion frontend/codegen/strapi-schema-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const schemaConfig: CodegenConfig = {
overwrite: true,
generates: {
'lib/strapi-sdk/generated/schema.graphql': {
schema: 'http://127.0.0.1:1337/graphql',
schema: 'http://localhost:1337/graphql',
plugins: ['schema-ast'],
},
},
Expand Down
8 changes: 4 additions & 4 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@
},
"scripts": {
"dev": "concurrently -n \"Next,codegen\" -c \"blue,magenta\" \"pnpm run dev:next\" \"pnpm run dev:codegen\"",
"dev:next": "next dev",
"dev:next": "NODE_OPTIONS=\"--dns-result-order ipv4first\" next dev",
"dev:codegen": "pnpm run codegen:download-strapi-schema && pnpm run codegen:watch",
"codegen:watch": "cross-env DOTENV_CONFIG_PATH=./.env.development graphql-codegen -r dotenv/config --config codegen/config.ts --watch",
"codegen:download-strapi-schema": "cross-env DOTENV_CONFIG_PATH=./.env.development graphql-codegen -r dotenv/config --config codegen/strapi-schema-config.ts",
"codegen:download-shopify-storefront-schema": "node ./lib/shopify-storefront-sdk/generate-schema.js",
"codegen:watch": "cross-env NODE_OPTIONS=\"--dns-result-order ipv4first\" DOTENV_CONFIG_PATH=./.env.development graphql-codegen -r dotenv/config --config codegen/config.ts --watch",
"codegen:download-strapi-schema": "cross-env NODE_OPTIONS=\"--dns-result-order ipv4first\" DOTENV_CONFIG_PATH=./.env.development graphql-codegen -r dotenv/config --config codegen/strapi-schema-config.ts",
"codegen:download-shopify-storefront-schema": "NODE_OPTIONS=\"--dns-result-order ipv4first\" node ./lib/shopify-storefront-sdk/generate-schema.js",
"build": "next build",
"start": "next start",
"type-check": "tsc --pretty --noEmit",
Expand Down
2 changes: 1 addition & 1 deletion frontend/playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ const config: PlaywrightTestConfig = {
/* Maximum time each action such as `click()` can take. Defaults to 0 (no limit). */
actionTimeout: 0,
/* Base URL to use in actions like `await page.goto('/')`. */
baseURL: 'http://127.0.0.1:3000',
baseURL: 'http://localhost:3000',

/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
trace: 'on-first-retry',
Expand Down
2 changes: 1 addition & 1 deletion frontend/tests/playwright/fixtures/custom-nextjs-server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ loadEnvConfig('./', process.env.NODE_ENV !== 'production');
* running the tests.
*/
const isDev = process.env.NODE_ENV !== 'production' && process.env.CI == null;
const hostname = '127.0.0.1';
const hostname = 'localhost';

// Create Next.js instance
const app = next({ dev: isDev, hostname, quiet: true });
Expand Down
8 changes: 4 additions & 4 deletions frontend/tests/playwright/test-fixtures.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,10 @@ export const test = base.extend<
},
],
productPage: async ({ page, baseURL }, use) => {
await use(new ProductPage(page, baseURL ?? 'http://127.0.0.1:3000'));
await use(new ProductPage(page, baseURL ?? 'http://localhost:3000'));
},
partsPage: async ({ page, baseURL }, use) => {
await use(new PartsPage(page, baseURL ?? 'http://127.0.0.1:3000'));
await use(new PartsPage(page, baseURL ?? 'http://localhost:3000'));
},
cartDrawer: async ({ page }, use) => {
await use(new CartDrawer(page));
Expand Down Expand Up @@ -97,8 +97,8 @@ export const test = base.extend<
*/
serverRequestInterceptor: [
async ({ customServer, productPage, partsPage }, use) => {
productPage.updateBaseURL(`http://127.0.0.1:${customServer.port}`);
partsPage.updateBaseURL(`http://127.0.0.1:${customServer.port}`);
productPage.updateBaseURL(`http://localhost:${customServer.port}`);
partsPage.updateBaseURL(`http://localhost:${customServer.port}`);
await use(customServer.serverRequestInterceptor);
},
{ scope: 'test' },
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"install:all": "export $(cat .env.local) && pnpm install && npm run install:backend",
"install:backend": "cd backend && yarn install:all",
"dev:backend": "cd backend && pnpm run dev",
"dev:frontend": "wait-on http://127.0.0.1:1337/_health && cd frontend && npm run dev",
"dev:frontend": "NODE_OPTIONS=\"--dns-result-order ipv4first\" wait-on http://localhost:1337/_health && cd frontend && npm run dev",
"dev": "cross-env FORCE_COLOR=1 npm-run-all -l -p dev:*",
"build:backend": "cd backend && pnpm run build",
"build:frontend": "cd frontend && pnpm run build",
Expand Down

0 comments on commit 30eeea8

Please sign in to comment.