test: cubrir jornada completa en playwright

This commit is contained in:
mono
2026-10-25 21:46:48 -05:00
parent 6a3352a96c
commit 488f383904
4 changed files with 57 additions and 4 deletions

View File

@@ -3,6 +3,7 @@ import { defineConfig, devices } from '@playwright/test';
export default defineConfig({
testDir: './tests/e2e',
timeout: 30_000,
workers: 1,
use: { baseURL: 'http://127.0.0.1:4173', trace: 'on-first-retry' },
webServer: { command: 'npm run dev -- --host 127.0.0.1 --port 4173', url: 'http://127.0.0.1:4173', reuseExistingServer: true },
projects: [{ name: 'chromium', use: { ...devices['Desktop Chrome'], launchOptions: { executablePath: '/usr/bin/chromium' } } }, { name: 'mobile', use: { ...devices['Pixel 5'], launchOptions: { executablePath: '/usr/bin/chromium' } } }],

View File

@@ -0,0 +1,52 @@
import { expect, test } from '@playwright/test';
test.describe('jornada completa', () => {
test('abre jornada, crea catálogo, registra venta y gasto, y cierra caja', async ({ page }, testInfo) => {
test.skip(testInfo.project.name !== 'chromium', 'El flujo completo se ejecuta una vez en escritorio.');
await page.goto('/inventario');
await page.getByLabel('Nombre del productor').fill('Productor E2E');
await page.getByRole('button', { name: 'Agregar', exact: true }).click();
await expect(page.getByText('Productor E2E')).toBeVisible();
await page.getByRole('combobox', { name: 'Productor' }).click({ force: true });
await page.getByText('Productor E2E', { exact: true }).last().click();
await page.getByLabel(/Nombre\/Presentación/).fill('Producto E2E');
await page.getByLabel('Precio unitario').fill('12000');
await page.getByRole('button', { name: 'Agregar Producto' }).click();
await expect(page.getByText('Producto E2E')).toBeVisible();
await page.getByRole('combobox', { name: 'Producto', exact: true }).first().click({ force: true });
await page.locator('.v-overlay-container .v-list-item').filter({ hasText: 'Producto E2E' }).click();
await page.getByLabel('Cantidad').first().fill('3');
await page.getByRole('button', { name: 'Registrar Ingreso Inicial' }).click();
await expect(page.getByText('Ingreso inicial registrado.')).toBeVisible();
await page.goto('/jornada');
await page.getByLabel('Responsables (separados por coma)').fill('Ana E2E');
await page.getByLabel('Base inicial (efectivo)').fill('10000');
const openDialog = page.waitForEvent('dialog');
await page.getByRole('button', { name: 'Abrir Jornada' }).click();
await (await openDialog).accept();
await expect(page.getByText(/Jornada ABIERTA/)).toBeVisible();
await page.goto('/ventas');
await expect(page.getByText('Disponible: 3')).toBeVisible();
await page.getByText('Producto E2E', { exact: true }).first().click({ force: true });
await expect(page.getByRole('button', { name: /Cobrar/ })).toContainText('12,000');
await page.getByLabel('Efectivo recibido').fill('20000');
await expect(page.getByText('Devuelta: $8,000')).toBeVisible();
await page.getByRole('button', { name: /Cobrar/ }).click();
await expect(page.getByText(/Venta registrada/)).toBeVisible();
await page.goto('/gastos');
await page.getByLabel('Concepto').fill('Bolsas E2E');
await page.getByLabel('Monto').fill('2000');
await page.getByRole('button', { name: 'Registrar gasto' }).click();
await expect(page.getByText('Bolsas E2E')).toBeVisible();
await page.goto('/jornada');
await page.getByLabel('Efectivo contado (obligatorio)').fill('20000');
await page.getByRole('button', { name: 'Cerrar caja y jornada' }).click();
await expect(page.getByText(/Cierre de caja y jornada completado/)).toBeVisible();
});
});

View File

@@ -24,5 +24,5 @@
- [x] 4.5 Dashboard con jornada activa
## 5. Tests Playwright
- [ ] 5.1 Setup Playwright
- [ ] 5.2 Test caso uso completo: abrir jornada, agregar productos, venta múltiple, gastos, cierre
- [x] 5.1 Setup Playwright
- [x] 5.2 Test caso uso completo: abrir jornada, agregar productos, venta múltiple, gastos, cierre

View File

@@ -23,8 +23,8 @@
## 4. Testing
- [x] 4.1 Setup Playwright
- [ ] 4.2 Add realistic service cases for QR, discrepancies, reports, and export
- [ ] 4.3 Test full day browser flow
- [x] 4.2 Add realistic service cases for QR, discrepancies, reports, and export
- [x] 4.3 Test full day browser flow
- [x] 4.4 Test responsive navigation and empty setup state
## 5. Build & Deploy