Skip to content

Commit f25244a

Browse files
committed
Use tooltip role in the test
1 parent a3bf861 commit f25244a

File tree

3 files changed

+24
-14
lines changed

3 files changed

+24
-14
lines changed

src/app/(main)/community/events/map/map-popover.tsx renamed to src/app/(main)/community/events/map/map-tooltip.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,20 @@ export type MeetupMapPointer = {
1010

1111
const meetupNameById = new Map(meetups.map(({ node }) => [node.id, node.name]))
1212

13-
type MapPopoverProps = {
13+
type MapTooltipProps = {
14+
id: string
1415
activeMeetupId: string | null
1516
pointer: MeetupMapPointer
1617
}
1718

18-
export function MapPopover({ activeMeetupId, pointer }: MapPopoverProps) {
19+
export function MapTooltip({ id, activeMeetupId, pointer }: MapTooltipProps) {
1920
if (!activeMeetupId || !pointer.visible) return null
2021
const name = meetupNameById.get(activeMeetupId)
2122
if (!name) return null
2223
return (
2324
<span
25+
id={id}
26+
role="tooltip"
2427
className="pointer-events-none absolute left-0 top-0 z-10 hidden min-w-0 whitespace-nowrap border border-neu-200/40 bg-neu-0/40 px-2 py-1 text-xs font-medium text-neu-900 shadow-sm backdrop-blur-sm group-hover/map:flex"
2528
style={{
2629
transform: `translate3d(calc(${pointer.x}px - 50%), calc(${pointer.y}px - 50% - 24px), 0)`,

src/app/(main)/community/events/meetups-map.tsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import { useTheme } from "next-themes"
1212
import { meetups } from "@/components/meetups"
1313

1414
import { bootMeetupsMap, type MapHandle, type MarkerPoint } from "./map/engine"
15-
import { MapPopover, type MeetupMapPointer } from "./map/map-popover"
15+
import { MapTooltip, type MeetupMapPointer } from "./map/map-tooltip"
1616
import { MapSkeleton } from "./map-skeleton"
1717
import { MeetupsList } from "./meetups-list"
1818
import { asRgbString, MAP_COLORS, MapColors } from "./map/map-colors"
@@ -161,6 +161,7 @@ export function MeetupsMap() {
161161
>
162162
<canvas
163163
ref={canvasRef}
164+
aria-describedby="map-tooltip"
164165
aria-label="Interactive WebGL map of GraphQL meetups"
165166
className="block h-80 w-full animate-fade-in transition-opacity duration-150 ease-linear md:h-full"
166167
style={{
@@ -170,7 +171,11 @@ export function MeetupsMap() {
170171
}}
171172
/>
172173

173-
<MapPopover activeMeetupId={activeMeetupId} pointer={pointer} />
174+
<MapTooltip
175+
id="map-tooltip"
176+
activeMeetupId={activeMeetupId}
177+
pointer={pointer}
178+
/>
174179

175180
<InfoTip />
176181

test/e2e/community-events.spec.ts

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
import { test, expect } from "@playwright/test"
22

3-
test("community events page map loads and Zurich meetup link works", async ({
4-
page,
5-
}) => {
3+
test("map loads and Zurich meetup link works", async ({ page }) => {
64
await page.goto("/community/events")
75

86
// Wait for the map canvas to be visible
@@ -43,7 +41,7 @@ test("community events page map loads and Zurich meetup link works", async ({
4341
expect(newPage.url()).toContain("meetup.com/graphql-zurich")
4442
})
4543

46-
test("community events map popover appears on marker hover", async ({ page }) => {
44+
test("map tooltip appears on marker hover", async ({ page }) => {
4745
await page.goto("/community/events")
4846
const mapCanvas = page.locator("canvas").first()
4947
await expect(mapCanvas).toBeVisible({ timeout: 10000 })
@@ -53,8 +51,8 @@ test("community events map popover appears on marker hover", async ({ page }) =>
5351
return Boolean(box && box.width > 100 && box.height > 100)
5452
})
5553
.toBe(true)
56-
const popover = page.locator('[data-testid="meetup-map-popover"]')
57-
await expect(popover).toHaveCount(0)
54+
const tooltip = page.getByRole("tooltip")
55+
await expect(tooltip).toHaveCount(0)
5856
await mapCanvas.hover()
5957
const { clientX, clientY } = await page.evaluate(() => {
6058
const canvas = document.querySelector("canvas") as HTMLCanvasElement | null
@@ -81,7 +79,9 @@ test("community events map popover appears on marker hover", async ({ page }) =>
8179
const latToRawV = (lat: number) => {
8280
const clampedLat = Math.max(-mercatorLimit, Math.min(mercatorLimit, lat))
8381
const rad = (clampedLat * Math.PI) / 180
84-
return 0.5 - Math.log(Math.tan(Math.PI * 0.25 + rad * 0.5)) / (2 * Math.PI)
82+
return (
83+
0.5 - Math.log(Math.tan(Math.PI * 0.25 + rad * 0.5)) / (2 * Math.PI)
84+
)
8585
}
8686
const maxProjectedV = latToRawV(mercatorLimit)
8787
const minProjectedV = latToRawV(minDisplayedLatitude)
@@ -93,7 +93,9 @@ test("community events map popover appears on marker hover", async ({ page }) =>
9393
Math.min(mercatorLimit, lat + baseLatitudeOffset),
9494
)
9595
const rawV = latToRawV(adjustedLat)
96-
const normalizedV = clamp01((rawV - maxProjectedV) / (minProjectedV - maxProjectedV))
96+
const normalizedV = clamp01(
97+
(rawV - maxProjectedV) / (minProjectedV - maxProjectedV),
98+
)
9799
return [u, normalizedV] as const
98100
}
99101
const { width, height } = canvas
@@ -117,6 +119,6 @@ test("community events map popover appears on marker hover", async ({ page }) =>
117119
return { clientX, clientY }
118120
})
119121
await page.mouse.move(clientX, clientY)
120-
await expect(popover).toHaveText("London GraphQL", { timeout: 5000 })
121-
await expect(popover).toBeVisible()
122+
await expect(tooltip).toHaveText("London GraphQL", { timeout: 5000 })
123+
await expect(tooltip).toBeVisible()
122124
})

0 commit comments

Comments
 (0)