Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Backport release_3_8] Automatic permalink will be disabled by default #4592

Merged
merged 1 commit into from
Jul 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion assets/src/modules/config/Options.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
};

Expand Down
71 changes: 53 additions & 18 deletions tests/end2end/playwright/theme.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 }) => {
Expand All @@ -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 }) => {
Expand Down Expand Up @@ -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')
});

});
1 change: 1 addition & 0 deletions tests/js-units/node/config/options.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Loading