Skip to content

Commit

Permalink
fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
mind84 committed Sep 17, 2024
1 parent d7eb2df commit 0033531
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
2 changes: 1 addition & 1 deletion tests/end2end/playwright/edition-form.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -562,7 +562,7 @@ test.describe('Text widget in a form', () => {

// edit the feature
let editFeatureRequestPromise = page.waitForResponse(response => response.url().includes('editFeature'));
await page.locator('.lizmapPopupContent > .lizmapPopupSingleFeature').nth(0).locator("lizmap-feature-toolbar").first().locator(".feature-edit").click();
await page.locator('.feature-toolbar > button:nth-child(5)').click();
await editFeatureRequestPromise;

// the text widgets in the form should be filled as in the popup
Expand Down
19 changes: 10 additions & 9 deletions tests/end2end/playwright/n_to_m_relations.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@ test.describe('N to M relations', () => {
let birdSpotRequestPromise = page.waitForRequest(request => request.method() === 'POST' && request.postData()?.includes('GetFeature') === true);
await page.locator('#nav-tab-attribute-summary').click();
await page.locator('#attribute-layer-list button[value="birds_spots"]').click();
await getFeatureRequestPromise;
await birdSpotRequestPromise;

// open birds attribute table panel
let birdsRequestPromise = page.waitForRequest(request => request.method() === 'POST' && request.postData()?.includes('GetFeature') === true);
await page.locator('#nav-tab-attribute-summary').click();
await page.locator('#attribute-layer-list button[value="birds"]').click();
await getFeatureRequestPromise;
await birdsRequestPromise;

//back to natural areas panel
await page.locator('#nav-tab-attribute-layer-natural_areas').click();
Expand Down Expand Up @@ -71,7 +71,7 @@ test.describe('N to M relations', () => {
// click on first row of main table and open "m" layer attribute table
let firstChildRequestPromise = page.waitForRequest(request => request.method() === 'POST' && request.postData()?.includes('GetFeature') === true);
await attrTable.locator("tbody tr").nth(0).click();
await getFeatureRequestPromise;
await firstChildRequestPromise;

let nRelatedAttrTable = page.locator("#attribute-layer-table-natural_areas-birds");
await expect(attrTable).toHaveCount(1);
Expand Down Expand Up @@ -104,7 +104,7 @@ test.describe('N to M relations', () => {
// change main record
let secondChildRequestPromise = page.waitForRequest(request => request.method() === 'POST' && request.postData()?.includes('GetFeature') === true);
await attrTable.locator("tbody tr").nth(1).click();
await getFeatureRequestPromise;
await secondChildRequestPromise;

// inspect new list of birds
await expect(nRelatedAttrTable.locator("tbody tr")).toHaveCount(3);
Expand Down Expand Up @@ -166,7 +166,7 @@ test.describe('N to M relations', () => {
// unlink bird spot from second natural area record
let unlinkOneToN = page.waitForRequest(request => request.method() === 'POST' && request.url().includes('unlinkChild'));

await oneToNAttrTable.locator("tbody tr").nth(0).locator("td").nth(0).locator("lizmap-feature-toolbar").locator(".feature-toolbar button[data-bs-title='Unlink child']").click();
await oneToNAttrTable.locator("tbody tr").nth(0).locator("td").nth(0).locator("lizmap-feature-toolbar").locator(".feature-toolbar button.feature-unlink").click();
await unlinkOneToN;

// wait for UI to reload properly
Expand Down Expand Up @@ -206,10 +206,11 @@ test.describe('N to M relations', () => {
// fill the form and submit
await page.locator("#jforms_view_edition").getByLabel('Name', { exact: true }).fill("Northern pintail");
await page.locator("#jforms_view_edition").getByLabel('Scientific name', { exact: true }).fill("Anas acuta");
let saveBirdRequestPromise = page.waitForResponse(response => response.url().includes('closeFeature'));
await page.locator('#jforms_view_edition__submit_submit').click({force:true});

await page.locator('#jforms_view_edition__submit_submit').click();

await addBirdsRequestPromise;
await saveBirdRequestPromise;
await page.waitForTimeout(300);

await expect(page.locator("#lizmap-edition-message")).toBeVisible();
await expect(page.locator("#lizmap-edition-message ul.jelix-msg").nth(0)).toHaveText("Data has been saved.");
Expand Down Expand Up @@ -255,7 +256,7 @@ test.describe('N to M relations', () => {
// click on last inserted record and check child attribute table
let naturalAreaChildPromise = page.waitForRequest(request => request.method() === 'POST' && request.postData()?.includes('GetFeature') === true);
await birdsTable.locator("tbody tr").nth(8).click();
await getFeatureRequestPromise;
await naturalAreaChildPromise;

let childNaturalAreasTable = page.locator("#attribute-layer-table-birds-natural_areas");
await expect(childNaturalAreasTable.locator("tbody tr")).toHaveCount(1);
Expand Down

0 comments on commit 0033531

Please sign in to comment.