From 7c780314e710c6db6b8359286677fbf212b57b7b Mon Sep 17 00:00:00 2001 From: Robert Field Date: Sun, 24 Sep 2023 15:31:09 +0100 Subject: [PATCH] ci: get ci tests passing (#61) * feat: disable advanced stripe fraud signals to try and resolve e2e fails in ci * feat: examples for disable advanced stripe fraud signals to try and resolve e2e fails in ci * feat: ci testing * chore: generated latest examples * feat: ci testing * feat: ci testing * feat: attempted fix for prettier formatting * feat: added build e2e scripts * feat: examples generated for added build e2e scripts * feat: ci build * feat: ci build * feat: clean up * chore: changeset --------- Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com> --- .changeset/spotty-years-beg.md | 5 +++++ .github/workflows/generate-examples.yml | 4 +++- examples/algolia/package.json | 4 +++- .../src/components/header/cart/CartMenu.tsx | 2 +- examples/basic/package.json | 8 +++++--- .../checkout/payments/EpStripePayment.tsx | 13 +++++++------ examples/basic/src/components/header/Header.tsx | 2 -- .../src/components/header/cart/CartMenu.tsx | 2 +- package.json | 3 ++- .../payments/EpStripePayment.tsx.template | 13 +++++++------ .../src/components/header/Header.tsx.template | 8 ++++---- .../components/header/cart/CartMenu.tsx.template | 2 +- .../utility/latest-versions/package.json | 6 +++--- .../workspace/files/package.json.template | 4 +++- turbo.json | 6 ++++++ yarn.lock | 16 ++++++++-------- 16 files changed, 59 insertions(+), 39 deletions(-) create mode 100644 .changeset/spotty-years-beg.md diff --git a/.changeset/spotty-years-beg.md b/.changeset/spotty-years-beg.md new file mode 100644 index 00000000..0a83917a --- /dev/null +++ b/.changeset/spotty-years-beg.md @@ -0,0 +1,5 @@ +--- +"@elasticpath/d2c-schematics": patch +--- + +fixed prettier formatting diff --git a/.github/workflows/generate-examples.yml b/.github/workflows/generate-examples.yml index 91aab074..527056c2 100644 --- a/.github/workflows/generate-examples.yml +++ b/.github/workflows/generate-examples.yml @@ -135,9 +135,11 @@ jobs: - name: Make .env.test file run: | echo "${{ secrets.TEST_ENV_FILE }}" > .env.test + echo NEXT_PUBLIC_CI=true >> .env.test + echo NEXT_PUBLIC_CI=true >> ./examples/basic/.env.test - name: Build everything - run: yarn build + run: yarn build:e2e - name: Install playwright browsers run: npx playwright install --with-deps diff --git a/examples/algolia/package.json b/examples/algolia/package.json index f5e2c7a4..c5028e14 100644 --- a/examples/algolia/package.json +++ b/examples/algolia/package.json @@ -15,7 +15,9 @@ "test:coverage": "vitest run --coverage", "test:watch": "vitest", "test:ci:e2e": "NODE_ENV=test yarn build && (yarn start & (sleep 5 && npx playwright install --with-deps && yarn test:e2e && kill $(lsof -t -i tcp:3000)))", - "test:e2e": "NODE_ENV=test playwright test" + "test:e2e": "NODE_ENV=test playwright test", + "build:e2e": "NODE_ENV=test next build", + "start:e2e": "NODE_ENV=test next start" }, "dependencies": { "@algolia/react-instantsearch-widget-color-refinement-list": "^1.4.7", diff --git a/examples/algolia/src/components/header/cart/CartMenu.tsx b/examples/algolia/src/components/header/cart/CartMenu.tsx index deaec661..cba3f72c 100644 --- a/examples/algolia/src/components/header/cart/CartMenu.tsx +++ b/examples/algolia/src/components/header/cart/CartMenu.tsx @@ -16,7 +16,7 @@ export default function CartMenu(): JSX.Element { const stateItems = resolveStateCartItems(state); function resolveStateCartItems( - state: CartState + state: CartState, ): ReadonlyNonEmptyArray | undefined { const presentCartState = getPresentCartState(state); return presentCartState && presentCartState.items; diff --git a/examples/basic/package.json b/examples/basic/package.json index c6b66838..953cdd00 100644 --- a/examples/basic/package.json +++ b/examples/basic/package.json @@ -15,15 +15,17 @@ "test:coverage": "vitest run --coverage", "test:watch": "vitest", "test:ci:e2e": "NODE_ENV=test yarn build && (yarn start & (sleep 5 && npx playwright install --with-deps && yarn test:e2e && kill $(lsof -t -i tcp:3000)))", - "test:e2e": "NODE_ENV=test playwright test" + "test:e2e": "NODE_ENV=test playwright test", + "build:e2e": "NODE_ENV=test next build", + "start:e2e": "NODE_ENV=test next start" }, "dependencies": { "@elasticpath/react-shopper-hooks": "^0.3.1", "@headlessui/react": "^1.7.17", "@heroicons/react": "^2.0.18", "@moltin/sdk": "^23.3.0", - "@stripe/react-stripe-js": "1.11.0", - "@stripe/stripe-js": "1.38.1", + "@stripe/react-stripe-js": "^2.3.0", + "@stripe/stripe-js": "^2.1.6", "clsx": "^1.2.1", "cookies-next": "^2.1.1", "dequal": "^2.0.3", diff --git a/examples/basic/src/components/checkout/payments/EpStripePayment.tsx b/examples/basic/src/components/checkout/payments/EpStripePayment.tsx index 67270e5b..895160a5 100644 --- a/examples/basic/src/components/checkout/payments/EpStripePayment.tsx +++ b/examples/basic/src/components/checkout/payments/EpStripePayment.tsx @@ -1,15 +1,16 @@ import React from "react"; -import { - Appearance, - loadStripe, - StripeElementsOptions, -} from "@stripe/stripe-js"; -import { Elements } from "@stripe/react-stripe-js"; +import { loadStripe } from "@stripe/stripe-js/pure"; +import type { Appearance, StripeElementsOptions } from "@stripe/stripe-js"; import EpStripePaymentForm from "./EpStripePaymentForm"; import { epPaymentsEnvData } from "../../../lib/resolve-ep-stripe-env"; import styles from "./EpStripePayment.module.css"; import clsx from "clsx"; +loadStripe.setLoadParameters({ + advancedFraudSignals: process.env.NODE_ENV === "test" ? false : true, +}); +import { Elements } from "@stripe/react-stripe-js"; + const stripePromise = loadStripe(epPaymentsEnvData.publishableKey, { stripeAccount: epPaymentsEnvData.accountId, }); diff --git a/examples/basic/src/components/header/Header.tsx b/examples/basic/src/components/header/Header.tsx index 030a698a..77360ac4 100644 --- a/examples/basic/src/components/header/Header.tsx +++ b/examples/basic/src/components/header/Header.tsx @@ -1,5 +1,4 @@ import { NavigationNode } from "../../lib/build-site-navigation"; - import MobileNavBar from "./navigation/MobileNavBar"; import EpIcon from "../../../public/icons/ep-icon.svg"; import NavBar from "./navigation/NavBar"; @@ -30,7 +29,6 @@ const Header = ({ nav }: IHeader): JSX.Element => {
-
diff --git a/examples/basic/src/components/header/cart/CartMenu.tsx b/examples/basic/src/components/header/cart/CartMenu.tsx index deaec661..cba3f72c 100644 --- a/examples/basic/src/components/header/cart/CartMenu.tsx +++ b/examples/basic/src/components/header/cart/CartMenu.tsx @@ -16,7 +16,7 @@ export default function CartMenu(): JSX.Element { const stateItems = resolveStateCartItems(state); function resolveStateCartItems( - state: CartState + state: CartState, ): ReadonlyNonEmptyArray | undefined { const presentCartState = getPresentCartState(state); return presentCartState && presentCartState.items; diff --git a/package.json b/package.json index e4afd8f0..a7e6efac 100644 --- a/package.json +++ b/package.json @@ -8,6 +8,7 @@ ], "scripts": { "build": "turbo run build", + "build:e2e": "turbo run build --filter='./packages/*' && turbo run build:e2e --filter='./examples/*'", "generate": "turbo run generate --parallel --filter=!@elasticpath/composable-common", "dev": "turbo run dev --parallel", "lint": "turbo run lint", @@ -19,7 +20,7 @@ "test": "turbo run test", "test:packages": "turbo run test --filter='./packages/*'", "test:watch": "turbo run test:watch", - "start:e2e": "turbo run start --filter='./examples/basic'", + "start:e2e": "turbo run start:e2e --filter='./examples/basic'", "test:e2e": "NODE_ENV=test yarn start:e2e & (sleep 5 && turbo run test:e2e --filter='./examples/basic' && kill $(lsof -t -i tcp:3000))", "build:cli": "turbo run build --filter=composable-cli...", "build:packages": "turbo run build --filter='./packages/*'", diff --git a/packages/d2c-schematics/ep-payments-payment-gateway/files/src/components/checkout/payments/EpStripePayment.tsx.template b/packages/d2c-schematics/ep-payments-payment-gateway/files/src/components/checkout/payments/EpStripePayment.tsx.template index 67270e5b..895160a5 100644 --- a/packages/d2c-schematics/ep-payments-payment-gateway/files/src/components/checkout/payments/EpStripePayment.tsx.template +++ b/packages/d2c-schematics/ep-payments-payment-gateway/files/src/components/checkout/payments/EpStripePayment.tsx.template @@ -1,15 +1,16 @@ import React from "react"; -import { - Appearance, - loadStripe, - StripeElementsOptions, -} from "@stripe/stripe-js"; -import { Elements } from "@stripe/react-stripe-js"; +import { loadStripe } from "@stripe/stripe-js/pure"; +import type { Appearance, StripeElementsOptions } from "@stripe/stripe-js"; import EpStripePaymentForm from "./EpStripePaymentForm"; import { epPaymentsEnvData } from "../../../lib/resolve-ep-stripe-env"; import styles from "./EpStripePayment.module.css"; import clsx from "clsx"; +loadStripe.setLoadParameters({ + advancedFraudSignals: process.env.NODE_ENV === "test" ? false : true, +}); +import { Elements } from "@stripe/react-stripe-js"; + const stripePromise = loadStripe(epPaymentsEnvData.publishableKey, { stripeAccount: epPaymentsEnvData.accountId, }); diff --git a/packages/d2c-schematics/header/files/src/components/header/Header.tsx.template b/packages/d2c-schematics/header/files/src/components/header/Header.tsx.template index ca7dad0e..7a6e9873 100644 --- a/packages/d2c-schematics/header/files/src/components/header/Header.tsx.template +++ b/packages/d2c-schematics/header/files/src/components/header/Header.tsx.template @@ -1,5 +1,5 @@ -import { NavigationNode } from "../../lib/build-site-navigation"; -<% if (search) { %>import SearchModal from "../search/SearchModal";<% } %> +import { NavigationNode } from "../../lib/build-site-navigation";<% if (search) { %> +import SearchModal from "../search/SearchModal";<% } %> import MobileNavBar from "./navigation/MobileNavBar"; import EpIcon from "../../../public/icons/ep-icon.svg"; import NavBar from "./navigation/NavBar"; @@ -29,8 +29,8 @@ const Header = ({ nav }: IHeader): JSX.Element => {
-
- <% if (search) { %><% } %> +
<% if (search) { %> + <% } %>
diff --git a/packages/d2c-schematics/header/files/src/components/header/cart/CartMenu.tsx.template b/packages/d2c-schematics/header/files/src/components/header/cart/CartMenu.tsx.template index deaec661..cba3f72c 100644 --- a/packages/d2c-schematics/header/files/src/components/header/cart/CartMenu.tsx.template +++ b/packages/d2c-schematics/header/files/src/components/header/cart/CartMenu.tsx.template @@ -16,7 +16,7 @@ export default function CartMenu(): JSX.Element { const stateItems = resolveStateCartItems(state); function resolveStateCartItems( - state: CartState + state: CartState, ): ReadonlyNonEmptyArray | undefined { const presentCartState = getPresentCartState(state); return presentCartState && presentCartState.items; diff --git a/packages/d2c-schematics/utility/latest-versions/package.json b/packages/d2c-schematics/utility/latest-versions/package.json index 3eaa9878..42ee4deb 100644 --- a/packages/d2c-schematics/utility/latest-versions/package.json +++ b/packages/d2c-schematics/utility/latest-versions/package.json @@ -4,7 +4,7 @@ "private": true, "dependencies": { "@moltin/sdk": "^23.3.0", - "@elasticpath/react-shopper-hooks": "^0.3.0", + "@elasticpath/react-shopper-hooks": "^0.3.1", "clsx": "^1.2.1", "cookies-next": "^2.1.1", "dequal": "^2.0.3", @@ -44,8 +44,8 @@ "react-instantsearch-hooks-server": "6.38.1", "react-instantsearch-hooks-web": "6.38.1", "@next/bundle-analyzer": "13.0.4", - "@stripe/react-stripe-js": "1.11.0", - "@stripe/stripe-js": "1.38.1", + "@stripe/react-stripe-js": "^2.3.0", + "@stripe/stripe-js": "^2.1.6", "postcss": "^8.4.30", "prettier-plugin-tailwindcss": "^0.5.4", "tailwindcss": "^3.3.3", diff --git a/packages/d2c-schematics/workspace/files/package.json.template b/packages/d2c-schematics/workspace/files/package.json.template index 4caeeaf0..f3d45d74 100644 --- a/packages/d2c-schematics/workspace/files/package.json.template +++ b/packages/d2c-schematics/workspace/files/package.json.template @@ -15,7 +15,9 @@ "test:coverage": "vitest run --coverage", "test:watch": "vitest", "test:ci:e2e": "NODE_ENV=test yarn build && (yarn start & (sleep 5 && npx playwright install --with-deps && yarn test:e2e && kill $(lsof -t -i tcp:3000)))", - "test:e2e": "NODE_ENV=test playwright test"<% } %> + "test:e2e": "NODE_ENV=test playwright test", + "build:e2e": "NODE_ENV=test next build", + "start:e2e": "NODE_ENV=test next start"<% } %> }, "dependencies": { "@moltin/sdk": "<%= latestVersions['@moltin/sdk'] %>", diff --git a/turbo.json b/turbo.json index d99646a6..7a13d2c4 100644 --- a/turbo.json +++ b/turbo.json @@ -26,6 +26,12 @@ "test:e2e": { "outputs": [] }, + "build:e2e": { + "outputs": [] + }, + "start:e2e": { + "outputs": [] + }, "start": { "outputs": [] }, diff --git a/yarn.lock b/yarn.lock index 57bb8ee9..51365fb7 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4452,17 +4452,17 @@ dependencies: "@sinonjs/commons" "^3.0.0" -"@stripe/react-stripe-js@1.11.0": - version "1.11.0" - resolved "https://registry.yarnpkg.com/@stripe/react-stripe-js/-/react-stripe-js-1.11.0.tgz#67bb1b5ca968351642fbcbac9e234e96411c9d41" - integrity sha512-NDoumqS26/FldY419IGHdc42JGTNI1L0g8RRZvrCtiKWkAtOMn6XDbTYbkLremuy4GQ+MBkoS2IzRzldgn+dtg== +"@stripe/react-stripe-js@^2.3.0": + version "2.3.0" + resolved "https://registry.yarnpkg.com/@stripe/react-stripe-js/-/react-stripe-js-2.3.0.tgz#bfce4ff11b8ad1366c85ff449dc6fc143f409998" + integrity sha512-AOxsvRIXfIh0WkebAfITfCQY6NgnEDg3jOH7KfHGQPjPmcxJ+HFj/EZOEuyflDjlB1iTGPDCqK0MqiQ8LjLbag== dependencies: prop-types "^15.7.2" -"@stripe/stripe-js@1.38.1": - version "1.38.1" - resolved "https://registry.yarnpkg.com/@stripe/stripe-js/-/stripe-js-1.38.1.tgz#67a27380f021931f6e44abeee2b011b8d7f524de" - integrity sha512-v0hF65jEs7tw33JE70E5puJ2fFhpiS2XYwmayupEdjKWavJivycYcZgZKYXAQhTiMgtDgN9YPzqUr86VzVc3Ew== +"@stripe/stripe-js@^2.1.6": + version "2.1.6" + resolved "https://registry.yarnpkg.com/@stripe/stripe-js/-/stripe-js-2.1.6.tgz#569b4257564a151744205e6e12037e4103de17b2" + integrity sha512-QSzqQIcowgap7a40f3a7oUR+59Xet/i8fp1EsnzzwxK5oPRQsCbbLQ4Cd6qM0y1pdZMonFnCrAWayWdE9Lr0iA== "@svgr/babel-plugin-add-jsx-attribute@^6.5.1": version "6.5.1"