Skip to content

Commit

Permalink
e2e: test nullable bool w/ value map
Browse files Browse the repository at this point in the history
  • Loading branch information
nboisteault authored and github-actions[bot] committed Sep 18, 2023
1 parent 083f98c commit 96dd350
Showing 1 changed file with 59 additions and 0 deletions.
59 changes: 59 additions & 0 deletions tests/end2end/playwright/edition-form.spec.ts
Original file line number Diff line number Diff line change
@@ -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('');
})
})

0 comments on commit 96dd350

Please sign in to comment.