From c4b58419dfcbf6589f43f27f0ac249368b9f50fb Mon Sep 17 00:00:00 2001 From: t-kurasawa Date: Sat, 6 Jan 2024 11:18:18 +0900 Subject: [PATCH 1/4] [issues/449] add Playwright E2E test environment --- .gitignore | 4 + components/PrintableMap.vue | 8 +- jest.config.js | 15 +- package.json | 8 +- playwright.config.ts | 77 +++++++++ test-e2e/README.md | 76 +++++++++ test-e2e/kamimap.spec.ts | 18 +++ {test => test-unit}/README.md | 0 .../components/Logo.vue.spec.js | 8 +- {test => test-unit}/lib/displayHelper.spec.js | 2 +- yarn.lock | 151 +++++++++++++++++- 11 files changed, 348 insertions(+), 19 deletions(-) create mode 100644 playwright.config.ts create mode 100644 test-e2e/README.md create mode 100644 test-e2e/kamimap.spec.ts rename {test => test-unit}/README.md (100%) rename {test => test-unit}/components/Logo.vue.spec.js (77%) rename {test => test-unit}/lib/displayHelper.spec.js (92%) diff --git a/.gitignore b/.gitignore index 8c6652cb..bf4646bd 100644 --- a/.gitignore +++ b/.gitignore @@ -89,3 +89,7 @@ sw.* # Vim swap files *.swp +/test-results/ +/playwright-report/ +/blob-report/ +/playwright/.cache/ diff --git a/components/PrintableMap.vue b/components/PrintableMap.vue index b5fa79ef..637c121d 100644 --- a/components/PrintableMap.vue +++ b/components/PrintableMap.vue @@ -88,10 +88,10 @@ div .legend-list-outer simplebar(data-simplebar-auto-hide="false") ul.legend-list - li.legend-item( - v-for='(setting, category) in mapConfig.layer_settings' - v-if="displayMarkersGroupByCategory.some((elm) => elm.category === category)" - ) + li.legend-item( + v-for='(setting, category) in Object.entries(mapConfig.layer_settings)' + v-if="displayMarkersGroupByCategory.some((elm) => elm.category === category)" + ) span.legend-mark( :style="{backgroundColor:setting.color}" @click="selectCategory(category), isOpenList=category, isDisplayAllCategory=false" diff --git a/jest.config.js b/jest.config.js index db505451..15f896c8 100644 --- a/jest.config.js +++ b/jest.config.js @@ -9,6 +9,19 @@ module.exports = { moduleNameMapper: { '^~/(.*)$': '/$1', }, - testMatch: ['/test/**/*.spec.js'], + testMatch: ['/test-unit/**/*.spec.js'], snapshotSerializers: ['/node_modules/jest-serializer-vue'], + collectCoverageFrom: [ + '**/*.{js,jsx,ts,tsx,vue}', + '!**/node_modules/**', + '!**/.nuxt/**', + '!**/@types/**', + '!**/.eslintrc.js', + '!**/nuxt.config.js', + '!**/jest.config.js', + '!**/nuxt-i18n.config.js', + '!**/nuxt-router-override-sample.config.js', + '!**/tests/**', + '!**/coverage/**', + ], }; diff --git a/package.json b/package.json index 6eba3b6a..d102adb5 100644 --- a/package.json +++ b/package.json @@ -13,7 +13,10 @@ "createtiles": "node createtiles.js", "lint": "eslint --ext .js,.vue --ignore-path .gitignore .", "dev-debug": "node --inspect-brk=9229 node_modules/nuxt/bin/nuxt", - "test": "jest" + "test": "npm-run-all --sequential test:unit test:e2e", + "test:unit": "jest", + "test:jest:coverage": "jest --coverage", + "test:e2e": "playwright test" }, "browserslist": [ "last 2 version", @@ -30,6 +33,7 @@ "js-crc": "^0.2.0", "ky": "^0.15.0", "maplibre-gl": "^1.13.0-rc.5", + "npm-run-all": "^4.1.5", "nuxt": "^2.14.7", "nuxt-i18n": "^6.20.4", "simplebar-vue": "^1.6.0", @@ -50,8 +54,10 @@ "@nuxt/typescript-build": "^0.2.10", "@nuxtjs/eslint-config": "^1.0.1", "@nuxtjs/eslint-module": "^1.2.0", + "@playwright/test": "^1.40.1", "@types/geojson": "^7946.0.7", "@types/jest": "^29.5.11", + "@types/node": "^20.10.6", "@vue/compiler-dom": "^3.4.5", "@vue/server-renderer": "^3.4.5", "@vue/server-test-utils": "1", diff --git a/playwright.config.ts b/playwright.config.ts new file mode 100644 index 00000000..1a885abb --- /dev/null +++ b/playwright.config.ts @@ -0,0 +1,77 @@ +import { defineConfig, devices } from '@playwright/test'; + +/** + * Read environment variables from file. + * https://github.com/motdotla/dotenv + */ +// require('dotenv').config(); + +/** + * See https://playwright.dev/docs/test-configuration. + */ +export default defineConfig({ + testDir: './test-e2e', + /* Run tests in files in parallel */ + fullyParallel: true, + /* Fail the build on CI if you accidentally left test.only in the source code. */ + forbidOnly: !!process.env.CI, + /* Retry on CI only */ + retries: process.env.CI ? 2 : 0, + /* Opt out of parallel tests on CI. */ + workers: process.env.CI ? 1 : undefined, + /* Reporter to use. See https://playwright.dev/docs/test-reporters */ + reporter: 'html', + /* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */ + use: { + /* Base URL to use in actions like `await page.goto('/')`. */ + // baseURL: 'http://127.0.0.1:3000', + + /* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */ + trace: 'on-first-retry', + }, + + /* Configure projects for major browsers */ + projects: [ + { + name: 'chromium', + use: { ...devices['Desktop Chrome'] }, + }, + + // { + // name: 'firefox', + // use: { ...devices['Desktop Firefox'] }, + // }, + + // { + // name: 'webkit', + // use: { ...devices['Desktop Safari'] }, + // }, + + /* Test against mobile viewports. */ + // { + // name: 'Mobile Chrome', + // use: { ...devices['Pixel 5'] }, + // }, + // { + // name: 'Mobile Safari', + // use: { ...devices['iPhone 12'] }, + // }, + + /* Test against branded browsers. */ + // { + // name: 'Microsoft Edge', + // use: { ...devices['Desktop Edge'], channel: 'msedge' }, + // }, + // { + // name: 'Google Chrome', + // use: { ...devices['Desktop Chrome'], channel: 'chrome' }, + // }, + ], + + /* Run your local dev server before starting the tests */ + // webServer: { + // command: 'npm run start', + // url: 'http://127.0.0.1:3000', + // reuseExistingServer: !process.env.CI, + // }, +}); diff --git a/test-e2e/README.md b/test-e2e/README.md new file mode 100644 index 00000000..e7851f1f --- /dev/null +++ b/test-e2e/README.md @@ -0,0 +1,76 @@ +[E2E テストコード環境を構築する](https://github.com/codeforjapan/mapprint/issues/449) + +## 要望の概要 | What + +E2E テストコード環境を構築する + +## なぜやるのか | Why + +コードの品質維持のため。 + +#319 で Jest 環境は作ったが Vue のテストにはモック化などの整備が不十分である。 +画面数も少ないため E2E テストコード環境を入れる。 + +## どうやるのか | How + +Playwright を導入する。 + +その後、個別のテストコードを実装する + +### テスト実行 +` yarn test:e2e ` + +※Windows の方はコマンドプロンプトから実行してください + +### [WIP] WSL 向けの環境構築手順 + +- Playwright は WSL ではすぐに動かないため以下の対応をお願いします。 + +- 1. Error: browserType.launch: Executable doesn't exist at /home/user/.cache/ +ms-playwright/chromium-1091/chrome-linux/chrome +╔═════════════════════════════════════════════════════════════════════════╗ +║ Looks like Playwright Test or Playwright was just installed or updated. ║ +║ Please run the following command to download new browsers: ║ +║ ║ +║ yarn playwright install ║ +║ ║ +║ <3 Playwright Team ║ +╚═════════════════════════════════════════════════════════════════════════╝ + 3 | + 4 | test('URL Check', async () => { +> 5 | const browser = await chromium.launch({ headless: false }); + | ^ + 6 | const context = await browser.newContext(); + 7 | const page = await context.newPage(); + 8 | + + +- 2. Error: browserType.launch: +╔══════════════════════════════════════════════════════╗ +║ Host system is missing dependencies to run browsers. ║ +║ Please install them with the following command: ║ +║ ║ +║ sudo yarn playwright install-deps ║ +║ ║ +║ Alternatively, use apt: ║ +║ sudo apt-get install libnss3\ ║ +║ libnspr4\ ║ +║ libatk1.0-0\ ║ +║ libatk-bridge2.0-0\ ║ +║ libcups2\ ║ +║ libxkbcommon0\ ║ +║ libatspi2.0-0\ ║ +║ libxcomposite1\ ║ +║ libxdamage1\ ║ +║ libxfixes3\ ║ +║ libxrandr2\ ║ +║ libgbm1\ ║ +║ libpango-1.0-0\ ║ +║ libcairo2\ ║ +║ libasound2 ║ +║ ║ +║ <3 Playwright Team ║ +╚══════════════════════════════════════════════════════╝ + +- 3. Error: browserType.launch: Target page, context or browser has been closed +[WIP] WSL で動かす方法は未解決です。 diff --git a/test-e2e/kamimap.spec.ts b/test-e2e/kamimap.spec.ts new file mode 100644 index 00000000..da568407 --- /dev/null +++ b/test-e2e/kamimap.spec.ts @@ -0,0 +1,18 @@ +import { test, expect } from '@playwright/test'; +import { chromium } from 'playwright'; + +test('URL Check', async () => { + const browser = await chromium.launch({ headless: false }); + const context = await browser.newContext(); + const page = await context.newPage(); + + try { + await page.goto('https://kamimap.com/'); + await page.waitForLoadState('load'); + await expect(page.url()).toBe('https://kamimap.com/en'); + } catch (error) { + console.error('Error during page navigation:', error); + } + + await browser.close(); +}); diff --git a/test/README.md b/test-unit/README.md similarity index 100% rename from test/README.md rename to test-unit/README.md diff --git a/test/components/Logo.vue.spec.js b/test-unit/components/Logo.vue.spec.js similarity index 77% rename from test/components/Logo.vue.spec.js rename to test-unit/components/Logo.vue.spec.js index a1bdff2a..83bc4037 100644 --- a/test/components/Logo.vue.spec.js +++ b/test-unit/components/Logo.vue.spec.js @@ -1,12 +1,12 @@ // Import the required libraries import { mount } from '@vue/test-utils'; -import TestComponent from '~/components/Logo.vue'; +import Logo from '~/components/Logo.vue'; // Describe the test suite -describe('TestComponent', () => { +describe('Logo', () => { // Test if the component renders correctly it('renders the component', () => { - const wrapper = mount(TestComponent); + const wrapper = mount(Logo); expect(wrapper.exists()).toBe(true); }); @@ -14,7 +14,7 @@ describe('TestComponent', () => { // For example, testing the presence and styling of individual triangles it('contains four triangles with correct styling', () => { - const wrapper = mount(TestComponent); + const wrapper = mount(Logo); const triangles = wrapper.findAll('.Triangle'); expect(triangles).toHaveLength(4); diff --git a/test/lib/displayHelper.spec.js b/test-unit/lib/displayHelper.spec.js similarity index 92% rename from test/lib/displayHelper.spec.js rename to test-unit/lib/displayHelper.spec.js index 2b4aba58..88e42650 100644 --- a/test/lib/displayHelper.spec.js +++ b/test-unit/lib/displayHelper.spec.js @@ -3,7 +3,7 @@ import { getNowYMD } from '~/lib/displayHelper'; describe('getNowYMD', () => { test('returns the formatted date in Japanese by default', () => { const mockDate = new Date('2022-01-05T12:34:56'); - const result = getNowYMD(mockDate); + const result = getNowYMD(mockDate, 'ja'); expect(result).toBe('2022年01月05日12時34分'); }); diff --git a/yarn.lock b/yarn.lock index c6131564..7eb2a5cb 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2241,6 +2241,13 @@ resolved "https://registry.yarnpkg.com/@pkgjs/parseargs/-/parseargs-0.11.0.tgz#a77ea742fab25775145434eb1d2328cf5013ac33" integrity sha512-+1VkjdD0QBLPodGrJUeqarH8VAIvQODIbwh9XpP5Syisf7YoQgsJKPNFoqqLQlu+VQ/tVSshMR6loPMn8U+dPg== +"@playwright/test@^1.40.1": + version "1.40.1" + resolved "https://registry.yarnpkg.com/@playwright/test/-/test-1.40.1.tgz#9e66322d97b1d74b9f8718bacab15080f24cde65" + integrity sha512-EaaawMTOeEItCRvfmkI9v6rBkF1svM8wjl/YPRrg2N2Wmp+4qJYkWtJsbew1szfKKDm6fPLy4YAanBhIlf9dWw== + dependencies: + playwright "1.40.1" + "@polka/url@^1.0.0-next.24": version "1.0.0-next.24" resolved "https://registry.yarnpkg.com/@polka/url/-/url-1.0.0-next.24.tgz#58601079e11784d20f82d0585865bb42305c4df3" @@ -2529,7 +2536,7 @@ resolved "https://registry.yarnpkg.com/@types/mime/-/mime-1.3.5.tgz#1ef302e01cf7d2b5a0fa526790c9123bf1d06690" integrity sha512-/pyBZWSLD2n0dcHE3hq8s8ZvcETHtEuF+3E7XVt0Ig2nvsVQXdghHVcEkIWjy9A0wKfTn97a/PSDYohKIlnP/w== -"@types/node@*": +"@types/node@*", "@types/node@^20.10.6": version "20.10.6" resolved "https://registry.yarnpkg.com/@types/node/-/node-20.10.6.tgz#a3ec84c22965802bf763da55b2394424f22bfbb5" integrity sha512-Vac8H+NlRNNlAmDfGUP7b5h/KA+AtWIzuXy0E6OyP8f1tCLYAtPvKRRDJjAPqhpCb0t6U2j7/xqAuLEebW2kiw== @@ -6323,6 +6330,11 @@ fs@0.0.1-security: resolved "https://registry.yarnpkg.com/fs/-/fs-0.0.1-security.tgz#8a7bd37186b6dddf3813f23858b57ecaaf5e41d4" integrity sha512-3XY9e1pP0CVEUCdj5BmfIZxRBTSDycnbqhIOGec9QYtmVH2fbLpj86CFWkrNOkt/Fvty4KZG5lTglL9j/gJ87w== +fsevents@2.3.2: + version "2.3.2" + resolved "https://registry.yarnpkg.com/fsevents/-/fsevents-2.3.2.tgz#8a526f78b8fdf4623b709e0b975c52c24c02fd1a" + integrity sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA== + fsevents@^1.2.7: version "1.2.13" resolved "https://registry.yarnpkg.com/fsevents/-/fsevents-1.2.13.tgz#f325cb0455592428bcf11b383370ef70e3bfcc38" @@ -6754,6 +6766,11 @@ hookable@^5.5.3: resolved "https://registry.yarnpkg.com/hookable/-/hookable-5.5.3.tgz#6cfc358984a1ef991e2518cb9ed4a778bbd3215d" integrity sha512-Yc+BQe8SvoXH1643Qez1zqLRmbA5rCL+sSmk6TVos0LWVfNIB7PGncdlId77WzLGSIB5KaWgTaNTs2lNVEI6VQ== +hosted-git-info@^2.1.4: + version "2.8.9" + resolved "https://registry.yarnpkg.com/hosted-git-info/-/hosted-git-info-2.8.9.tgz#dffc0bf9a21c02209090f2aa69429e1414daf3f9" + integrity sha512-mxIDAb9Lsm6DoOJ7xH+5+X4y1LU/4Hi50L9C5sIswK3JzULS4bwk1FvjdBgvYR4bzT4tuUQiC15FE2f5HbLvYw== + html-encoding-sniffer@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/html-encoding-sniffer/-/html-encoding-sniffer-3.0.0.tgz#2cb1a8cf0db52414776e5b2a7a04d5dd98158de9" @@ -8150,6 +8167,16 @@ lines-and-columns@^1.1.6: resolved "https://registry.yarnpkg.com/lines-and-columns/-/lines-and-columns-1.2.4.tgz#eca284f75d2965079309dc0ad9255abb2ebc1632" integrity sha512-7ylylesZQ/PV29jhEDl3Ufjo6ZX7gCqJr5F7PKrqc93v7fzSymt1BpwEU8nAUXs8qzzvqhbjhK5QZg6Mt/HkBg== +load-json-file@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/load-json-file/-/load-json-file-4.0.0.tgz#2f5f45ab91e33216234fd53adab668eb4ec0993b" + integrity sha512-Kx8hMakjX03tiGTLAIdJ+lL0htKnXjEZN6hk/tozf/WOuYGdZBJrZ+rCJRbVCugsjB3jMLn9746NsQIf5VjBMw== + dependencies: + graceful-fs "^4.1.2" + parse-json "^4.0.0" + pify "^3.0.0" + strip-bom "^3.0.0" + loader-runner@^2.4.0: version "2.4.0" resolved "https://registry.yarnpkg.com/loader-runner/-/loader-runner-2.4.0.tgz#ed47066bfe534d7e84c4c7b9998c2a75607d9357" @@ -8512,6 +8539,11 @@ memory-fs@^0.5.0: errno "^0.1.3" readable-stream "^2.0.1" +memorystream@^0.3.1: + version "0.3.1" + resolved "https://registry.yarnpkg.com/memorystream/-/memorystream-0.3.1.tgz#86d7090b30ce455d63fbae12dda51a47ddcaf9b2" + integrity sha512-S3UwM3yj5mtUSEfP41UZmt/0SCoVYUcU1rkXv+BQ5Ig8ndL4sPoJNBUJERafdPb5jjHJGuMgytgKvKIf58XNBw== + merge-source-map@^1.1.0: version "1.1.0" resolved "https://registry.yarnpkg.com/merge-source-map/-/merge-source-map-1.1.0.tgz#2fdde7e6020939f70906a68f2d7ae685e4c8c646" @@ -8944,6 +8976,16 @@ nopt@^7.2.0: dependencies: abbrev "^2.0.0" +normalize-package-data@^2.3.2: + version "2.5.0" + resolved "https://registry.yarnpkg.com/normalize-package-data/-/normalize-package-data-2.5.0.tgz#e66db1838b200c1dfc233225d12cb36520e234a8" + integrity sha512-/5CMN3T0R4XTj4DcGaexo+roZSdSFW/0AOOTROrjxzCG1wrWXEsGbRKevjlIL+ZDE4sZlJr5ED4YW0yqmkK+eA== + dependencies: + hosted-git-info "^2.1.4" + resolve "^1.10.0" + semver "2 || 3 || 4 || 5" + validate-npm-package-license "^3.0.1" + normalize-path@^2.1.1: version "2.1.1" resolved "https://registry.yarnpkg.com/normalize-path/-/normalize-path-2.1.1.tgz#1ab28b556e198363a8c1a6f7e6fa20137fe6aed9" @@ -8976,6 +9018,21 @@ normalize-url@^6.0.1: resolved "https://registry.yarnpkg.com/normalize-url/-/normalize-url-6.1.0.tgz#40d0885b535deffe3f3147bec877d05fe4c5668a" integrity sha512-DlL+XwOy3NxAQ8xuC0okPgK46iuVNAK01YN7RueYBqqFeGsBjV9XmCAzAdgt+667bCl5kPh9EqKKDwnaPG1I7A== +npm-run-all@^4.1.5: + version "4.1.5" + resolved "https://registry.yarnpkg.com/npm-run-all/-/npm-run-all-4.1.5.tgz#04476202a15ee0e2e214080861bff12a51d98fba" + integrity sha512-Oo82gJDAVcaMdi3nuoKFavkIHBRVqQ1qvMb+9LHk/cF4P6B2m8aP04hGf7oL6wZ9BuGwX1onlLhpuoofSyoQDQ== + dependencies: + ansi-styles "^3.2.1" + chalk "^2.4.1" + cross-spawn "^6.0.5" + memorystream "^0.3.1" + minimatch "^3.0.4" + pidtree "^0.3.0" + read-pkg "^3.0.0" + shell-quote "^1.6.1" + string.prototype.padend "^3.0.0" + npm-run-path@^4.0.1: version "4.0.1" resolved "https://registry.yarnpkg.com/npm-run-path/-/npm-run-path-4.0.1.tgz#b7ecd1e5ed53da8e37a55e1c2269e0b97ed748ea" @@ -9446,6 +9503,13 @@ path-scurry@^1.10.1: lru-cache "^9.1.1 || ^10.0.0" minipass "^5.0.0 || ^6.0.2 || ^7.0.0" +path-type@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/path-type/-/path-type-3.0.0.tgz#cef31dc8e0a1a3bb0d105c0cd97cf3bf47f4e36f" + integrity sha512-T2ZUsdZFHgA3u4e5PfPbjd7HDDpxPnQb5jN0SrDsjNSuVXHJqtwTnWqG0B1jZrgmJ/7lj1EmVIByWt1gxGkWvg== + dependencies: + pify "^3.0.0" + path-type@^4.0.0: version "4.0.0" resolved "https://registry.yarnpkg.com/path-type/-/path-type-4.0.0.tgz#84ed01c0a7ba380afe09d90a8c180dcd9d03043b" @@ -9500,6 +9564,11 @@ picomatch@^2.0.4, picomatch@^2.2.1, picomatch@^2.2.3, picomatch@^2.3.1: resolved "https://registry.yarnpkg.com/picomatch/-/picomatch-2.3.1.tgz#3ba3833733646d9d3e4995946c1365a67fb07a42" integrity sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA== +pidtree@^0.3.0: + version "0.3.1" + resolved "https://registry.yarnpkg.com/pidtree/-/pidtree-0.3.1.tgz#ef09ac2cc0533df1f3250ccf2c4d366b0d12114a" + integrity sha512-qQbW94hLHEqCg7nhby4yRC7G2+jYHY4Rguc2bjw7Uug4GIJuu1tvf2uHaZv5Q8zdt+WKJ6qK1FOI6amaWUo5FA== + pify@^2.3.0: version "2.3.0" resolved "https://registry.yarnpkg.com/pify/-/pify-2.3.0.tgz#ed141a6ac043a849ea588498e7dca8b15330e90c" @@ -9548,6 +9617,20 @@ pkg-types@^1.0.3: mlly "^1.2.0" pathe "^1.1.0" +playwright-core@1.40.1: + version "1.40.1" + resolved "https://registry.yarnpkg.com/playwright-core/-/playwright-core-1.40.1.tgz#442d15e86866a87d90d07af528e0afabe4c75c05" + integrity sha512-+hkOycxPiV534c4HhpfX6yrlawqVUzITRKwHAmYfmsVreltEl6fAZJ3DPfLMOODw0H3s1Itd6MDCWmP1fl/QvQ== + +playwright@1.40.1: + version "1.40.1" + resolved "https://registry.yarnpkg.com/playwright/-/playwright-1.40.1.tgz#a11bf8dca15be5a194851dbbf3df235b9f53d7ae" + integrity sha512-2eHI7IioIpQ0bS1Ovg/HszsN/XKNwEG1kbzSDDmADpclKc7CyqkHw7Mg2JCz/bbCxg25QUPcjksoMW7JcIFQmw== + dependencies: + playwright-core "1.40.1" + optionalDependencies: + fsevents "2.3.2" + pngjs@^5.0.0: version "5.0.0" resolved "https://registry.yarnpkg.com/pngjs/-/pngjs-5.0.0.tgz#e79dd2b215767fd9c04561c01236df960bce7fbb" @@ -10703,6 +10786,15 @@ read-cache@^1.0.0: dependencies: pify "^2.3.0" +read-pkg@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/read-pkg/-/read-pkg-3.0.0.tgz#9cbc686978fee65d16c00e2b19c237fcf6e38389" + integrity sha512-BLq/cCO9two+lBgiTYNqD6GdtK8s4NpaWrl6/rCO9w0TUS8oJl7cmToOZfRYllKTISY6nt1U7jQ53brmKqY6BA== + dependencies: + load-json-file "^4.0.0" + normalize-package-data "^2.3.2" + path-type "^3.0.0" + "readable-stream@1 || 2", readable-stream@^2.0.0, readable-stream@^2.0.1, readable-stream@^2.0.2, readable-stream@^2.1.5, readable-stream@^2.2.2, readable-stream@^2.3.3, readable-stream@^2.3.6, readable-stream@~2.3.6: version "2.3.8" resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-2.3.8.tgz#91125e8042bba1b9887f49345f6277027ce8be9b" @@ -10908,7 +11000,7 @@ resolve.exports@^2.0.0: resolved "https://registry.yarnpkg.com/resolve.exports/-/resolve.exports-2.0.2.tgz#f8c934b8e6a13f539e38b7098e2e36134f01e800" integrity sha512-X2UW6Nw3n/aMgDVy+0rSqgHlv39WZAlZrXCdnbyEiKm17DSqHX4MmQMaST3FbeWR5FTuRcUwYAziZajji0Y7mg== -resolve@^1.1.6, resolve@^1.1.7, resolve@^1.10.1, resolve@^1.12.0, resolve@^1.14.2, resolve@^1.15.1, resolve@^1.20.0, resolve@^1.22.0, resolve@^1.22.4: +resolve@^1.1.6, resolve@^1.1.7, resolve@^1.10.0, resolve@^1.10.1, resolve@^1.12.0, resolve@^1.14.2, resolve@^1.15.1, resolve@^1.20.0, resolve@^1.22.0, resolve@^1.22.4: version "1.22.8" resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.22.8.tgz#b6c87a9f2aa06dfab52e3d70ac8cde321fa5a48d" integrity sha512-oKWePCxqpd6FlLvGV1VU0x7bkPmmCNolxzjMf4NczoDnQcIWrAF+cPtZn5i6n+RfD2d9i0tzpKnG6Yk168yIyw== @@ -11127,16 +11219,16 @@ scule@^1.0.0, scule@^1.1.1: resolved "https://registry.yarnpkg.com/scule/-/scule-1.1.1.tgz#82b4d13bb8c729c15849256e749cee0cb52a4d89" integrity sha512-sHtm/SsIK9BUBI3EFT/Gnp9VoKfY6QLvlkvAE6YK7454IF8FSgJEAnJpVdSC7K5/pjI5NfxhzBLW2JAfYA/shQ== +"semver@2 || 3 || 4 || 5", semver@^5.5.0, semver@^5.6.0: + version "5.7.2" + resolved "https://registry.yarnpkg.com/semver/-/semver-5.7.2.tgz#48d55db737c3287cd4835e17fa13feace1c41ef8" + integrity sha512-cBznnQ9KjJqU67B52RMC65CMarK2600WFnbkcaiwWq3xy/5haFJlshgnpjovMVJ+Hff49d8GEn0b87C5pDQ10g== + semver@5.5.0: version "5.5.0" resolved "https://registry.yarnpkg.com/semver/-/semver-5.5.0.tgz#dc4bbc7a6ca9d916dee5d43516f0092b58f7b8ab" integrity sha512-4SJ3dm0WAwWy/NVeioZh5AntkdJoWKxHxcmyP622fOkgHa4z3R0TdBJICINyaSDE6uNwVc8gZr+ZinwZAH4xIA== -semver@^5.5.0, semver@^5.6.0: - version "5.7.2" - resolved "https://registry.yarnpkg.com/semver/-/semver-5.7.2.tgz#48d55db737c3287cd4835e17fa13feace1c41ef8" - integrity sha512-cBznnQ9KjJqU67B52RMC65CMarK2600WFnbkcaiwWq3xy/5haFJlshgnpjovMVJ+Hff49d8GEn0b87C5pDQ10g== - semver@^6.0.0, semver@^6.1.0, semver@^6.1.2, semver@^6.3.0, semver@^6.3.1: version "6.3.1" resolved "https://registry.yarnpkg.com/semver/-/semver-6.3.1.tgz#556d2ef8689146e46dcea4bfdd095f3434dffcb4" @@ -11287,7 +11379,7 @@ shebang-regex@^3.0.0: resolved "https://registry.yarnpkg.com/shebang-regex/-/shebang-regex-3.0.0.tgz#ae16f1644d873ecad843b0307b143362d4c42172" integrity sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A== -shell-quote@^1.8.1: +shell-quote@^1.6.1, shell-quote@^1.8.1: version "1.8.1" resolved "https://registry.yarnpkg.com/shell-quote/-/shell-quote-1.8.1.tgz#6dbf4db75515ad5bac63b4f1894c3a154c766680" integrity sha512-6j1W9l1iAs/4xYBI1SYOVZyFcCis9b4KCLQ8fgAGG07QvzaRLVVRQvAy85yNmmZSjYjg4MWh4gNvlPujU/5LpA== @@ -11506,6 +11598,32 @@ source-map@^0.7.3: resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.7.4.tgz#a9bbe705c9d8846f4e08ff6765acf0f1b0898656" integrity sha512-l3BikUxvPOcn5E74dZiq5BGsTb5yEwhaTSzccU6t4sDOH8NWJCstKO5QT2CvtFoK6F0saL7p9xHAqHOlCPJygA== +spdx-correct@^3.0.0: + version "3.2.0" + resolved "https://registry.yarnpkg.com/spdx-correct/-/spdx-correct-3.2.0.tgz#4f5ab0668f0059e34f9c00dce331784a12de4e9c" + integrity sha512-kN9dJbvnySHULIluDHy32WHRUu3Og7B9sbY7tsFLctQkIqnMh3hErYgdMjTYuqmcXX+lK5T1lnUt3G7zNswmZA== + dependencies: + spdx-expression-parse "^3.0.0" + spdx-license-ids "^3.0.0" + +spdx-exceptions@^2.1.0: + version "2.3.0" + resolved "https://registry.yarnpkg.com/spdx-exceptions/-/spdx-exceptions-2.3.0.tgz#3f28ce1a77a00372683eade4a433183527a2163d" + integrity sha512-/tTrYOC7PPI1nUAgx34hUpqXuyJG+DTHJTnIULG4rDygi4xu/tfgmq1e1cIRwRzwZgo4NLySi+ricLkZkw4i5A== + +spdx-expression-parse@^3.0.0: + version "3.0.1" + resolved "https://registry.yarnpkg.com/spdx-expression-parse/-/spdx-expression-parse-3.0.1.tgz#cf70f50482eefdc98e3ce0a6833e4a53ceeba679" + integrity sha512-cbqHunsQWnJNE6KhVSMsMeH5H/L9EpymbzqTQ3uLwNCLZ1Q481oWaofqH7nO6V07xlXwY6PhQdQ2IedWx/ZK4Q== + dependencies: + spdx-exceptions "^2.1.0" + spdx-license-ids "^3.0.0" + +spdx-license-ids@^3.0.0: + version "3.0.16" + resolved "https://registry.yarnpkg.com/spdx-license-ids/-/spdx-license-ids-3.0.16.tgz#a14f64e0954f6e25cc6587bd4f392522db0d998f" + integrity sha512-eWN+LnM3GR6gPu35WxNgbGl8rmY1AEmoMDvL/QD6zYmPWgywxWqJWNdLGT+ke8dKNWrcYgYjPpG5gbTfghP8rw== + split-string@^3.0.1, split-string@^3.0.2: version "3.1.0" resolved "https://registry.yarnpkg.com/split-string/-/split-string-3.1.0.tgz#7cb09dda3a86585705c64b39a6466038682e8fe2" @@ -11649,6 +11767,15 @@ string-width@^5.0.1, string-width@^5.1.2: emoji-regex "^9.2.2" strip-ansi "^7.0.1" +string.prototype.padend@^3.0.0: + version "3.1.5" + resolved "https://registry.yarnpkg.com/string.prototype.padend/-/string.prototype.padend-3.1.5.tgz#311ef3a4e3c557dd999cdf88fbdde223f2ac0f95" + integrity sha512-DOB27b/2UTTD+4myKUFh+/fXWcu/UDyASIXfg+7VzoCNNGOfWvoyU/x5pvVHr++ztyt/oSYI1BcWBBG/hmlNjA== + dependencies: + call-bind "^1.0.2" + define-properties "^1.2.0" + es-abstract "^1.22.1" + string.prototype.trim@^1.2.8: version "1.2.8" resolved "https://registry.yarnpkg.com/string.prototype.trim/-/string.prototype.trim-1.2.8.tgz#f9ac6f8af4bd55ddfa8895e6aea92a96395393bd" @@ -12584,6 +12711,14 @@ v8-to-istanbul@^9.0.1: "@types/istanbul-lib-coverage" "^2.0.1" convert-source-map "^2.0.0" +validate-npm-package-license@^3.0.1: + version "3.0.4" + resolved "https://registry.yarnpkg.com/validate-npm-package-license/-/validate-npm-package-license-3.0.4.tgz#fc91f6b9c7ba15c857f4cb2c5defeec39d4f410a" + integrity sha512-DpKm2Ui/xN7/HQKCtpZxoRWBhZ9Z0kqtygG8XCgNQ8ZlDnxuQmWhj566j8fN4Cu3/JmbhsDo7fcAJq4s9h27Ew== + dependencies: + spdx-correct "^3.0.0" + spdx-expression-parse "^3.0.0" + vary@^1.1.2, vary@~1.1.2: version "1.1.2" resolved "https://registry.yarnpkg.com/vary/-/vary-1.1.2.tgz#2299f02c6ded30d4a5961b0b9f74524a18f634fc" From ebb9762a23404c1a69a170ca51d1b2c73b20091a Mon Sep 17 00:00:00 2001 From: t-kurasawa Date: Sat, 6 Jan 2024 11:38:43 +0900 Subject: [PATCH 2/4] fix --- components/PrintableMap.vue | 8 ++++---- test-e2e/kamimap.spec.ts | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/components/PrintableMap.vue b/components/PrintableMap.vue index 637c121d..b5fa79ef 100644 --- a/components/PrintableMap.vue +++ b/components/PrintableMap.vue @@ -88,10 +88,10 @@ div .legend-list-outer simplebar(data-simplebar-auto-hide="false") ul.legend-list - li.legend-item( - v-for='(setting, category) in Object.entries(mapConfig.layer_settings)' - v-if="displayMarkersGroupByCategory.some((elm) => elm.category === category)" - ) + li.legend-item( + v-for='(setting, category) in mapConfig.layer_settings' + v-if="displayMarkersGroupByCategory.some((elm) => elm.category === category)" + ) span.legend-mark( :style="{backgroundColor:setting.color}" @click="selectCategory(category), isOpenList=category, isDisplayAllCategory=false" diff --git a/test-e2e/kamimap.spec.ts b/test-e2e/kamimap.spec.ts index da568407..eec14212 100644 --- a/test-e2e/kamimap.spec.ts +++ b/test-e2e/kamimap.spec.ts @@ -9,7 +9,7 @@ test('URL Check', async () => { try { await page.goto('https://kamimap.com/'); await page.waitForLoadState('load'); - await expect(page.url()).toBe('https://kamimap.com/en'); + await expect(page.url()).toBe('https://kamimap.com/en/'); } catch (error) { console.error('Error during page navigation:', error); } From c4dafe1df8620cd0dc78003ca5fba50303aa96e4 Mon Sep 17 00:00:00 2001 From: t-kurasawa Date: Sat, 6 Jan 2024 12:19:16 +0900 Subject: [PATCH 3/4] update README.md --- package.json | 5 +++-- test-e2e/README.md | 8 ++++++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index d102adb5..93858c24 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,8 @@ "test": "npm-run-all --sequential test:unit test:e2e", "test:unit": "jest", "test:jest:coverage": "jest --coverage", - "test:e2e": "playwright test" + "test:e2e": "playwright test", + "test:e2e:trace": "playwright test --trace on" }, "browserslist": [ "last 2 version", @@ -92,4 +93,4 @@ "ts-loader": "^6.2.2", "typescript": "^5.3.3" } -} +} \ No newline at end of file diff --git a/test-e2e/README.md b/test-e2e/README.md index e7851f1f..fc03f9b3 100644 --- a/test-e2e/README.md +++ b/test-e2e/README.md @@ -22,6 +22,14 @@ Playwright を導入する。 ※Windows の方はコマンドプロンプトから実行してください +### テストコードの作成方法 +- Playwright には画面操作を行うことでテストコードを生成する機能があります。画面操作を行いテストコードを追加してください。 + +` npx playwright codegen kamimap.com ` + +https://playwright.dev/docs/codegen-intro + + ### [WIP] WSL 向けの環境構築手順 - Playwright は WSL ではすぐに動かないため以下の対応をお願いします。 From ac96d8cd7f54c0876c2ffbcb522e230ef05164dd Mon Sep 17 00:00:00 2001 From: t-kurasawa Date: Sat, 6 Jan 2024 12:24:04 +0900 Subject: [PATCH 4/4] fix review comments --- .gitignore | 2 ++ test-unit/lib/displayHelper.spec.js | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index bf4646bd..8293ecc9 100644 --- a/.gitignore +++ b/.gitignore @@ -89,6 +89,8 @@ sw.* # Vim swap files *.swp + +# Playwright /test-results/ /playwright-report/ /blob-report/ diff --git a/test-unit/lib/displayHelper.spec.js b/test-unit/lib/displayHelper.spec.js index 88e42650..67831988 100644 --- a/test-unit/lib/displayHelper.spec.js +++ b/test-unit/lib/displayHelper.spec.js @@ -1,7 +1,7 @@ import { getNowYMD } from '~/lib/displayHelper'; describe('getNowYMD', () => { - test('returns the formatted date in Japanese by default', () => { + test('returns the formatted date in Japanese by customization', () => { const mockDate = new Date('2022-01-05T12:34:56'); const result = getNowYMD(mockDate, 'ja'); expect(result).toBe('2022年01月05日12時34分');