import { test, expect } from '../support/fixtures'; import { openOrder, fields, selectTestCustomer, fillTestOrder } from '../support/order-page'; test('Auftragserfassung startet ohne JavaScript-Ausnahme', async ({ page, guard }) => { await openOrder(page); expect(guard.knownErrors, 'job_edit.php greift trotz fehlendem window.opener auf top zu').toEqual([]); }); test('Auftragserfassung öffnet vier Frames und verhindert leeres Absenden', async ({ page }) => { const order = await openOrder(page); expect(order.frames().map(f => f.name())).toEqual(expect.arrayContaining(['job_header', 'job_tour', 'job_options', 'job_tour_list'])); const { tour, options } = fields(order); await expect(tour.locator('[name="nameOfPayer"]')).toHaveValue(/Bezahler wählen/); await expect(options.locator('[name="toursubmit"]')).toBeDisabled(); await expect(options.locator('[name="jb_permanent"]')).toBeDisabled(); }); test('Bezahlerauswahl übernimmt die explizite Testkostenstelle', async ({ page }) => { const order = await openOrder(page); await selectTestCustomer(order, 'bezahlerFirmaButton', 'Testkunde Assecutor 1'); await expect(fields(order).tour.locator('[name="nameOfPayer"]')).toHaveValue('Testkunde Assecutor 1'); }); test('Auftragseingang Sonstiges blendet Zusatzfeld ein und räumt es wieder auf', async ({ page }) => { const { tour } = fields(await openOrder(page)); const detail = tour.locator('[name="jb_origin_other"]'); await expect(detail).toBeHidden(); await tour.locator('[title="Auftragseingang sonstiges"]').check(); await expect(detail).toBeVisible(); await detail.fill('UI-TEST ohne Speicherung'); await tour.locator('[title="Auftragseingang per Telefon"]').check(); await expect(detail).toBeHidden(); await expect(detail).toHaveValue(''); }); test('Angebot erzwingt manuelle Disposition und unvollständigen Status', async ({ page }) => { const { options } = fields(await openOrder(page)); await options.locator('[name="jb_offer"]').check(); for (const name of ['jb_status_manual', 'jb_incomplete']) { await expect(options.locator(`[name="${name}"]`)).toBeChecked(); await expect(options.locator(`[name="${name}"]`)).toBeDisabled(); } for (const name of ['afterwards', 'jb_insurance', 'jb_globaljob']) { await expect(options.locator(`[name="${name}"]`)).not.toBeChecked(); await expect(options.locator(`[name="${name}"]`)).toBeDisabled(); } await options.locator('[name="jb_offer"]').uncheck(); for (const name of ['afterwards', 'jb_insurance', 'jb_status_manual', 'jb_incomplete']) { await expect(options.locator(`[name="${name}"]`)).toBeEnabled(); } }); test('Höherversicherung zeigt Warenwert und Tarif und setzt sie beim Abschalten zurück', async ({ page }) => { const { options } = fields(await openOrder(page)); const value = options.locator('[name="jb_value_of_goods"]'); await expect(value).toBeHidden(); await options.locator('[name="jb_insurance"]').check(); await expect(value).toBeVisible(); await value.fill('1234,56'); await options.locator('[name="jb_insurance_rate"]').selectOption('1'); await options.locator('[name="special_case"]').check(); await options.locator('[name="jb_insurance"]').uncheck(); await expect(value).toBeHidden(); await expect(value).toHaveValue(''); await expect(options.locator('[name="jb_insurance_rate"]')).toHaveValue('0'); await expect(options.locator('[name="special_case"]')).not.toBeChecked(); }); for (const [input, message] of [['abc', /Warenwert bitte/], ['500001', /500\.000/], ['12,345', /Warenwert bitte/]] as const) { test(`Höherversicherung weist ungültigen Warenwert ${input} zurück`, async ({ page }) => { const order = await openOrder(page); const { options } = fields(order); await options.locator('[name="jb_insurance"]').check(); const value = options.locator('[name="jb_value_of_goods"]'); await value.fill(input); const alert = order.waitForEvent('dialog'); const blur = value.press('Tab'); const dialog = await alert; expect(dialog.type()).toBe('alert'); expect(dialog.message()).toMatch(message); await dialog.accept(); await blur; await expect(value).toHaveValue(''); await expect(options.locator('[name="toursubmit"]')).toBeDisabled(); }); } test('Stationswechsel vertauscht Firmen, Ansprechpartner und Hinweise', async ({ page }) => { const { tour } = fields(await openOrder(page)); for (const [name, value] of Object.entries({von_cs_comp:'UI-TEST Start', nach_cs_comp:'UI-TEST Ziel', von_tr_person:'Kontakt A', nach_tr_person:'Kontakt B', von_tr_remark:'Hinweis A', nach_tr_remark:'Hinweis B'})) { await tour.locator(`[name="${name}"]`).fill(value); } await tour.locator('[name="switchButton"]').click(); for (const [name, value] of Object.entries({von_cs_comp:'UI-TEST Ziel', nach_cs_comp:'UI-TEST Start', von_tr_person:'Kontakt B', nach_tr_person:'Kontakt A', von_tr_remark:'Hinweis B', nach_tr_remark:'Hinweis A'})) { await expect(tour.locator(`[name="${name}"]`)).toHaveValue(value); } }); for (const [side, name] of [['von', 'waste1Button'], ['nach', 'waste2Button']] as const) { test(`Löschen der ${side}-Station erhält die verbleibende Route`, async ({ page }) => { const order = await openOrder(page); const { tour } = fields(order); await tour.locator('[name="von_cs_comp"]').fill('UI-TEST Start'); await tour.locator('[name="nach_cs_comp"]').fill('UI-TEST Ziel'); await tour.locator(`[name="${name}"]`).click(); await expect(tour.locator('[name="von_cs_comp"]')).toHaveValue(side === 'von' ? 'UI-TEST Ziel' : 'UI-TEST Start'); await expect(tour.locator('[name="nach_cs_comp"]')).toHaveValue(''); }); } test('Manuelle Disposition und unvollständig sind ohne Speichern auswählbar', async ({ page }) => { const { options } = fields(await openOrder(page)); await options.locator('[name="jb_status_manual"]').check(); await options.locator('[name="jb_incomplete"]').check(); await expect(options.locator('[name="jb_status_manual"]')).toBeChecked(); await expect(options.locator('[name="jb_incomplete"]')).toBeChecked(); await expect(options.locator('[name="toursubmit"]')).toBeDisabled(); }); test('Vollständiger Testauftrag wird absendebereit, aber noch nicht gespeichert', async ({ page }, info) => { const order = await openOrder(page); await fillTestOrder(order, 'UI-TEST-VORSCHAU'); const {options,tour}=fields(order); await expect(tour.locator('[name="von_cs_comp"]')).toHaveValue('Testkunde Assecutor 1'); await expect(tour.locator('[name="nach_cs_comp"]')).toHaveValue('Testkunde Assecutor 2'); await expect(options.locator('[name="jb_fixprice"]')).toHaveValue('10,00'); await expect(options.locator('[name="csc_id_payer"]')).toHaveValue('878914'); await expect(options.locator('[name="sendmail"]')).toHaveValue('0'); await order.screenshot({path:info.outputPath('testauftrag-vorbereitet.png'),fullPage:true}); });