test: cubrir jornada completa en playwright
This commit is contained in:
@@ -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' } } }],
|
||||
|
||||
52
apps/toldo-app/tests/e2e/full-day.spec.ts
Normal file
52
apps/toldo-app/tests/e2e/full-day.spec.ts
Normal 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();
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user