From 21c898349d2933433cd5868cad9bd1338a77b7d7 Mon Sep 17 00:00:00 2001 From: rldhont Date: Mon, 8 Jul 2024 16:00:57 +0200 Subject: [PATCH] Automatic permalink will be disabled by default After https://github.com/3liz/lizmap-web-client/pull/4586 that added `automatic_permalink` option the default value will be false. --- assets/src/modules/config/Options.js | 2 +- tests/end2end/playwright/theme.spec.js | 71 ++++++++++++++++------ tests/js-units/node/config/options.test.js | 1 + 3 files changed, 55 insertions(+), 19 deletions(-) diff --git a/assets/src/modules/config/Options.js b/assets/src/modules/config/Options.js index 70fa2c3a8f..cde838a777 100644 --- a/assets/src/modules/config/Options.js +++ b/assets/src/modules/config/Options.js @@ -33,7 +33,7 @@ const optionalProperties = { 'hide_numeric_scale_value': {type: 'boolean', default: false}, 'hideGroupCheckbox': { type: 'boolean', default: false }, 'activateFirstMapTheme': { type: 'boolean', default: false }, - 'automatic_permalink': { type: 'boolean', default: true }, + 'automatic_permalink': { type: 'boolean', default: false }, 'wms_single_request_for_all_layers' : { type:'boolean', default: false } }; diff --git a/tests/end2end/playwright/theme.spec.js b/tests/end2end/playwright/theme.spec.js index 5a88ff1635..56adc8aa50 100644 --- a/tests/end2end/playwright/theme.spec.js +++ b/tests/end2end/playwright/theme.spec.js @@ -23,16 +23,9 @@ test.describe('Theme', () => { await page.locator('lizmap-treeview > ul > li:nth-child(2) > div.checked.layer > div.node > div > i').click({ force: true }); expect(await page.locator('#sub-dock select.styleLayer').inputValue()).toBe('style1'); - // The url has been updated + // The url has not been updated const url = new URL(page.url()); - await expect(url.hash).not.toHaveLength(1); - // The decoded hash is - // #3.730872,43.540386,4.017985,43.679557 - // |group1,Les%20quartiers - // |,style1 - // |1,1 - await expect(url.hash).toMatch(/#3.7308\d+,43.5403\d+,4.0179\d+,43.6795\d+\|/) - await expect(url.hash).toContain('|group1,Les%20quartiers|,style1|1,1') + await expect(url.hash).toHaveLength(0); }); test('must display theme2 when selected', async ({ page }) => { @@ -52,16 +45,9 @@ test.describe('Theme', () => { await page.locator('lizmap-treeview > ul > li:nth-child(2) > div.checked.layer > div.node > div > i').click({ force: true }); expect(await page.locator('#sub-dock select.styleLayer').inputValue()).toBe('style2'); - // The url has been updated + // The url has not been updated const url = new URL(page.url()); - await expect(url.hash).not.toHaveLength(0); - // The decoded hash is - // #3.730872,43.540386,4.017985,43.679557 - // |Les%20quartiers|style2|1 - // |style2 - // |1 - await expect(url.hash).toMatch(/#3.7308\d+,43.5403\d+,4.0179\d+,43.6795\d+\|/) - await expect(url.hash).toContain('|Les%20quartiers|style2|1') + await expect(url.hash).toHaveLength(0); }); test('must display theme3 when selected', async ({ page }) => { @@ -116,3 +102,52 @@ test.describe('Theme', () => { }); }); + +test.describe('Theme and automatic permalink', () => { + + test.beforeEach(async ({ page }) => { + // force automatic permalink + await page.route('**/service/getProjectConfig*', async route => { + const response = await route.fetch(); + const json = await response.json(); + json.options['automatic_permalink'] = true; + await route.fulfill({ response, json }); + }); + + const url = '/index.php/view/map/?repository=testsrepository&project=theme'; + await gotoMap(url, page) + }); + + test('must display theme1 at startup', async ({ page }) => { + await expect(page.locator('#theme-selector > ul > li.theme').first()).toHaveClass(/selected/); + + // The url has been updated + const url = new URL(page.url()); + await expect(url.hash).not.toHaveLength(0); + // The decoded hash is + // #3.730872,43.540386,4.017985,43.679557 + // |group1,Les%20quartiers + // |,style1 + // |1,1 + await expect(url.hash).toMatch(/#3.7308\d+,43.5403\d+,4.0179\d+,43.6795\d+\|/) + await expect(url.hash).toContain('|group1,Les%20quartiers|,style1|1,1') + }); + + test('must display theme2 when selected', async ({ page }) => { + // Select theme2 + await page.locator('#theme-selector > button').click() + await page.locator('#theme-selector > ul > li.theme').nth(1).click(); + + // The url has been updated + const url = new URL(page.url()); + await expect(url.hash).not.toHaveLength(0); + // The decoded hash is + // #3.730872,43.540386,4.017985,43.679557 + // |Les%20quartiers|style2|1 + // |style2 + // |1 + await expect(url.hash).toMatch(/#3.7308\d+,43.5403\d+,4.0179\d+,43.6795\d+\|/) + await expect(url.hash).toContain('|Les%20quartiers|style2|1') + }); + +}); diff --git a/tests/js-units/node/config/options.test.js b/tests/js-units/node/config/options.test.js index 8db1de8feb..7b8118ccb9 100644 --- a/tests/js-units/node/config/options.test.js +++ b/tests/js-units/node/config/options.test.js @@ -74,6 +74,7 @@ describe('OptionsConfig', function () { expect(opt.hide_numeric_scale_value).to.be.eq(false) expect(opt.hideGroupCheckbox).to.be.eq(false) expect(opt.activateFirstMapTheme).to.be.eq(false) + expect(opt.automatic_permalink).to.be.eq(false) // Default value for multiple mapScales without use_native_zoom_levels defined expect(opt.use_native_zoom_levels).to.be.eq(false) // Default value for singleWMS option is false (option wms_single_request_for_all_layers not defined)