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

feature/accessible-interactive-tutorial-test #55

Merged
merged 7 commits into from
Oct 10, 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
56 changes: 28 additions & 28 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@stassi/leaf",
"version": "0.0.54",
"version": "0.0.55",
"description": "Leaflet adapter.",
"keywords": [
"cartography",
Expand Down Expand Up @@ -61,7 +61,7 @@
"serve": "^14.2.3"
},
"devDependencies": {
"@babel/eslint-parser": "^7.25.7",
"@babel/eslint-parser": "^7.25.8",
"@babel/plugin-syntax-import-attributes": "^7.25.7",
"@rollup/plugin-commonjs": "^28.0.0",
"@rollup/plugin-inject": "^5.0.5",
Expand All @@ -83,12 +83,12 @@
"eslint-plugin-jsonc": "^2.16.0",
"eslint-plugin-no-unsanitized": "^4.1.2",
"eslint-plugin-prettier": "^5.2.1",
"expect-puppeteer": "^10.1.1",
"expect-puppeteer": "^10.1.2",
"jest": "^29.7.0",
"jest-environment-puppeteer": "^10.1.1",
"jest-puppeteer": "^10.1.1",
"jest-environment-puppeteer": "^10.1.2",
"jest-puppeteer": "^10.1.2",
"prettier": "3.3.3",
"puppeteer": "^23.5.1",
"puppeteer": "^23.5.2",
"rollup": "^4.24.0",
"rollup-plugin-modify": "^3.0.0",
"shx": "^0.3.4",
Expand Down
55 changes: 55 additions & 0 deletions src/tutorial/accessible/interactive.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
describe('accessible interactive tutorial', (): void => {
beforeAll(async (): Promise<void> => {
await page.goto('http://localhost:3001/tutorial/accessible/interactive')
})

describe('map', (): void => {
describe('on initial page load', (): void => {
// eslint-disable-next-line jest/prefer-lowercase-title -- official case
describe('OpenStreetMap tiles', (): void => {
it('should render', async (): Promise<void> => {
;(
await page.$$eval(
'.leaflet-tile-loaded',
(tiles: Element[]): (string | null)[] =>
tiles.map((tile: Element): string | null =>
tile.getAttribute('src'),
),
)
).forEach((source: string | null): void => {
expect(source).toMatch(/^https:\/\/tile\.openstreetmap\.org\//)
})
})
})
})

describe('"Tab"-focused marker when "Enter" is pressed', (): void => {
it('should display popup text "Kyiv, Ukraine is the birthplace of Leaflet!"', async (): Promise<void> => {
let markerFocused = false

while (!markerFocused) {
await page.keyboard.press('Tab')

if (
(
await page.evaluate(
(): string => document.activeElement?.className ?? '',
)
).includes('leaflet-marker-icon')
) {
markerFocused = true
}
}

await page.keyboard.press('Enter')

expect(
await page.$eval(
'.leaflet-popup-content',
({ textContent }: Element): string | null => textContent,
),
).toBe('Kyiv, Ukraine is the birthplace of Leaflet!')
})
})
})
})
16 changes: 6 additions & 10 deletions src/tutorial/custom-marker-icons/custom-marker-icons.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
type SourceCustomMarkerIcons = string | null

describe('custom-marker-icons tutorial', (): void => {
beforeAll(async (): Promise<void> => {
await page.goto(
Expand All @@ -15,13 +13,12 @@ describe('custom-marker-icons tutorial', (): void => {
;(
await page.$$eval(
'.leaflet-tile-loaded',
(tiles: Element[]): SourceCustomMarkerIcons[] =>
tiles.map(
(tile: Element): SourceCustomMarkerIcons =>
tile.getAttribute('src'),
(tiles: Element[]): (string | null)[] =>
tiles.map((tile: Element): string | null =>
tile.getAttribute('src'),
),
)
).forEach((source: SourceCustomMarkerIcons): void => {
).forEach((source: string | null): void => {
expect(source).toMatch(/^https:\/\/tile\.openstreetmap\.org\//)
})
})
Expand All @@ -45,7 +42,7 @@ describe('custom-marker-icons tutorial', (): void => {
},
])(
'src="$src"',
({ popupText, src }: { popupText: string; src: string }): void => {
({ popupText, src }: Record<'popupText' | 'src', string>): void => {
it(`should display popup text "${popupText}"`, async (): Promise<void> => {
await (await page.$(`img[src="${src}"]`))?.click()

Expand All @@ -60,8 +57,7 @@ describe('custom-marker-icons tutorial', (): void => {
expect(
await page.$eval(
'.leaflet-popup-content',
({ textContent }: Element): SourceCustomMarkerIcons =>
textContent,
({ textContent }: Element): string | null => textContent,
),
).toBe(popupText)
})
Expand Down
12 changes: 5 additions & 7 deletions src/tutorial/mobile/mobile.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
type SourceMobile = string | null

describe('mobile tutorial', (): void => {
beforeAll(async (): Promise<void> => {
await browser
Expand All @@ -22,12 +20,12 @@ describe('mobile tutorial', (): void => {
;(
await page.$$eval(
'.leaflet-tile-loaded',
(tiles: Element[]): SourceMobile[] =>
tiles.map(
(tile: Element): SourceMobile => tile.getAttribute('src'),
(tiles: Element[]): (string | null)[] =>
tiles.map((tile: Element): string | null =>
tile.getAttribute('src'),
),
)
).forEach((source: SourceMobile): void => {
).forEach((source: string | null): void => {
expect(source).toMatch(/^https:\/\/tile\.openstreetmap\.org\//)
})
})
Expand All @@ -51,7 +49,7 @@ describe('mobile tutorial', (): void => {
expect(
await page.$eval(
'.leaflet-popup-content',
({ textContent }: Element): SourceMobile => textContent,
({ textContent }: Element): string | null => textContent,
),
).toBe('You are within 10 meters from this point.')
})
Expand Down
16 changes: 7 additions & 9 deletions src/tutorial/quick-start/quick-start.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import { type BoundingBox } from 'puppeteer'

type SourceQuickstart = string | null

describe('quick-start tutorial', (): void => {
beforeAll(async (): Promise<void> => {
await page.goto('http://localhost:3001/tutorial/quick-start/quick-start')
Expand All @@ -15,12 +13,12 @@ describe('quick-start tutorial', (): void => {
;(
await page.$$eval(
'.leaflet-tile-loaded',
(tiles: Element[]): SourceQuickstart[] =>
tiles.map(
(tile: Element): SourceQuickstart => tile.getAttribute('src'),
(tiles: Element[]): (string | null)[] =>
tiles.map((tile: Element): string | null =>
tile.getAttribute('src'),
),
)
).forEach((source: SourceQuickstart): void => {
).forEach((source: string | null): void => {
expect(source).toMatch(/^https:\/\/tile\.openstreetmap\.org\//)
})
})
Expand All @@ -31,7 +29,7 @@ describe('quick-start tutorial', (): void => {
expect(
await page.$eval(
'.leaflet-popup-content',
({ textContent }: Element): SourceQuickstart => textContent,
({ textContent }: Element): string | null => textContent,
),
).toBe('I am a standalone popup.')
})
Expand All @@ -58,7 +56,7 @@ describe('quick-start tutorial', (): void => {
expect(
await page.$eval(
'.leaflet-popup-content',
({ textContent }: Element): SourceQuickstart => textContent,
({ textContent }: Element): string | null => textContent,
),
).toMatch(/^You clicked the map at LatLng\(.+\)$/)
})
Expand Down Expand Up @@ -107,7 +105,7 @@ describe('quick-start tutorial', (): void => {
expect(
await page.$eval(
'.leaflet-popup-content',
({ textContent }: Element): SourceQuickstart => textContent,
({ textContent }: Element): string | null => textContent,
),
).toBe(popupText)
})
Expand Down