From e5c233f9fe4f168f7d8143aa3b1ffc96930008e4 Mon Sep 17 00:00:00 2001 From: nboisteault Date: Mon, 18 Sep 2023 14:31:55 +0200 Subject: [PATCH 1/2] e2e: test nullable bool w/ value map --- tests/end2end/playwright/edition-form.spec.js | 32 ---------- tests/end2end/playwright/edition-form.spec.ts | 59 +++++++++++++++++++ 2 files changed, 59 insertions(+), 32 deletions(-) delete mode 100644 tests/end2end/playwright/edition-form.spec.js create mode 100644 tests/end2end/playwright/edition-form.spec.ts diff --git a/tests/end2end/playwright/edition-form.spec.js b/tests/end2end/playwright/edition-form.spec.js deleted file mode 100644 index 4e70613f9b..0000000000 --- a/tests/end2end/playwright/edition-form.spec.js +++ /dev/null @@ -1,32 +0,0 @@ -// @ts-check -const { test, expect } = require('@playwright/test'); - -test.describe('Edition Form Validation', () => { - - test('Input type number with range and step', async ({ page }) => { - // Go to http://localhost:8130/index.php/view/map?repository=testsrepository&project=form_edition_all_field_type - - const url_form_edition_all = '/index.php/view/map?repository=testsrepository&project=form_edition_all_field_type'; - await page.goto(url_form_edition_all, { waitUntil: 'networkidle' }); - - - // display form - await page.locator('#button-edition').click(); - await page.locator('a#edition-draw').click(); - - // ensure input attributes match with field config defined in project - await expect(page.locator('#jforms_view_edition input[name="integer_field"]')).toHaveAttribute('type','number') - await expect(page.locator('#jforms_view_edition input[name="integer_field"]')).toHaveAttribute('step','5'); - await expect(page.locator('#jforms_view_edition input[name="integer_field"]')).toHaveAttribute('min','-200'); - await expect(page.locator('#jforms_view_edition input[name="integer_field"]')).toHaveAttribute('max','200'); - - // add data - await page.locator('#jforms_view_edition input[name="integer_field"]').fill('50'); - - // submit form - await page.locator('#jforms_view_edition__submit_submit').click(); - // will close & show message - await expect(page.locator('#edition-form-container')).toBeHidden(); - await expect(page.locator('#lizmap-edition-message')).toBeVisible(); - }) -}) \ No newline at end of file diff --git a/tests/end2end/playwright/edition-form.spec.ts b/tests/end2end/playwright/edition-form.spec.ts new file mode 100644 index 0000000000..e25b0cf49a --- /dev/null +++ b/tests/end2end/playwright/edition-form.spec.ts @@ -0,0 +1,59 @@ +import { test, expect } from '@playwright/test'; + +test.beforeEach(async ({ page }) => { + const url = '/index.php/view/map/?repository=testsrepository&project=form_edition_all_field_type'; + await page.goto(url, { waitUntil: 'networkidle' }); +}); + +test.describe('Edition Form Validation', () => { + + test('Input type number with range and step', async ({ page }) => { + // display form + await page.locator('#button-edition').click(); + await page.locator('a#edition-draw').click(); + + // ensure input attributes match with field config defined in project + await expect(page.locator('#jforms_view_edition input[name="integer_field"]')).toHaveAttribute('type','number') + await expect(page.locator('#jforms_view_edition input[name="integer_field"]')).toHaveAttribute('step','5'); + await expect(page.locator('#jforms_view_edition input[name="integer_field"]')).toHaveAttribute('min','-200'); + await expect(page.locator('#jforms_view_edition input[name="integer_field"]')).toHaveAttribute('max','200'); + + // add data + await page.locator('#jforms_view_edition input[name="integer_field"]').fill('50'); + + // submit form + await page.locator('#jforms_view_edition__submit_submit').click(); + // will close & show message + await expect(page.locator('#edition-form-container')).toBeHidden(); + await expect(page.locator('#lizmap-edition-message')).toBeVisible(); + }) + + test('Boolean nullable w/ value map', async ({ page }) => { + + let editFeatureRequestPromise = page.waitForResponse(response => response.url().includes('editFeature')); + + await page.locator('#button-edition').click(); + await page.locator('#edition-layer').selectOption('many_bool_formats_7aa4cb8a_09ae_4a5b_92e4_189a42ca3a2f'); + await page.locator('#edition-draw').click(); + await page.locator('#jforms_view_edition_liz_future_action').selectOption('edit'); + await page.getByLabel('bool_simple_null_vm').selectOption('t'); + await page.locator('#jforms_view_edition__submit_submit').click(); + + await editFeatureRequestPromise; + + // Wait a bit for the UI to refresh + await page.waitForTimeout(300); + + await expect(page.getByLabel('bool_simple_null_vm')).toHaveValue('t'); + + await page.getByLabel('bool_simple_null_vm').selectOption(''); + await page.locator('#jforms_view_edition__submit_submit').click(); + + await editFeatureRequestPromise; + + // Wait a bit for the UI to refresh + await page.waitForTimeout(300); + + await expect(page.getByLabel('bool_simple_null_vm')).toHaveValue(''); + }) +}) \ No newline at end of file From 3081385cedf96bfcd7ec155b9267750e31d4f3b0 Mon Sep 17 00:00:00 2001 From: nboisteault Date: Mon, 18 Sep 2023 14:31:32 +0200 Subject: [PATCH 2/2] Fix: edition w/ nullable boolean and value map Set value was not selected in