From 89b2c591f029c637d58951e527881a252ec86943 Mon Sep 17 00:00:00 2001 From: Dario Piotrowicz Date: Wed, 2 Oct 2024 10:30:30 +0100 Subject: [PATCH] Revert e2e tests for proper ecommerce logic and the related code changes Previously we would test the application's ecommerce logic, this was somewhat brittle and required minor code changes in the application's code, given these two flaws it seems like it can be better to just avoid this e2e testing altogether This reverts commit 87d7eb858387af83e89548beef06c3e98c47abf8. This reverts commit 8a812bd802e333913d184176d5abbb0075a1cf20. This reverts commit aebcaed69d47b98cfcf26e9a3e29fb9ffef299d2. This reverts commit 4232b73854f4fcece13f84ded23988003fd99f2d. --- .github/workflows/playwright.yml | 9 ------- examples/vercel-commerce/.dev.vars.example | 7 ----- examples/vercel-commerce/e2e/base.spec.ts | 22 ---------------- examples/vercel-commerce/lib/shopify/index.ts | 26 ------------------- examples/vercel-commerce/package.json | 1 - examples/vercel-commerce/wrangler.toml | 9 +++++++ pnpm-lock.yaml | 12 --------- pnpm-workspace.yaml | 1 - 8 files changed, 9 insertions(+), 78 deletions(-) delete mode 100644 examples/vercel-commerce/.dev.vars.example diff --git a/.github/workflows/playwright.yml b/.github/workflows/playwright.yml index 0988531d..473f7011 100644 --- a/.github/workflows/playwright.yml +++ b/.github/workflows/playwright.yml @@ -17,15 +17,6 @@ jobs: run: npm install -g pnpm && pnpm install - name: build all workers run: pnpm -r build:worker - - name: Generate .dev.vars file for vercel-commerce app - run: | - echo 'COMPANY_NAME = "Cloudflare"' >> ./examples/vercel-commerce/.dev.vars - echo 'TWITTER_CREATOR = "@Cloudflare"' >> ./examples/vercel-commerce/.dev.vars - echo 'TWITTER_SITE = "https://www.cloudflare.com/"' >> ./examples/vercel-commerce/.dev.vars - echo 'SITE_NAME = "My Store"' >> ./examples/vercel-commerce/.dev.vars - echo 'SHOPIFY_STORE_DOMAIN="https://graphql.myshopify.com"' >> ./examples/vercel-commerce/.dev.vars - echo 'SHOPIFY_STOREFRONT_ACCESS_TOKEN="${{ secrets.SHOPIFY_STOREFRONT_ACCESS_TOKEN }}"' >> ./examples/vercel-commerce/.dev.vars - echo 'SHOPIFY_REVALIDATION_SECRET=""' >> ./examples/vercel-commerce/.dev.vars - name: Install Playwright browsers run: pnpm run install-playwright - name: Run playwright tests diff --git a/examples/vercel-commerce/.dev.vars.example b/examples/vercel-commerce/.dev.vars.example deleted file mode 100644 index 9ff0463d..00000000 --- a/examples/vercel-commerce/.dev.vars.example +++ /dev/null @@ -1,7 +0,0 @@ -COMPANY_NAME="Vercel Inc." -TWITTER_CREATOR="@vercel" -TWITTER_SITE="https://nextjs.org/commerce" -SITE_NAME="Next.js Commerce" -SHOPIFY_REVALIDATION_SECRET="" -SHOPIFY_STOREFRONT_ACCESS_TOKEN="" -SHOPIFY_STORE_DOMAIN="[your-shopify-store-subdomain].myshopify.com" diff --git a/examples/vercel-commerce/e2e/base.spec.ts b/examples/vercel-commerce/e2e/base.spec.ts index ee8a9dc3..71c7ab8f 100644 --- a/examples/vercel-commerce/e2e/base.spec.ts +++ b/examples/vercel-commerce/e2e/base.spec.ts @@ -1,8 +1,4 @@ import { test, expect } from '@playwright/test'; -import dotenv from 'dotenv'; -import path from 'node:path'; - -dotenv.config({ path: path.resolve(__dirname, '..', '.dev.vars') }); test('the basic layout of the application works as expected', async ({ page }) => { await page.goto('/'); @@ -12,21 +8,3 @@ test('the basic layout of the application works as expected', async ({ page }) = await expect(page.getByRole('link', { name: 'Created by ▲ Vercel' })).toBeVisible(); }); - -test('the actual commerce functionality', async ({ page }) => { - test.skip(!process.env.SHOPIFY_STORE_DOMAIN, 'Populate the .dev.vars file to run the test'); - - await page.goto('/'); - - const hanraShirtLink = page.getByRole('link', { name: 'Hanra Shirt Hanra Shirt $108.' }); - - await hanraShirtLink.click(); - - await expect(page.getByRole('heading', { name: 'Hanra Shirt' })).toBeVisible(); - await expect(page.getByText('SizeSML')).toBeVisible(); - - await page.getByPlaceholder('Search for products...').fill('non-existing-product'); - await page.getByPlaceholder('Search for products...').press('Enter'); - - await expect(page.getByText('There are no products that match')).toBeVisible(); -}); diff --git a/examples/vercel-commerce/lib/shopify/index.ts b/examples/vercel-commerce/lib/shopify/index.ts index afd13c9c..f3954689 100644 --- a/examples/vercel-commerce/lib/shopify/index.ts +++ b/examples/vercel-commerce/lib/shopify/index.ts @@ -205,10 +205,6 @@ const reshapeProducts = (products: ShopifyProduct[]) => { }; export async function createCart(): Promise { - if (!process.env.SHOPIFY_STORE_DOMAIN) { - return {} as Cart; - } - const res = await shopifyFetch({ query: createCartMutation, cache: 'no-store' @@ -262,10 +258,6 @@ export async function updateCart( } export async function getCart(cartId: string | undefined): Promise { - if (!process.env.SHOPIFY_STORE_DOMAIN) { - return undefined; - } - if (!cartId) { return undefined; } @@ -285,10 +277,6 @@ export async function getCart(cartId: string | undefined): Promise { - if (!process.env.SHOPIFY_STORE_DOMAIN) { - return undefined; - } - const res = await shopifyFetch({ query: getCollectionQuery, tags: [TAGS.collections], @@ -309,10 +297,6 @@ export async function getCollectionProducts({ reverse?: boolean; sortKey?: string; }): Promise { - if (!process.env.SHOPIFY_STORE_DOMAIN) { - return []; - } - const res = await shopifyFetch({ query: getCollectionProductsQuery, tags: [TAGS.collections, TAGS.products], @@ -332,10 +316,6 @@ export async function getCollectionProducts({ } export async function getCollections(): Promise { - if (!process.env.SHOPIFY_STORE_DOMAIN) { - return []; - } - const res = await shopifyFetch({ query: getCollectionsQuery, tags: [TAGS.collections] @@ -415,9 +395,6 @@ export async function getPages(): Promise { } export async function getProduct(handle: string): Promise { - if (!process.env.SHOPIFY_STORE_DOMAIN) { - return undefined; - } const res = await shopifyFetch({ query: getProductQuery, tags: [TAGS.products], @@ -450,9 +427,6 @@ export async function getProducts({ reverse?: boolean; sortKey?: string; }): Promise { - if (!process.env.SHOPIFY_STORE_DOMAIN) { - return []; - } const res = await shopifyFetch({ query: getProductsQuery, tags: [TAGS.products], diff --git a/examples/vercel-commerce/package.json b/examples/vercel-commerce/package.json index 106e0bf8..e3e402ba 100644 --- a/examples/vercel-commerce/package.json +++ b/examples/vercel-commerce/package.json @@ -36,7 +36,6 @@ "@types/react": "18.3.3", "@types/react-dom": "18.3.0", "autoprefixer": "^10.4.19", - "dotenv": "catalog:", "postcss": "^8.4.39", "prettier": "3.3.3", "prettier-plugin-tailwindcss": "^0.6.5", diff --git a/examples/vercel-commerce/wrangler.toml b/examples/vercel-commerce/wrangler.toml index 31c8d97d..6335400c 100644 --- a/examples/vercel-commerce/wrangler.toml +++ b/examples/vercel-commerce/wrangler.toml @@ -7,3 +7,12 @@ compatibility_flags = ["nodejs_compat_v2"] # Use the new Workers + Assets to host the static frontend files assets = { directory = ".worker-next/assets", binding = "ASSETS" } + +[vars] +COMPANY_NAME="Vercel Inc." +TWITTER_CREATOR="@vercel" +TWITTER_SITE="https://nextjs.org/commerce" +SITE_NAME="Next.js Commerce" +SHOPIFY_REVALIDATION_SECRET="" +SHOPIFY_STOREFRONT_ACCESS_TOKEN="" +SHOPIFY_STORE_DOMAIN="[your-shopify-store-subdomain].myshopify.com" \ No newline at end of file diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index c65de10e..69ba3d0d 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -24,9 +24,6 @@ catalogs: '@types/react-dom': specifier: ^18 version: 18.3.0 - dotenv: - specifier: ^16.4.5 - version: 16.4.5 esbuild: specifier: ^0.23.0 version: 0.23.1 @@ -209,9 +206,6 @@ importers: autoprefixer: specifier: ^10.4.19 version: 10.4.20(postcss@8.4.47) - dotenv: - specifier: 'catalog:' - version: 16.4.5 postcss: specifier: ^8.4.39 version: 8.4.47 @@ -1795,10 +1789,6 @@ packages: resolution: {integrity: sha512-35mSku4ZXK0vfCuHEDAwt55dg2jNajHZ1odvF+8SSr82EsZY4QmXfuWso8oEd8zRhVObSN18aM0CjSdoBX7zIw==} engines: {node: '>=0.10.0'} - dotenv@16.4.5: - resolution: {integrity: sha512-ZmdL2rui+eB2YwhsWzjInR8LldtZHGDoQ1ugH85ppHKwpUHL7j7rN0Ti9NCnGiQbhaZ11FpR+7ao1dNsmduNUg==} - engines: {node: '>=12'} - eastasianwidth@0.2.0: resolution: {integrity: sha512-I88TYZWc9XiYHRQ4/3c5rjjfgkjhLyW2luGIheGERbNQ6OY7yTybanSpDXZa8y7VUP9YmDcYa+eyq4ca7iLqWA==} @@ -4848,8 +4838,6 @@ snapshots: dependencies: esutils: 2.0.3 - dotenv@16.4.5: {} - eastasianwidth@0.2.0: {} electron-to-chromium@1.5.29: {} diff --git a/pnpm-workspace.yaml b/pnpm-workspace.yaml index 3da33483..fa513fa4 100644 --- a/pnpm-workspace.yaml +++ b/pnpm-workspace.yaml @@ -25,4 +25,3 @@ catalog: "typescript-eslint": ^8.7.0 "eslint-plugin-unicorn": ^55.0.0 "package-manager-detector": ^0.2.0 - "dotenv": ^16.4.5