Skip to content

Commit 8900ec6

Browse files
committed
Added test for map feature popups
1 parent 0ff068b commit 8900ec6

File tree

2 files changed

+26
-17
lines changed

2 files changed

+26
-17
lines changed

test/e2e/mapml-viewer/localization.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
<map-extent units="CBMTILE" checked>
4949
<map-link rel="query" tref="localization.mapml" ></map-link>
5050
</map-extent>
51-
<map-feature>
51+
<map-feature data-testid="map-feature">
5252
<map-properties><h6>Un lieu</h6></map-properties>
5353
<map-geometry cs="gcrs">
5454
<map-point><map-coordinates>-90 45</map-coordinates></map-point>
@@ -64,7 +64,7 @@
6464
<map-extent units="CBMTILE" checked>
6565
<map-link rel="query" tref="localization.mapml" ></map-link>
6666
</map-extent>
67-
<map-feature>
67+
<map-feature data-testid="map-feature">
6868
<map-properties><h6>A place - this map is not localized</h6></map-properties>
6969
<map-geometry cs="gcrs">
7070
<map-point><map-coordinates>-90 45</map-coordinates></map-point>
@@ -79,7 +79,7 @@
7979
<map-extent units="CBMTILE" checked>
8080
<map-link rel="query" tref="localization.mapml" ></map-link>
8181
</map-extent>
82-
<map-feature>
82+
<map-feature data-testid="map-feature">
8383
<map-properties><h6>A place</h6></map-properties>
8484
<map-geometry cs="gcrs">
8585
<map-point><map-coordinates>-90 45</map-coordinates></map-point>

test/e2e/mapml-viewer/localization.test.js

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -218,14 +218,6 @@ test.describe('<mapml-viewer> localization tests', () => {
218218
});
219219

220220
test('Hover messages for location tracking matches the locale key', async () => {
221-
const buttonNames = [
222-
'btnLocTrackOn',
223-
'btnMyLocTrackOn',
224-
'btnLocTrackOff',
225-
'btnLocTrackLastKnown',
226-
'btnMyLastKnownLocTrackOn'
227-
];
228-
229221
for (const [language, locale] of locales) {
230222
// select the current map
231223
const map = await page.getByTestId(language);
@@ -286,20 +278,37 @@ test.describe('<mapml-viewer> localization tests', () => {
286278
});
287279

288280
test('Map feature options matches the locale key', async () => {
289-
// hover over map feature, controls after clicking on the feature
290-
const buttonNames = [];
281+
const buttonNames = [
282+
'kbdFocusMap',
283+
'kbdPrevFeature',
284+
'kbdNextFeature',
285+
'kbdFocusControls'
286+
];
287+
288+
// click all feature buttons
289+
const features = await page.getByTestId('map-feature');
290+
const count = await features.count();
291+
for (let i = 0; i < count; i++) {
292+
await page.waitForTimeout(500);
293+
await features.nth(i).evaluate((node) => node.click());
294+
}
291295

292296
for (const [language, locale] of locales) {
293297
// select the current map
294298
const map = await page.getByTestId(language);
295299

296-
// where do we access these?
300+
// test focus buttons (for map features)
301+
const focusButtons = await map.locator('.mapml-focus-buttons button');
302+
const buttonsCount = await focusButtons.count();
303+
for (let i = 0; i < buttonsCount; i++) {
304+
const text = await focusButtons.nth(i).getAttribute('title');
305+
expect(text).toBeTruthy();
306+
expect(text.endsWith(locale[buttonNames[i]])).toBe(true);
307+
}
297308
}
298309
});
299310

300-
test('Keyboard feature messages matches the locale key', async () => {
301-
// in the attribution button, check that the keyboard feature messages
302-
// are translated
311+
test('Keyboard feature messages in the attribution button matches the locale key', async () => {
303312
const dialogBolded = ['kbdShortcuts', 'kbdMovement', 'kbdFeature'];
304313

305314
const dialogListItems = [

0 commit comments

Comments
 (0)