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

test: add test for realtime map tooltip #1028

Merged
merged 3 commits into from
Feb 9, 2025
Merged
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
40 changes: 39 additions & 1 deletion tests/realtimemap.spec.ts
Original file line number Diff line number Diff line change
@@ -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())
Expand All @@ -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)
})
})
Loading