mirror of
https://github.com/vercel/commerce.git
synced 2025-05-15 14:06:59 +00:00
Removes e2e tests (#1091)
This commit is contained in:
parent
c1b5de6c60
commit
764bc67fba
49
.github/workflows/e2e.yml
vendored
49
.github/workflows/e2e.yml
vendored
@ -1,49 +0,0 @@
|
||||
name: e2e
|
||||
on:
|
||||
schedule:
|
||||
# Runs "at 09:00 and 15:00, Monday through Friday" (see https://crontab.guru)
|
||||
- cron: '0 9,15 * * 1-5'
|
||||
jobs:
|
||||
e2e:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Cancel running workflows
|
||||
uses: styfle/cancel-workflow-action@0.11.0
|
||||
with:
|
||||
access_token: ${{ github.token }}
|
||||
- name: Checkout repo
|
||||
uses: actions/checkout@v3
|
||||
- name: Set node version
|
||||
uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version-file: '.nvmrc'
|
||||
- name: Set pnpm version
|
||||
uses: pnpm/action-setup@v2
|
||||
with:
|
||||
run_install: false
|
||||
version: 7
|
||||
- name: Cache node_modules
|
||||
id: node-modules-cache
|
||||
uses: actions/cache@v3
|
||||
with:
|
||||
path: '**/node_modules'
|
||||
key: node-modules-cache-${{ hashFiles('**/pnpm-lock.yaml') }}
|
||||
- name: Install dependencies
|
||||
if: steps.node-modules-cache.outputs.cache-hit != 'true'
|
||||
run: pnpm install
|
||||
- name: Get playwright version
|
||||
run: echo "PLAYWRIGHT_VERSION=$(node -e "console.log(require('./node_modules/@playwright/test/package.json').version)")" >> $GITHUB_ENV
|
||||
- name: Cache playwright
|
||||
uses: actions/cache@v3
|
||||
id: playwright-cache
|
||||
with:
|
||||
path: '~/.cache/ms-playwright'
|
||||
key: playwright-cache-${{ env.PLAYWRIGHT_VERSION }}
|
||||
- name: Install playwright browsers
|
||||
if: steps.playwright-cache.outputs.cache-hit != 'true'
|
||||
run: npx playwright install --with-deps
|
||||
- name: Install playwright browser dependencies
|
||||
if: steps.playwright-cache.outputs.cache-hit == 'true'
|
||||
run: npx playwright install-deps
|
||||
- name: Run tests
|
||||
run: pnpm test:e2e
|
@ -1,73 +0,0 @@
|
||||
import { test, expect } from '@playwright/test';
|
||||
|
||||
const regex = (text: string) => new RegExp(text, 'gim');
|
||||
|
||||
test('should be able to open and close cart', async ({ page }) => {
|
||||
let cart;
|
||||
|
||||
await page.goto('/');
|
||||
|
||||
await page.getByTestId('open-cart').click();
|
||||
cart = await page.getByTestId('cart');
|
||||
await expect(cart).toBeVisible();
|
||||
await expect(cart).toHaveText(regex('your cart is empty'));
|
||||
|
||||
await page.getByTestId('close-cart').click();
|
||||
cart = await page.getByTestId('cart');
|
||||
await expect(cart).toBeHidden();
|
||||
});
|
||||
|
||||
test('should be able to add item to cart, without selecting a variant, assuming first variant', async ({
|
||||
page
|
||||
}) => {
|
||||
await page.goto('/');
|
||||
await page.getByTestId('homepage-products').locator('a').first().click();
|
||||
|
||||
const productName = await page.getByTestId('product-name').first().innerText();
|
||||
const firstVariant = await page.getByTestId('variant').first().innerText();
|
||||
|
||||
await page.getByRole('button', { name: regex('add to cart') }).click();
|
||||
|
||||
const cart = await page.getByTestId('cart');
|
||||
|
||||
await expect(cart).toBeVisible();
|
||||
|
||||
const cartItems = await page.getByTestId('cart-item').all();
|
||||
let isItemInCart = false;
|
||||
|
||||
for (const item of cartItems) {
|
||||
const cartProductName = await item.getByTestId('cart-product-name').innerText();
|
||||
const cartProductVariant = await item.getByTestId('cart-product-variant').innerText();
|
||||
|
||||
if (cartProductName === productName && cartProductVariant === firstVariant) {
|
||||
isItemInCart = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
await expect(isItemInCart).toBe(true);
|
||||
});
|
||||
|
||||
test('should be able to add item to cart by selecting a variant', async ({ page }) => {
|
||||
await page.goto('/');
|
||||
await page.getByTestId('homepage-products').locator('a').first().click();
|
||||
|
||||
const selectedProductName = await page.getByTestId('product-name').first().innerText();
|
||||
const secondVariant = await page.getByTestId('variant').nth(1);
|
||||
|
||||
await secondVariant.click();
|
||||
const selectedProductVariant = await page.getByTestId('selected-variant').innerText();
|
||||
|
||||
await page.getByRole('button', { name: regex('add to cart') }).click();
|
||||
|
||||
const cart = await page.getByTestId('cart');
|
||||
|
||||
await expect(cart).toBeVisible();
|
||||
|
||||
const cartItem = await page.getByTestId('cart-item').first();
|
||||
const cartItemProductName = await cartItem.getByTestId('cart-product-name').innerText();
|
||||
const cartItemProductVariant = await cartItem.getByTestId('cart-product-variant').innerText();
|
||||
|
||||
await expect(cartItemProductName).toBe(selectedProductName);
|
||||
await expect(cartItemProductVariant).toBe(selectedProductVariant);
|
||||
});
|
@ -1,16 +0,0 @@
|
||||
import { test, expect } from '@playwright/test';
|
||||
|
||||
test.use({ viewport: { width: 600, height: 900 } });
|
||||
test('should be able to open and close mobile menu', async ({ page }) => {
|
||||
let mobileMenu;
|
||||
|
||||
await page.goto('/');
|
||||
|
||||
await page.getByTestId('open-mobile-menu').click();
|
||||
mobileMenu = await page.getByTestId('mobile-menu');
|
||||
await expect(mobileMenu).toBeVisible();
|
||||
|
||||
await page.getByTestId('close-mobile-menu').click();
|
||||
mobileMenu = await page.getByTestId('mobile-menu');
|
||||
await expect(mobileMenu).toBeHidden();
|
||||
});
|
@ -13,8 +13,7 @@
|
||||
"lint-staged": "lint-staged",
|
||||
"prettier": "prettier --write --ignore-unknown .",
|
||||
"prettier:check": "prettier --check --ignore-unknown .",
|
||||
"test": "pnpm lint && pnpm prettier:check",
|
||||
"test:e2e": "playwright test"
|
||||
"test": "pnpm lint && pnpm prettier:check"
|
||||
},
|
||||
"git": {
|
||||
"pre-commit": "lint-staged"
|
||||
@ -31,7 +30,6 @@
|
||||
"react-dom": "18.2.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@playwright/test": "^1.36.1",
|
||||
"@tailwindcss/typography": "^0.5.9",
|
||||
"@types/node": "20.4.2",
|
||||
"@types/react": "18.2.15",
|
||||
|
@ -1,45 +0,0 @@
|
||||
import { PlaywrightTestConfig, devices } from '@playwright/test';
|
||||
import path from 'path';
|
||||
|
||||
const baseURL = `http://localhost:${process.env.PORT || 3000}`;
|
||||
const config: PlaywrightTestConfig = {
|
||||
testDir: path.join(__dirname, 'e2e'),
|
||||
retries: 2,
|
||||
outputDir: '.playwright',
|
||||
webServer: {
|
||||
command: 'pnpm build && pnpm start',
|
||||
url: baseURL,
|
||||
timeout: 120 * 1000,
|
||||
reuseExistingServer: !process.env.CI
|
||||
},
|
||||
use: {
|
||||
baseURL,
|
||||
trace: 'retry-with-trace'
|
||||
},
|
||||
projects: [
|
||||
{
|
||||
name: 'Desktop Chrome',
|
||||
use: {
|
||||
...devices['Desktop Chrome']
|
||||
}
|
||||
},
|
||||
{
|
||||
name: 'Desktop Safari',
|
||||
use: {
|
||||
...devices['Desktop Safari']
|
||||
}
|
||||
},
|
||||
{
|
||||
name: 'Mobile Chrome',
|
||||
use: {
|
||||
...devices['Pixel 5']
|
||||
}
|
||||
},
|
||||
{
|
||||
name: 'Mobile Safari',
|
||||
use: devices['iPhone 12']
|
||||
}
|
||||
]
|
||||
};
|
||||
|
||||
export default config;
|
20
pnpm-lock.yaml
generated
20
pnpm-lock.yaml
generated
@ -21,9 +21,6 @@ dependencies:
|
||||
version: 18.2.0(react@18.2.0)
|
||||
|
||||
devDependencies:
|
||||
'@playwright/test':
|
||||
specifier: ^1.36.1
|
||||
version: 1.36.1
|
||||
'@tailwindcss/typography':
|
||||
specifier: ^0.5.9
|
||||
version: 0.5.9(tailwindcss@3.3.3)
|
||||
@ -348,17 +345,6 @@ packages:
|
||||
tslib: 2.6.0
|
||||
dev: true
|
||||
|
||||
/@playwright/test@1.36.1:
|
||||
resolution: {integrity: sha512-YK7yGWK0N3C2QInPU6iaf/L3N95dlGdbsezLya4n0ZCh3IL7VgPGxC6Gnznh9ApWdOmkJeleT2kMTcWPRZvzqg==}
|
||||
engines: {node: '>=16'}
|
||||
hasBin: true
|
||||
dependencies:
|
||||
'@types/node': 20.4.2
|
||||
playwright-core: 1.36.1
|
||||
optionalDependencies:
|
||||
fsevents: 2.3.2
|
||||
dev: true
|
||||
|
||||
/@rushstack/eslint-patch@1.3.2:
|
||||
resolution: {integrity: sha512-V+MvGwaHH03hYhY+k6Ef/xKd6RYlc4q8WBx+2ANmipHJcKuktNcI/NgEsJgdSUF6Lw32njT6OnrRsKYCdgHjYw==}
|
||||
dev: true
|
||||
@ -2532,12 +2518,6 @@ packages:
|
||||
engines: {node: '>= 6'}
|
||||
dev: true
|
||||
|
||||
/playwright-core@1.36.1:
|
||||
resolution: {integrity: sha512-7+tmPuMcEW4xeCL9cp9KxmYpQYHKkyjwoXRnoeTowaeNat8PoBMk/HwCYhqkH2fRkshfKEOiVus/IhID2Pg8kg==}
|
||||
engines: {node: '>=16'}
|
||||
hasBin: true
|
||||
dev: true
|
||||
|
||||
/pluralize@8.0.0:
|
||||
resolution: {integrity: sha512-Nc3IT5yHzflTfbjgqWcCPpo7DaKy4FnpB0l/zCAW0Tc7jxAiuqSxHasntB3D7887LSrA93kDJ9IXovxJYxyLCA==}
|
||||
engines: {node: '>=4'}
|
||||
|
Loading…
x
Reference in New Issue
Block a user