Skip to content

Commit

Permalink
ci: get ci tests passing (#61)
Browse files Browse the repository at this point in the history
* 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>
  • Loading branch information
field123 and github-actions[bot] authored Sep 24, 2023
1 parent d6dfbd9 commit 7c78031
Show file tree
Hide file tree
Showing 16 changed files with 59 additions and 39 deletions.
5 changes: 5 additions & 0 deletions .changeset/spotty-years-beg.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@elasticpath/d2c-schematics": patch
---

fixed prettier formatting
4 changes: 3 additions & 1 deletion .github/workflows/generate-examples.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion examples/algolia/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion examples/algolia/src/components/header/cart/CartMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export default function CartMenu(): JSX.Element {
const stateItems = resolveStateCartItems(state);

function resolveStateCartItems(
state: CartState
state: CartState,
): ReadonlyNonEmptyArray<RefinedCartItem> | undefined {
const presentCartState = getPresentCartState(state);
return presentCartState && presentCartState.items;
Expand Down
8 changes: 5 additions & 3 deletions examples/basic/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
@@ -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,
});
Expand Down
2 changes: 0 additions & 2 deletions examples/basic/src/components/header/Header.tsx
Original file line number Diff line number Diff line change
@@ -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";
Expand Down Expand Up @@ -30,7 +29,6 @@ const Header = ({ nav }: IHeader): JSX.Element => {
<NavBar nav={nav} headerPadding={headerPadding} />
</div>
<div className="flex items-center self-center">

<CartMenu />
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion examples/basic/src/components/header/cart/CartMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export default function CartMenu(): JSX.Element {
const stateItems = resolveStateCartItems(state);

function resolveStateCartItems(
state: CartState
state: CartState,
): ReadonlyNonEmptyArray<RefinedCartItem> | undefined {
const presentCartState = getPresentCartState(state);
return presentCartState && presentCartState.items;
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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/*'",
Expand Down
Original file line number Diff line number Diff line change
@@ -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,
});
Expand Down
Original file line number Diff line number Diff line change
@@ -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";
Expand Down Expand Up @@ -29,8 +29,8 @@ const Header = ({ nav }: IHeader): JSX.Element => {
<div className="w-full max-w-base-max-width">
<NavBar nav={nav} headerPadding={headerPadding} />
</div>
<div className="flex items-center self-center">
<% if (search) { %><SearchModal /><% } %>
<div className="flex items-center self-center"><% if (search) { %>
<SearchModal /><% } %>
<CartMenu />
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export default function CartMenu(): JSX.Element {
const stateItems = resolveStateCartItems(state);

function resolveStateCartItems(
state: CartState
state: CartState,
): ReadonlyNonEmptyArray<RefinedCartItem> | undefined {
const presentCartState = getPresentCartState(state);
return presentCartState && presentCartState.items;
Expand Down
6 changes: 3 additions & 3 deletions packages/d2c-schematics/utility/latest-versions/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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'] %>",
Expand Down
6 changes: 6 additions & 0 deletions turbo.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@
"test:e2e": {
"outputs": []
},
"build:e2e": {
"outputs": []
},
"start:e2e": {
"outputs": []
},
"start": {
"outputs": []
},
Expand Down
16 changes: 8 additions & 8 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 7c78031

Please sign in to comment.