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(); }); });