From 9dba9e0cfd39bfac6b618e7817c98dbce7116511 Mon Sep 17 00:00:00 2001 From: Andreas Stassivik Date: Sun, 6 Oct 2024 18:12:58 -0700 Subject: [PATCH 1/3] `mobile` tutorial test implementation --- src/tutorial/mobile/mobile.test.ts | 59 ++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 src/tutorial/mobile/mobile.test.ts diff --git a/src/tutorial/mobile/mobile.test.ts b/src/tutorial/mobile/mobile.test.ts new file mode 100644 index 0000000..d3e5d94 --- /dev/null +++ b/src/tutorial/mobile/mobile.test.ts @@ -0,0 +1,59 @@ +type Source = string | null + +describe('mobile tutorial', (): void => { + beforeAll(async (): Promise => { + await browser + .defaultBrowserContext() + .overridePermissions('http://localhost:3001', ['geolocation']) + + await page.setGeolocation({ + accuracy: 10, + latitude: 51.505, + longitude: -0.09, + }) + + await page.goto('http://localhost:3001/tutorial/mobile/mobile') + }) + + describe('map', (): void => { + // eslint-disable-next-line jest/prefer-lowercase-title -- official case + describe('OpenStreetMap tiles', (): void => { + it('should render', async (): Promise => { + ;( + await page.$$eval( + '.leaflet-tile-loaded', + (tiles: Element[]): Source[] => + tiles.map((tile: Element): Source => tile.getAttribute('src')), + ) + ).forEach((source: Source): void => { + expect(source).toMatch(/^https:\/\/tile\.openstreetmap\.org\//) + }) + }) + }) + }) + + describe('user location', (): void => { + describe('circle', (): void => { + it('should render', async (): Promise => { + expect(await page.$('path.leaflet-interactive')).toBeDefined() + }) + }) + + describe('marker', (): void => { + it('should render', async (): Promise => { + expect(await page.$('.leaflet-marker-icon')).toBeDefined() + }) + }) + + describe('popup text', (): void => { + it('should display user location accuracy', async (): Promise => { + expect( + await page.$eval( + '.leaflet-popup-content', + ({ textContent }: Element): Source => textContent, + ), + ).toBe('You are within 10 meters from this point.') + }) + }) + }) +}) From 568ca4881e6455bb2b4b5d1239187aa0f1dc324c Mon Sep 17 00:00:00 2001 From: Andreas Stassivik Date: Sun, 6 Oct 2024 18:49:59 -0700 Subject: [PATCH 2/3] `layer` replaces `user location` test description, nested under `map` --- src/tutorial/mobile/mobile.test.ts | 36 +++++++++++++++--------------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/src/tutorial/mobile/mobile.test.ts b/src/tutorial/mobile/mobile.test.ts index d3e5d94..32c1784 100644 --- a/src/tutorial/mobile/mobile.test.ts +++ b/src/tutorial/mobile/mobile.test.ts @@ -30,29 +30,29 @@ describe('mobile tutorial', (): void => { }) }) }) - }) - describe('user location', (): void => { - describe('circle', (): void => { - it('should render', async (): Promise => { - expect(await page.$('path.leaflet-interactive')).toBeDefined() + describe('layer', (): void => { + describe('circle', (): void => { + it('should render', async (): Promise => { + expect(await page.$('path.leaflet-interactive')).toBeDefined() + }) }) - }) - describe('marker', (): void => { - it('should render', async (): Promise => { - expect(await page.$('.leaflet-marker-icon')).toBeDefined() + describe('marker', (): void => { + it('should render', async (): Promise => { + expect(await page.$('.leaflet-marker-icon')).toBeDefined() + }) }) - }) - describe('popup text', (): void => { - it('should display user location accuracy', async (): Promise => { - expect( - await page.$eval( - '.leaflet-popup-content', - ({ textContent }: Element): Source => textContent, - ), - ).toBe('You are within 10 meters from this point.') + describe('popup text', (): void => { + it('should display user location accuracy', async (): Promise => { + expect( + await page.$eval( + '.leaflet-popup-content', + ({ textContent }: Element): Source => textContent, + ), + ).toBe('You are within 10 meters from this point.') + }) }) }) }) From c8648a001b093d8533ceb509a6c818e9cf7cfffa Mon Sep 17 00:00:00 2001 From: Andreas Stassivik Date: Sun, 6 Oct 2024 18:51:25 -0700 Subject: [PATCH 3/3] 0.0.47 --- package-lock.json | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index d0e67b1..3fa1264 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@stassi/leaf", - "version": "0.0.46", + "version": "0.0.47", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@stassi/leaf", - "version": "0.0.46", + "version": "0.0.47", "cpu": [ "arm64", "x64" diff --git a/package.json b/package.json index c6da8be..bdcac79 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@stassi/leaf", - "version": "0.0.46", + "version": "0.0.47", "description": "Leaflet adapter.", "keywords": [ "cartography",