From 21aa1281836edeb12d60b3d6d373ad5d754cc6d4 Mon Sep 17 00:00:00 2001 From: Roope Jansson <138477077+roope-ankka@users.noreply.github.com> Date: Wed, 12 Jun 2024 11:59:15 +0300 Subject: [PATCH] test: fix date e2e tests (#400) --- e2e/tests/resource-page.spec.ts | 35 ++++++++++++++++++++++----------- 1 file changed, 23 insertions(+), 12 deletions(-) diff --git a/e2e/tests/resource-page.spec.ts b/e2e/tests/resource-page.spec.ts index 7becd725..f863ea65 100644 --- a/e2e/tests/resource-page.spec.ts +++ b/e2e/tests/resource-page.spec.ts @@ -123,23 +123,34 @@ test.describe('Resource page', async () => { test('Add and delete custom holiday - Closed all day', async () => { await page.getByRole('button', { name: 'Muokkaa juhlapyhiä' }).click(); - await page.locator('[data-test="holiday-3-checkbox"]').click(); + + const holidayInput = page + .locator('input[data-test*="holiday-"]:not(:checked):not(:disabled)') + .first(); + const holidayTestId = await holidayInput.getAttribute('data-test'); + + await page.locator(`[data-test="${holidayTestId}"]`).check(); await page.locator('[data-test="submit-opening-hours-button"]').click(); - await expect(page.getByTestId('holiday-form-success')).toBeVisible(); - await page.locator('[data-test="holiday-3-checkbox"]').click(); - await expect( - page.getByRole('heading', { name: 'Oletko varma että haluat' }) - ).toBeVisible(); - await expect( - page.getByText('Olet poistamassa aukiolojakson') - ).toBeVisible(); + await expect(page.getByTestId('holiday-form-success')).toBeVisible({ + timeout: 30 * 1000, + }); + await page.locator(`[data-test="${holidayTestId}"]`).click(); + await expect(page.locator('#confirmation-modal')).toBeVisible(); + await page.getByRole('button', { name: 'Poista', exact: true }).click(); + await expect(page.getByTestId('holiday-form-success')).toBeVisible(); }); test('Add and delete custom holiday - Exceptional opening hours', async () => { await page.getByRole('button', { name: 'Muokkaa juhlapyhiä' }).click(); - await page.locator('[data-test="holiday-1-checkbox"]').click(); + + const holidayInput = page + .locator('input[data-test*="holiday-"]:not(:checked):not(:disabled)') + .first(); + const holidayTestId = await holidayInput.getAttribute('data-test'); + + await page.locator(`[data-test="${holidayTestId}"]`).check(); await page.getByText('Poikkeava aukioloaika').click(); await page.getByLabel('Auki', { exact: true }).click(); await page.getByRole('option', { name: 'Itsepalvelu' }).click(); @@ -149,9 +160,9 @@ test.describe('Resource page', async () => { await page.getByPlaceholder('E.g. seniors').fill('seniors'); await page.locator('[data-test="submit-opening-hours-button"]').click(); await expect(page.getByTestId('holiday-form-success')).toBeVisible({ - timeout: 15000, + timeout: 30 * 1000, }); - await page.locator('[data-test="holiday-1-checkbox"]').click(); + await page.locator(`[data-test="${holidayTestId}"]`).click(); await expect( page.getByRole('heading', { name: 'Oletko varma että haluat' }) ).toBeVisible();