diff --git a/tests/realtimemap.spec.ts b/tests/realtimemap.spec.ts index 5ef609a3..108fcdfe 100644 --- a/tests/realtimemap.spec.ts +++ b/tests/realtimemap.spec.ts @@ -1,4 +1,4 @@ -import { test, urlMatcher } from './utils' +import { test, expect, urlMatcher } from './utils' test.beforeEach(async ({ page, advancedRouteFromHAR }) => { await page.route(/google-analytics\.com|googletagmanager\.com/, (route) => route.abort()) @@ -18,3 +18,41 @@ test('time-based-map page', async ({ page }) => { await page.getByLabel('תאריך').fill(new Date().toLocaleDateString('en-GB')) await page.getByLabel('דקות').fill('6') }) + +test('tooltip appears after clicking on map point', async ({ page }) => { + await page.goto('/map') + + await test.step('Click on a bus button', async () => { + const button = page.getByRole('button', { name: 'אגד אגד' }) + await button.click() + await button.click({ force: true }) + }) + + await test.step('Click inside the tooltip', async () => { + await page.getByRole('button', { name: 'הצג מידע לגיקים' }).click() + await page.getByRole('button', { name: 'הסתר מידע לגיקים' }).click() + }) + + await test.step('Expecting the tooltip to have the correct content', async () => { + const contentItemsInOrder = [ + 'מוצא:', + 'יעד:', + 'מהירות:', + 'זמן דגימה:', + 'לוחית רישוי:', + 'כיוון נסיעה:', + 'נ.צ.:', + ] + const textList = await page.evaluate(() => { + return Array.from(document.querySelectorAll('div.content ul li')) + .map((li) => + Array.from(li.childNodes) + .filter((node) => node.nodeType === Node.TEXT_NODE) + .map((node) => node.textContent?.trim() || ''), + ) + .flat() + .filter((value) => value !== '') + }) + expect(textList).toEqual(contentItemsInOrder) + }) +})