diff --git a/apps/system-e2e/src/tests/judicial-system/regression/indictment-tests.spec.ts b/apps/system-e2e/src/tests/judicial-system/regression/indictment-tests.spec.ts index cf7494c3b0a3..a326c4f204fd 100644 --- a/apps/system-e2e/src/tests/judicial-system/regression/indictment-tests.spec.ts +++ b/apps/system-e2e/src/tests/judicial-system/regression/indictment-tests.spec.ts @@ -6,7 +6,8 @@ import { test } from '../utils/judicialSystemTest' import { randomPoliceCaseNumber, getDaysFromNow, - uploadDocument, + randomIndictmentCourtCaseNumber, + chooseDocument, } from '../utils/helpers' test.use({ baseURL: urls.judicialSystemBaseUrl }) @@ -21,6 +22,8 @@ test.describe.serial('Indictment tests', () => { const page = prosecutorPage const today = getDaysFromNow() + const policeCaseNumber = randomPoliceCaseNumber() + // Case list await page.goto('/krofur') await page.getByRole('button', { name: 'Nýtt mál' }).click() @@ -29,9 +32,10 @@ test.describe.serial('Indictment tests', () => { // New indictment case await page.getByTestId('policeCaseNumber0').click() - await page.getByTestId('policeCaseNumber0').fill(randomPoliceCaseNumber()) + await page.getByTestId('policeCaseNumber0').fill(policeCaseNumber) + await page.getByText('Sakarefni *Veldu sakarefni').click() - await page.locator('#react-select-case-type-option-0').click() + await page.getByRole('option', { name: 'Umferðarlagabrot' }).click() await page.getByPlaceholder('Sláðu inn vettvang').click() await page.getByPlaceholder('Sláðu inn vettvang').fill('Reykjavík') await page.locator('input[id=arrestDate]').fill(today) @@ -70,50 +74,69 @@ test.describe.serial('Indictment tests', () => { ]) // Processing + await Promise.all([ expect(page).toHaveURL(`/akaera/malsmedferd/${caseId}`), verifyRequestCompletion(page, '/api/graphql', 'Case'), ]) + await Promise.all([ page.getByText('Játar sök').click(), verifyRequestCompletion(page, '/api/graphql', 'UpdateDefendant'), ]) + await Promise.all([ page.getByText('Nei').last().click(), verifyRequestCompletion(page, '/api/graphql', 'UpdateCase'), ]) + await Promise.all([ page.getByTestId('continueButton').click(), verifyRequestCompletion(page, '/api/graphql', 'Case'), ]) + // Indictment - // Case files - await expect(page).toHaveURL(`/akaera/domskjol/${caseId}`) + await Promise.all([ + expect(page).toHaveURL(`/akaera/akaera/${caseId}`), + verifyRequestCompletion(page, '/api/graphql', 'CreateIndictmentCount'), + ]) - await uploadDocument( - page, - async () => { - await page - .getByText( - 'Ákæra *Dragðu gögn hingað til að hlaða uppVelja gögn til að hlaða upp', - ) - .click() - }, - 'TestAkaera.pdf', - ) - await uploadDocument( - page, - async () => { - await page - .getByText( - 'SakavottorðDragðu gögn hingað til að hlaða uppVelja gögn til að hlaða upp', - ) - .click() - }, - 'TestSakavottord.pdf', - ) + await page.getByText('LÖKE málsnúmer *Veldu málsnú').click() + + await Promise.all([ + page.getByRole('option', { name: `${policeCaseNumber}` }).click(), + verifyRequestCompletion(page, '/api/graphql', 'UpdateIndictmentCount'), + ]) + + await page.getByPlaceholder('AB123').fill('AB123') + + await Promise.all([ + page.keyboard.press('Tab'), + verifyRequestCompletion(page, '/api/graphql', 'UpdateIndictmentCount'), + ]) - await Promise.all([page.getByTestId('continueButton').click()]) + await Promise.all([ + page.getByText('Brot *Veldu brot').click(), + page.getByRole('option', { name: 'Sviptingarakstur' }).click(), + verifyRequestCompletion(page, '/api/graphql', 'UpdateIndictmentCount'), + ]) + + await Promise.all([ + page.getByLabel('Krefjast sviptingarKrefjast').check(), + verifyRequestCompletion(page, '/api/graphql', 'UpdateCase'), + ]) + + await Promise.all([ + page.getByTestId('continueButton').click(), + verifyRequestCompletion(page, '/api/graphql', 'Case'), + ]) + + // Case files + await expect(page).toHaveURL(`/akaera/domskjol/${caseId}`) + await Promise.all([ + page.getByTestId('continueButton').click(), + verifyRequestCompletion(page, '/api/graphql', 'Case'), + ]) // Overview await expect(page).toHaveURL(`/akaera/stadfesta/${caseId}`) @@ -145,4 +168,121 @@ test.describe.serial('Indictment tests', () => { verifyRequestCompletion(page, '/api/graphql', 'TransitionCase'), ]) }) + + test('judge should receive indictment case', async ({ judgePage }) => { + const page = judgePage + const nextWeek = getDaysFromNow(7) + + // Case list + await page.goto('/krofur') + await page.getByText(accusedName).click() + + // Indictment Overview + await expect(page).toHaveURL(`domur/akaera/yfirlit/${caseId}`) + + await Promise.all([ + page.getByTestId('continueButton').click(), + verifyRequestCompletion(page, '/api/graphql', 'Case'), + ]) + + // Reception and assignment + await expect(page).toHaveURL(`domur/akaera/mottaka/${caseId}`) + + await page + .getByTestId('courtCaseNumber') + .fill(randomIndictmentCourtCaseNumber()) + await page.keyboard.press('Tab') + + await page.getByText('Veldu dómara/aðstoðarmann').click() + await page + .getByTestId('select-judge') + .getByText('Test Dómari') + .last() + .click() + + await Promise.all([ + page.getByTestId('continueButton').click(), + verifyRequestCompletion(page, '/api/graphql', 'Case'), + ]) + + // Subpoena + await expect(page).toHaveURL(`domur/akaera/fyrirkall/${caseId}`) + + await page + .locator('label') + .filter({ hasText: 'Útivistarfyrirkall' }) + .click() + + await page.locator('input[id=courtDate]').fill(nextWeek) + await page.keyboard.press('Escape') + + await page.getByTestId('courtDate-time').fill('11:00') + await page.getByTestId('courtroom').press('Tab') + + await page.getByTestId('courtroom').fill('12') + await page.getByTestId('courtroom').press('Tab') + + await page.getByTestId('continueButton').click() + await page.getByTestId('modalPrimaryButton').click() + + // Advocates and civil claimants + await expect(page).toHaveURL(`domur/akaera/malflytjendur/${caseId}`) + + await page + .locator('label') + .filter({ hasText: 'Ákærði óskar ekki eftir að sé' }) + .click() + await page.getByRole('button', { name: 'Staðfesta val' }).click() + await page.getByTestId('modalPrimaryButton').click() + + await Promise.all([ + page.getByTestId('continueButton').click(), + verifyRequestCompletion(page, '/api/graphql', 'Case'), + ]) + + // Conclusion + await expect(page).toHaveURL(`domur/akaera/nidurstada/${caseId}`) + + await page.locator('label').filter({ hasText: 'Lokið' }).click() + await page.locator('label').filter({ hasText: 'Dómur' }).click() + + await chooseDocument( + page, + async () => { + await page + .getByRole('button', { name: 'Velja gögn til að hlaða upp' }) + .nth(1) + .click() + }, + 'TestThingbok.pdf', + ) + await chooseDocument( + page, + async () => { + await page + .getByRole('button', { name: 'Velja gögn til að hlaða upp' }) + .nth(2) + .click() + }, + 'TestDomur.pdf', + ) + + await Promise.all([ + page.getByTestId('continueButton').click(), + verifyRequestCompletion(page, '/api/graphql', 'Case'), + ]) + + // Summary + await expect(page).toHaveURL(`domur/akaera/samantekt/${caseId}`) + + await page.getByTestId('continueButton').click() + await page.getByTestId('modalPrimaryButton').click() + + // Completed case overview + await expect(page).toHaveURL(`domur/akaera/lokid/${caseId}`) + + await page.getByText('Birta skal dómfellda dóminn').click() + await page.getByTestId('continueButton').click() + await page.getByTestId('modalPrimaryButton').click() + }) }) diff --git a/apps/system-e2e/src/tests/judicial-system/utils/helpers.ts b/apps/system-e2e/src/tests/judicial-system/utils/helpers.ts index dd4e89ac3093..01eed8690b40 100644 --- a/apps/system-e2e/src/tests/judicial-system/utils/helpers.ts +++ b/apps/system-e2e/src/tests/judicial-system/utils/helpers.ts @@ -5,8 +5,14 @@ export const randomPoliceCaseNumber = () => { return `007-${new Date().getFullYear()}-${Math.floor(Math.random() * 100000)}` } -export const randomCourtCaseNumber = () => { - return `R-${Math.floor(Math.random() * 1000)}/${new Date().getFullYear()}` +export const randomCourtCaseNumber = (prefix?: string) => { + return `${prefix ?? 'R'}-${Math.floor( + Math.random() * 1000, + )}/${new Date().getFullYear()}` +} + +export const randomIndictmentCourtCaseNumber = () => { + return randomCourtCaseNumber('S') } export const randomAppealCaseNumber = () => {