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_7] [Bugfix] Choose a theme drop permalink hash #4156

Merged
merged 1 commit into from
Feb 2, 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
4 changes: 3 additions & 1 deletion assets/src/legacy/switcher-layers-actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,8 @@ var lizLayerActionButtons = function() {
}
);
}
$('#theme-selector.open').click();
return false;
});

// Trigger event with the list of mapThemes
Expand All @@ -302,7 +304,7 @@ var lizLayerActionButtons = function() {
}
);

// Activate first map them on load
// Activate first map theme on load
if ('activateFirstMapTheme' in lizMap.config.options && lizMap.config.options.activateFirstMapTheme == 'True') {
$('#theme-selector li.theme:nth-child(1)').click();
}
Expand Down
24 changes: 23 additions & 1 deletion tests/end2end/playwright/theme.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,17 @@ test.describe('Theme', () => {
// Style
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
const url = new URL(page.url());
await expect(url.hash).not.toHaveLength(1);
// The decoded hash is
// #3.7308717840938743,43.54038574169922,4.017985172062126,43.679557362551954
// |group1,Les%20quartiers
// |,style1
// |1,1
await expect(url.hash).toMatch(/#3.730871\d+,43.540385\d+,4.0179851\d+,43.679557\d+\|/)
await expect(url.hash).toContain('|group1,Les%20quartiers|,style1|1,1')
});

test('must display theme2 when selected', async ({ page }) => {
Expand All @@ -38,5 +49,16 @@ test.describe('Theme', () => {
// Style
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
const url = new URL(page.url());
await expect(url.hash).not.toHaveLength(0);
// The decoded hash is
// #3.731213820800494,43.540385230085235,4.0183280116947415,43.679557742508926
// |Les%20quartiers|style2|1
// |style2
// |1
await expect(url.hash).toMatch(/#3.731213\d+,43.540385\d+,4.018328\d+,43.679557\d+\|/)
await expect(url.hash).toContain('|Les%20quartiers|style2|1')
});
});
});
Loading