test(storefront): add initial Playwright E2E setup and smoke test
This commit is contained in:
parent
caa60c68fb
commit
25594ec512
|
|
@ -31,3 +31,8 @@ dist-ssr
|
||||||
# Generated Git Info
|
# Generated Git Info
|
||||||
.git_*_info
|
.git_*_info
|
||||||
|
|
||||||
|
# Playwright & Coverage
|
||||||
|
playwright-report/
|
||||||
|
test-results/
|
||||||
|
coverage/
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,7 @@
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@eslint/js": "^9.0.0",
|
"@eslint/js": "^9.0.0",
|
||||||
|
"@playwright/test": "^1.65.1",
|
||||||
"@tailwindcss/postcss": "^4.0.0",
|
"@tailwindcss/postcss": "^4.0.0",
|
||||||
"@types/node": "^22.0.0",
|
"@types/node": "^22.0.0",
|
||||||
"@types/react": "^19.0.0",
|
"@types/react": "^19.0.0",
|
||||||
|
|
@ -1178,6 +1179,22 @@
|
||||||
"@emnapi/runtime": "^1.7.1"
|
"@emnapi/runtime": "^1.7.1"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/@playwright/test": {
|
||||||
|
"version": "1.65.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/@playwright/test/-/test-1.65.1.tgz",
|
||||||
|
"integrity": "sha512-y+NCIRm2LvY4slUVWvGh1nujJ8RF/hEisIsq2mtUPgdQC4L701bq5hZGMhrpeXjACvwvO9tj5dJqhvM6TP9lbw==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "Apache-2.0",
|
||||||
|
"dependencies": {
|
||||||
|
"playwright": "1.65.1"
|
||||||
|
},
|
||||||
|
"bin": {
|
||||||
|
"playwright": "cli.js"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=20"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/@rolldown/pluginutils": {
|
"node_modules/@rolldown/pluginutils": {
|
||||||
"version": "1.0.0-beta.27",
|
"version": "1.0.0-beta.27",
|
||||||
"resolved": "https://registry.npmjs.org/@rolldown/pluginutils/-/pluginutils-1.0.0-beta.27.tgz",
|
"resolved": "https://registry.npmjs.org/@rolldown/pluginutils/-/pluginutils-1.0.0-beta.27.tgz",
|
||||||
|
|
@ -3966,6 +3983,35 @@
|
||||||
"url": "https://github.com/sponsors/jonschlinkert"
|
"url": "https://github.com/sponsors/jonschlinkert"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/playwright": {
|
||||||
|
"version": "1.65.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/playwright/-/playwright-1.65.1.tgz",
|
||||||
|
"integrity": "sha512-vJ1FuoOrNwOKHUIVEvSt3jT1L+wjjDpwhwIstKtfvTh8XIG4FG4bIFuvNdMxi81LGfAhUgUZleVFaOLY4RIUUw==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "Apache-2.0",
|
||||||
|
"dependencies": {
|
||||||
|
"playwright-core": "1.65.1"
|
||||||
|
},
|
||||||
|
"bin": {
|
||||||
|
"playwright": "cli.js"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=20"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/playwright-core": {
|
||||||
|
"version": "1.65.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/playwright-core/-/playwright-core-1.65.1.tgz",
|
||||||
|
"integrity": "sha512-hqPpz7blSMPxWVdoeE1yiBSzXsKiVOd2k+kjCvmUywD2GPO2Dd9HfcWnq9NN0GHbNZDFgZ9JfBFr+X5/BLo0qw==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "Apache-2.0",
|
||||||
|
"bin": {
|
||||||
|
"playwright-core": "cli.js"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=20"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/postcss": {
|
"node_modules/postcss": {
|
||||||
"version": "8.5.26",
|
"version": "8.5.26",
|
||||||
"resolved": "https://registry.npmjs.org/postcss/-/postcss-8.5.26.tgz",
|
"resolved": "https://registry.npmjs.org/postcss/-/postcss-8.5.26.tgz",
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,11 @@
|
||||||
"dev": "vite",
|
"dev": "vite",
|
||||||
"build": "tsc -b && vite build",
|
"build": "tsc -b && vite build",
|
||||||
"lint": "eslint .",
|
"lint": "eslint .",
|
||||||
"preview": "vite preview"
|
"preview": "vite preview",
|
||||||
|
"test:e2e": "playwright test",
|
||||||
|
"test:e2e:ui": "playwright test --ui",
|
||||||
|
"test:e2e:headed": "playwright test --headed",
|
||||||
|
"test:e2e:report": "playwright show-report"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"axios": "^1.7.0",
|
"axios": "^1.7.0",
|
||||||
|
|
@ -18,6 +22,7 @@
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@eslint/js": "^9.0.0",
|
"@eslint/js": "^9.0.0",
|
||||||
|
"@playwright/test": "^1.65.1",
|
||||||
"@tailwindcss/postcss": "^4.0.0",
|
"@tailwindcss/postcss": "^4.0.0",
|
||||||
"@types/node": "^22.0.0",
|
"@types/node": "^22.0.0",
|
||||||
"@types/react": "^19.0.0",
|
"@types/react": "^19.0.0",
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,32 @@
|
||||||
|
import { defineConfig, devices } from '@playwright/test';
|
||||||
|
|
||||||
|
export default defineConfig({
|
||||||
|
testDir: './tests/e2e',
|
||||||
|
fullyParallel: true,
|
||||||
|
forbidOnly: !!process.env.CI,
|
||||||
|
retries: process.env.CI ? 2 : 0,
|
||||||
|
workers: process.env.CI ? 1 : undefined,
|
||||||
|
reporter: [['list'], ['html', { open: 'never' }]],
|
||||||
|
use: {
|
||||||
|
baseURL: 'http://localhost:3000/store/',
|
||||||
|
trace: 'on-first-retry',
|
||||||
|
screenshot: 'only-on-failure',
|
||||||
|
video: 'retain-on-failure',
|
||||||
|
},
|
||||||
|
projects: [
|
||||||
|
{
|
||||||
|
name: 'chromium-desktop',
|
||||||
|
use: { ...devices['Desktop Chrome'] },
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'chromium-mobile',
|
||||||
|
use: { ...devices['Pixel 5'] },
|
||||||
|
},
|
||||||
|
],
|
||||||
|
webServer: {
|
||||||
|
command: 'npm run dev -- --port 3000',
|
||||||
|
url: 'http://localhost:3000/store/',
|
||||||
|
reuseExistingServer: !process.env.CI,
|
||||||
|
timeout: 60_000,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
@ -0,0 +1,143 @@
|
||||||
|
import type { Page } from '@playwright/test';
|
||||||
|
|
||||||
|
export const MOCK_PLANS = [
|
||||||
|
{
|
||||||
|
code: 'LIFETIME_ALL',
|
||||||
|
name: 'Lifetime All-Access Plan',
|
||||||
|
description: '10 Years access to all modules',
|
||||||
|
plan_type: 'bundle',
|
||||||
|
billing_period: 'lifetime',
|
||||||
|
price_inr: 15000,
|
||||||
|
price_usd: 350,
|
||||||
|
price_eur: 350,
|
||||||
|
is_active: true,
|
||||||
|
module_slugs: ['acupuncture-points', 'scalp-acupuncture', 'ear-acupuncture', 'nutrition', 'auriculotherapy', 'gynecological-disorders'],
|
||||||
|
modules: [],
|
||||||
|
is_featured: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
code: 'POINTS_PACK',
|
||||||
|
name: 'Points Complete Pack (1 Yr)',
|
||||||
|
plan_type: 'bundle',
|
||||||
|
billing_period: 'yearly',
|
||||||
|
price_inr: 900,
|
||||||
|
price_usd: 15,
|
||||||
|
price_eur: 15,
|
||||||
|
is_active: true,
|
||||||
|
module_slugs: ['acupuncture-points', 'scalp-acupuncture', 'ear-acupuncture'],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
code: 'POINTS_ACU',
|
||||||
|
name: 'Acu Points Module (1 Yr)',
|
||||||
|
plan_type: 'one_time',
|
||||||
|
billing_period: 'yearly',
|
||||||
|
price_inr: 300,
|
||||||
|
price_usd: 5,
|
||||||
|
price_eur: 5,
|
||||||
|
is_active: true,
|
||||||
|
module_slugs: ['acupuncture-points'],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
code: 'POINTS_SCALP',
|
||||||
|
name: 'Scalp Points Module (1 Yr)',
|
||||||
|
plan_type: 'one_time',
|
||||||
|
billing_period: 'yearly',
|
||||||
|
price_inr: 100,
|
||||||
|
price_usd: 2,
|
||||||
|
price_eur: 2,
|
||||||
|
is_active: true,
|
||||||
|
module_slugs: ['scalp-acupuncture'],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
code: 'POINTS_EAR',
|
||||||
|
name: 'Ear Points Module (1 Yr)',
|
||||||
|
plan_type: 'one_time',
|
||||||
|
billing_period: 'yearly',
|
||||||
|
price_inr: 200,
|
||||||
|
price_usd: 3,
|
||||||
|
price_eur: 3,
|
||||||
|
is_active: true,
|
||||||
|
module_slugs: ['ear-acupuncture'],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
code: 'PATTERN_CORE',
|
||||||
|
name: 'Pattern Module Access (1 Yr)',
|
||||||
|
plan_type: 'bundle',
|
||||||
|
billing_period: 'yearly',
|
||||||
|
price_inr: 500,
|
||||||
|
price_usd: 10,
|
||||||
|
price_eur: 10,
|
||||||
|
is_active: true,
|
||||||
|
module_slugs: ['eight-principles'],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
code: 'NUTRITION_CORE',
|
||||||
|
name: 'Nutrition Module Access (1 Yr)',
|
||||||
|
plan_type: 'bundle',
|
||||||
|
billing_period: 'yearly',
|
||||||
|
price_inr: 600,
|
||||||
|
price_usd: 15,
|
||||||
|
price_eur: 15,
|
||||||
|
is_active: true,
|
||||||
|
module_slugs: ['nutrition'],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
code: 'THERAPEUTICS_GYNAE',
|
||||||
|
name: 'Therapeutics: Gynecology (1 Yr)',
|
||||||
|
plan_type: 'one_time',
|
||||||
|
billing_period: 'yearly',
|
||||||
|
price_inr: 600,
|
||||||
|
price_usd: 15,
|
||||||
|
price_eur: 15,
|
||||||
|
is_active: true,
|
||||||
|
module_slugs: ['gynecological-disorders'],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
code: 'THERAPEUTICS_EAR',
|
||||||
|
name: 'Therapeutics: Ear reflexology (1 Yr)',
|
||||||
|
plan_type: 'one_time',
|
||||||
|
billing_period: 'yearly',
|
||||||
|
price_inr: 600,
|
||||||
|
price_usd: 15,
|
||||||
|
price_eur: 15,
|
||||||
|
is_active: true,
|
||||||
|
module_slugs: ['auriculotherapy'],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
code: 'THERAPEUTICS_CORE',
|
||||||
|
name: 'Therapeutics Complete Bundle (1 Yr)',
|
||||||
|
plan_type: 'bundle',
|
||||||
|
billing_period: 'yearly',
|
||||||
|
price_inr: 1200,
|
||||||
|
price_usd: 30,
|
||||||
|
price_eur: 30,
|
||||||
|
is_active: true,
|
||||||
|
module_slugs: ['gynecological-disorders', 'auriculotherapy'],
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
export async function mockPublicStoreApis(page: Page) {
|
||||||
|
await page.route('**/api/checkout/config', async (route) => {
|
||||||
|
await route.fulfill({
|
||||||
|
status: 200,
|
||||||
|
contentType: 'application/json',
|
||||||
|
body: JSON.stringify({ razorpay_key_id: 'rzp_test_mock_key' }),
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
await page.route('**/api/plans', async (route) => {
|
||||||
|
await route.fulfill({
|
||||||
|
status: 200,
|
||||||
|
contentType: 'application/json',
|
||||||
|
body: JSON.stringify(MOCK_PLANS),
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
await page.route('**/api/contents/modules', async (route) => {
|
||||||
|
await route.fulfill({
|
||||||
|
status: 200,
|
||||||
|
contentType: 'application/json',
|
||||||
|
body: JSON.stringify({ modules: [] }),
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,22 @@
|
||||||
|
import { test, expect } from '@playwright/test';
|
||||||
|
import { mockPublicStoreApis } from './fixtures/apiMocks';
|
||||||
|
|
||||||
|
test.describe('Storefront Smoke Suite', () => {
|
||||||
|
test.beforeEach(async ({ page }) => {
|
||||||
|
await mockPublicStoreApis(page);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('renders storefront catalog and complete pack badges', async ({ page }) => {
|
||||||
|
await page.goto('./');
|
||||||
|
|
||||||
|
await expect(page.getByRole('heading', { name: 'Unlock Professional TCM Modules' })).toBeVisible();
|
||||||
|
await expect(page.getByText('Points Reference Module')).toBeVisible();
|
||||||
|
await expect(page.getByText('Pattern Diagnosis Module')).toBeVisible();
|
||||||
|
await expect(page.getByText('TCM Nutrition & Dietetics')).toBeVisible();
|
||||||
|
await expect(page.getByText('Clinical Therapeutics')).toBeVisible();
|
||||||
|
await expect(page.getByText('Lifetime Unlimited Access Pass').first()).toBeVisible();
|
||||||
|
|
||||||
|
const badges = page.locator('span', { hasText: /^Complete Pack$/ });
|
||||||
|
expect(await badges.count()).toBeGreaterThanOrEqual(2);
|
||||||
|
});
|
||||||
|
});
|
||||||
Loading…
Reference in New Issue