All checks were successful
Premier test E2E : welcome -> categories -> produit -> ajout panier -> panier -> paiement -> confirmation. Tourne headless dans le conteneur Playwright officiel, contre une stack JETABLE isolee (tests/e2e/run.sh : `-p wakdoe2e`, override container_name + sans port hote, jointe par --add-host). Zero dependance Node/browser sur l'hote, ne touche aucune stack existante. - playwright.config.js (CJS), tests/e2e/borne.spec.js, tests/e2e/run.sh, tests/e2e/docker-compose.e2e.yml (override jetable). - @playwright/test en devDep ; le job CI js-tests skip le download des browsers (PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1, validee : npm ci + 7 tests JS verts). - Hostnames de test en .test (Chromium resout *.localhost en dur vers 127.0.0.1). Etape 1 de l'initiative E2E (lance a la main). Suite : parcours admin, puis job CI.
58 lines
2.7 KiB
JavaScript
58 lines
2.7 KiB
JavaScript
// Parcours E2E borne : welcome -> categories -> produit -> ajout panier -> panier
|
|
// -> paiement -> confirmation. La stack est montee a part (run.sh) ; le panier vit
|
|
// dans localStorage (meme origine), donc on peut naviguer par goto sans perdre l'etat.
|
|
const { test, expect } = require('@playwright/test');
|
|
|
|
test('parcours borne : de l\'accueil a la confirmation de commande', async ({ page }) => {
|
|
|
|
await test.step('accueil -> categories', async () => {
|
|
await page.goto('/index.html');
|
|
await expect(page).toHaveTitle(/Bienvenue/);
|
|
await expect(page.locator('#welcome-heading')).toBeVisible();
|
|
// CTA "sur place" -> categories.html?mode=sur-place
|
|
await page.locator('a[href*="categories.html?mode=sur-place"]').click();
|
|
await expect(page).toHaveURL(/categories\.html/);
|
|
});
|
|
|
|
await test.step('categories -> produits', async () => {
|
|
await expect(page.locator('h1.categories-main__heading')).toBeVisible();
|
|
// Categorie 2 = boissons : produits SIMPLES (la categorie 1 = menus, qui rendent
|
|
// un autre gabarit a slots, sans bouton d'ajout direct).
|
|
await page.locator('a[href="products.html?category=2"]').click();
|
|
await expect(page).toHaveURL(/products\.html\?category=2/);
|
|
});
|
|
|
|
await test.step('produits -> fiche produit', async () => {
|
|
// Cartes rendues par JS depuis le JSON : auto-wait sur la 1re carte.
|
|
const firstCard = page.locator('#products-grid a.product-card').first();
|
|
await expect(firstCard).toBeVisible();
|
|
await firstCard.click();
|
|
await expect(page).toHaveURL(/product\.html\?id=/);
|
|
});
|
|
|
|
await test.step('ajout au panier', async () => {
|
|
const addBtn = page.locator('#add-to-cart-btn');
|
|
await expect(addBtn).toBeVisible();
|
|
await addBtn.click();
|
|
// Feedback visuel "Ajoute !" (page-product.js) ; l'ecriture localStorage est synchrone.
|
|
await expect(addBtn).toHaveText(/Ajoute/);
|
|
});
|
|
|
|
await test.step('panier : recapitulatif', async () => {
|
|
await page.goto('/cart.html');
|
|
await expect(page.locator('#cart-summary')).toBeVisible();
|
|
await expect(page.locator('#cart-list li')).toHaveCount(1);
|
|
// Total calcule, plus le placeholder "—".
|
|
await expect(page.locator('#total-ttc')).not.toHaveText('—');
|
|
await page.locator('#pay-btn').click();
|
|
await expect(page).toHaveURL(/payment\.html/);
|
|
});
|
|
|
|
await test.step('paiement -> confirmation', async () => {
|
|
await page.locator('#pay-card').click();
|
|
await expect(page).toHaveURL(/confirmation\.html/);
|
|
await expect(page.locator('.confirmation-banner__title')).toHaveText(/Commande confirmee/);
|
|
// Numero de commande genere (plus le placeholder).
|
|
await expect(page.locator('#order-number')).not.toHaveText('—');
|
|
});
|
|
});
|