-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into feature/packaging
- Loading branch information
Showing
226 changed files
with
9,582 additions
and
17,514 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,4 +6,5 @@ | |
**/docs | ||
**/node_modules | ||
**/tests_output | ||
*.d.ts | ||
*.d.ts | ||
/.nx/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,60 @@ | ||
name: Run linter and tests | ||
name: Run linter, tests and type check | ||
|
||
on: push | ||
|
||
jobs: | ||
lint-test: | ||
lint: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-node@v4 | ||
with: | ||
node-version: 20.16.0 | ||
registry-url: https://registry.npmjs.org/ | ||
- run: | | ||
npm ci | ||
npm run lint:ci | ||
test: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: actions/setup-node@v3 | ||
with: | ||
node-version: 18.13.0 | ||
node-version: 20.16.0 | ||
registry-url: https://registry.npmjs.org/ | ||
- run: | | ||
npm ci | ||
npm run lint:ci | ||
npm run test | ||
teste2e: | ||
timeout-minutes: 60 | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-node@v4 | ||
with: | ||
node-version: 20.16.0 | ||
- name: Install dependencies | ||
run: npm ci | ||
- name: Build snowbox (started by playwright by itself) | ||
run: npm run snowbox:build | ||
- name: Install Playwright Browsers | ||
run: npx playwright install --with-deps | ||
- name: Run Playwright tests | ||
run: npm run test:e2e | ||
- uses: actions/upload-artifact@v4 | ||
if: ${{ !cancelled() }} | ||
with: | ||
name: playwright-report | ||
path: playwright-report/ | ||
retention-days: 30 | ||
type-check: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: actions/setup-node@v3 | ||
with: | ||
node-version: 20.16.0 | ||
registry-url: https://registry.npmjs.org/ | ||
- run: | | ||
npm ci | ||
npm run tsc:ci |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
build | ||
dist | ||
dist | ||
/.nx/workspace-data |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import 'regenerator-runtime/runtime' | ||
|
||
class Worker { | ||
constructor(stringUrl) { | ||
this.url = stringUrl | ||
this.onmessage = () => { | ||
// empty | ||
} | ||
} | ||
|
||
postMessage(msg) { | ||
this.onmessage(msg) | ||
} | ||
} | ||
// a mock for web worker | ||
window.Worker = Worker | ||
|
||
window.URL.createObjectURL = function () { | ||
// empty | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import { test, expect } from '@playwright/test' | ||
import { openSnowbox } from './utils/openSnowbox' | ||
|
||
const drawTargetId = '#vuex-target-draw-result' | ||
|
||
test('clicks to the map produce a fetchable pin coordinate', async ({ | ||
page, | ||
}) => { | ||
await openSnowbox(page) | ||
|
||
const canvas = await page.locator('canvas') | ||
const boundingBox = await canvas.boundingBox() | ||
if (boundingBox === null) throw new Error('Canvas not found.') | ||
const { width, height } = boundingBox | ||
let { x, y } = boundingBox | ||
|
||
x += width / 2 | ||
y += height / 2 | ||
|
||
await page.getByLabel('Draw tools').click() | ||
await page.getByText('Draw and write').click() | ||
await page.getByText('Polygon').click() | ||
|
||
const moves: [number, number, string][] = [ | ||
[0, 0, 'click'], | ||
[40, -40, 'click'], | ||
[40, 40, 'click'], | ||
[-80, 80, 'click'], | ||
[-80, -80, 'click'], | ||
[40, -40, 'dblclick'], | ||
] | ||
|
||
for (const [xMove, yMove, method] of moves) { | ||
await page.mouse[method]((x += xMove), (y += yMove)) | ||
} | ||
|
||
const drawing = JSON.parse(await page.locator(drawTargetId).innerText()) | ||
|
||
expect(drawing.type).toBe('FeatureCollection') | ||
expect(drawing.features.length).toBe(1) | ||
expect(drawing.features[0].geometry.coordinates[0].length).toBe(7) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { test, expect } from '@playwright/test' | ||
import { openSnowbox } from './utils/openSnowbox' | ||
|
||
const pinsTargetId = '#vuex-target-pin-coordinate' | ||
|
||
test('clicks to the map produce a fetchable pin coordinate', async ({ | ||
page, | ||
}) => { | ||
await openSnowbox(page) | ||
|
||
const coordinateTarget = page.locator(pinsTargetId) | ||
|
||
await expect(coordinateTarget).toBeEmpty() | ||
await page.locator('canvas').click() | ||
await expect(coordinateTarget).toHaveText(/\d+(\.\d+)?,\d+(\.\d+)?/) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { test, expect } from '@playwright/test' | ||
import { openSnowbox } from './utils/openSnowbox' | ||
import { dispatch } from './utils/vuex' | ||
|
||
const locatable = '私が来た' | ||
|
||
test('programmatically dispatched toasts are visible in the UI', async ({ | ||
page, | ||
}) => { | ||
await openSnowbox(page) | ||
|
||
await dispatch(page, 'plugin/toast/addToast', { | ||
type: 'info', | ||
text: locatable, | ||
}) | ||
|
||
await expect(page.getByText(locatable)).toBeVisible() | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { Page } from '@playwright/test' | ||
|
||
export const clickTimes = async ({ | ||
page, | ||
value, | ||
times, | ||
method = 'getByLabel', | ||
}: { | ||
page: Page | ||
value: string | ||
times: number | ||
method?: string | ||
}) => { | ||
for (let i = 0; i < times; i++) { | ||
await page[method](value).click() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { Page } from '@playwright/test' | ||
|
||
export const openSnowbox = async (page: Page) => { | ||
// @ts-expect-error | it's manually added in snowbox client | ||
const watchReadiness = page.waitForFunction(() => Boolean(window.mapInstance)) | ||
await page.goto('./dist/index.html') | ||
await watchReadiness | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { Page } from '@playwright/test' | ||
|
||
const execute = async ( | ||
page: Page, | ||
command: string, | ||
path: string, | ||
payload: unknown, | ||
params?: object | ||
) => { | ||
const evaluatable = `window.mapInstance.$store.${command}('${path}'${ | ||
typeof payload !== 'undefined' | ||
? `, ${JSON.stringify(payload)}` | ||
: typeof params !== 'undefined' | ||
? JSON.stringify(null) | ||
: '' | ||
}${typeof params !== 'undefined' ? `, ${JSON.stringify(params)}` : ''})` | ||
console.error(evaluatable) | ||
await page.evaluate(evaluatable) | ||
} | ||
|
||
export const dispatch = async ( | ||
page: Page, | ||
path: string, | ||
payload: unknown, | ||
params?: object | ||
) => await execute(page, 'dispatch', path, payload, params) | ||
|
||
export const commit = async ( | ||
page: Page, | ||
path: string, | ||
payload: unknown, | ||
params?: object | ||
) => await execute(page, 'commit', path, payload, params) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { test, expect } from '@playwright/test' | ||
import { openSnowbox } from './utils/openSnowbox' | ||
import { clickTimes } from './utils/clickTimes' | ||
|
||
const zoomTargetId = '#vuex-target-zoom' | ||
|
||
test('zoom in button zooms in until max zoom', async ({ page }) => { | ||
const zoomInLabel = 'Zoom in' | ||
await openSnowbox(page) | ||
|
||
const zoomTarget = page.locator(zoomTargetId) | ||
await expect(zoomTarget).toHaveText('2') | ||
await clickTimes({ page, value: zoomInLabel, times: 7 }) | ||
await expect(zoomTarget).toHaveText('9') | ||
await expect(page.getByLabel(zoomInLabel)).toBeDisabled() | ||
}) | ||
|
||
test('zoom out button zooms out until min zoom', async ({ page }) => { | ||
const zoomOutLabel = 'Zoom out' | ||
await openSnowbox(page) | ||
|
||
const zoomTarget = page.locator(zoomTargetId) | ||
await expect(zoomTarget).toHaveText('2') | ||
await clickTimes({ page, value: zoomOutLabel, times: 2 }) | ||
await expect(zoomTarget).toHaveText('0') | ||
await expect(page.getByLabel(zoomOutLabel)).toBeDisabled() | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.