From 9c5694729a1d4f65afc5674e9c4fc52dc9ad92df Mon Sep 17 00:00:00 2001 From: Le Vivilet Date: Thu, 18 Jun 2026 16:35:10 +0200 Subject: [PATCH 1/7] feature: rename files --- packages/{explorer-view => pull-request-github}/extension.json | 0 packages/{explorer-view => pull-request-github}/package-lock.json | 0 packages/{explorer-view => pull-request-github}/package.json | 0 .../parts/GetPullRequestVirtualDom/GetPullRequestVirtualDom.ts | 0 .../src/parts/GitHubPullRequest/GitHubPullRequest.ts | 0 .../src/parts/Listen/Listen.ts | 0 .../{explorer-view => pull-request-github}/src/parts/Main/Main.ts | 0 .../src/parts/PullRequestUrl/PullRequestUrl.ts | 0 .../src/parts/PullRequestView/PullRequestView.ts | 0 .../src/parts/PullRequestViewState/PullRequestViewState.ts | 0 .../src/pullRequestWorkerMain.ts | 0 .../test/GetPullRequestVirtualDom.test.ts | 0 .../test/GitHubPullRequest.test.ts | 0 .../{explorer-view => pull-request-github}/test/Listen.test.ts | 0 .../test/PullRequestUrl.test.ts | 0 .../test/PullRequestView.test.ts | 0 packages/{explorer-view => pull-request-github}/tsconfig.json | 0 17 files changed, 0 insertions(+), 0 deletions(-) rename packages/{explorer-view => pull-request-github}/extension.json (100%) rename packages/{explorer-view => pull-request-github}/package-lock.json (100%) rename packages/{explorer-view => pull-request-github}/package.json (100%) rename packages/{explorer-view => pull-request-github}/src/parts/GetPullRequestVirtualDom/GetPullRequestVirtualDom.ts (100%) rename packages/{explorer-view => pull-request-github}/src/parts/GitHubPullRequest/GitHubPullRequest.ts (100%) rename packages/{explorer-view => pull-request-github}/src/parts/Listen/Listen.ts (100%) rename packages/{explorer-view => pull-request-github}/src/parts/Main/Main.ts (100%) rename packages/{explorer-view => pull-request-github}/src/parts/PullRequestUrl/PullRequestUrl.ts (100%) rename packages/{explorer-view => pull-request-github}/src/parts/PullRequestView/PullRequestView.ts (100%) rename packages/{explorer-view => pull-request-github}/src/parts/PullRequestViewState/PullRequestViewState.ts (100%) rename packages/{explorer-view => pull-request-github}/src/pullRequestWorkerMain.ts (100%) rename packages/{explorer-view => pull-request-github}/test/GetPullRequestVirtualDom.test.ts (100%) rename packages/{explorer-view => pull-request-github}/test/GitHubPullRequest.test.ts (100%) rename packages/{explorer-view => pull-request-github}/test/Listen.test.ts (100%) rename packages/{explorer-view => pull-request-github}/test/PullRequestUrl.test.ts (100%) rename packages/{explorer-view => pull-request-github}/test/PullRequestView.test.ts (100%) rename packages/{explorer-view => pull-request-github}/tsconfig.json (100%) diff --git a/packages/explorer-view/extension.json b/packages/pull-request-github/extension.json similarity index 100% rename from packages/explorer-view/extension.json rename to packages/pull-request-github/extension.json diff --git a/packages/explorer-view/package-lock.json b/packages/pull-request-github/package-lock.json similarity index 100% rename from packages/explorer-view/package-lock.json rename to packages/pull-request-github/package-lock.json diff --git a/packages/explorer-view/package.json b/packages/pull-request-github/package.json similarity index 100% rename from packages/explorer-view/package.json rename to packages/pull-request-github/package.json diff --git a/packages/explorer-view/src/parts/GetPullRequestVirtualDom/GetPullRequestVirtualDom.ts b/packages/pull-request-github/src/parts/GetPullRequestVirtualDom/GetPullRequestVirtualDom.ts similarity index 100% rename from packages/explorer-view/src/parts/GetPullRequestVirtualDom/GetPullRequestVirtualDom.ts rename to packages/pull-request-github/src/parts/GetPullRequestVirtualDom/GetPullRequestVirtualDom.ts diff --git a/packages/explorer-view/src/parts/GitHubPullRequest/GitHubPullRequest.ts b/packages/pull-request-github/src/parts/GitHubPullRequest/GitHubPullRequest.ts similarity index 100% rename from packages/explorer-view/src/parts/GitHubPullRequest/GitHubPullRequest.ts rename to packages/pull-request-github/src/parts/GitHubPullRequest/GitHubPullRequest.ts diff --git a/packages/explorer-view/src/parts/Listen/Listen.ts b/packages/pull-request-github/src/parts/Listen/Listen.ts similarity index 100% rename from packages/explorer-view/src/parts/Listen/Listen.ts rename to packages/pull-request-github/src/parts/Listen/Listen.ts diff --git a/packages/explorer-view/src/parts/Main/Main.ts b/packages/pull-request-github/src/parts/Main/Main.ts similarity index 100% rename from packages/explorer-view/src/parts/Main/Main.ts rename to packages/pull-request-github/src/parts/Main/Main.ts diff --git a/packages/explorer-view/src/parts/PullRequestUrl/PullRequestUrl.ts b/packages/pull-request-github/src/parts/PullRequestUrl/PullRequestUrl.ts similarity index 100% rename from packages/explorer-view/src/parts/PullRequestUrl/PullRequestUrl.ts rename to packages/pull-request-github/src/parts/PullRequestUrl/PullRequestUrl.ts diff --git a/packages/explorer-view/src/parts/PullRequestView/PullRequestView.ts b/packages/pull-request-github/src/parts/PullRequestView/PullRequestView.ts similarity index 100% rename from packages/explorer-view/src/parts/PullRequestView/PullRequestView.ts rename to packages/pull-request-github/src/parts/PullRequestView/PullRequestView.ts diff --git a/packages/explorer-view/src/parts/PullRequestViewState/PullRequestViewState.ts b/packages/pull-request-github/src/parts/PullRequestViewState/PullRequestViewState.ts similarity index 100% rename from packages/explorer-view/src/parts/PullRequestViewState/PullRequestViewState.ts rename to packages/pull-request-github/src/parts/PullRequestViewState/PullRequestViewState.ts diff --git a/packages/explorer-view/src/pullRequestWorkerMain.ts b/packages/pull-request-github/src/pullRequestWorkerMain.ts similarity index 100% rename from packages/explorer-view/src/pullRequestWorkerMain.ts rename to packages/pull-request-github/src/pullRequestWorkerMain.ts diff --git a/packages/explorer-view/test/GetPullRequestVirtualDom.test.ts b/packages/pull-request-github/test/GetPullRequestVirtualDom.test.ts similarity index 100% rename from packages/explorer-view/test/GetPullRequestVirtualDom.test.ts rename to packages/pull-request-github/test/GetPullRequestVirtualDom.test.ts diff --git a/packages/explorer-view/test/GitHubPullRequest.test.ts b/packages/pull-request-github/test/GitHubPullRequest.test.ts similarity index 100% rename from packages/explorer-view/test/GitHubPullRequest.test.ts rename to packages/pull-request-github/test/GitHubPullRequest.test.ts diff --git a/packages/explorer-view/test/Listen.test.ts b/packages/pull-request-github/test/Listen.test.ts similarity index 100% rename from packages/explorer-view/test/Listen.test.ts rename to packages/pull-request-github/test/Listen.test.ts diff --git a/packages/explorer-view/test/PullRequestUrl.test.ts b/packages/pull-request-github/test/PullRequestUrl.test.ts similarity index 100% rename from packages/explorer-view/test/PullRequestUrl.test.ts rename to packages/pull-request-github/test/PullRequestUrl.test.ts diff --git a/packages/explorer-view/test/PullRequestView.test.ts b/packages/pull-request-github/test/PullRequestView.test.ts similarity index 100% rename from packages/explorer-view/test/PullRequestView.test.ts rename to packages/pull-request-github/test/PullRequestView.test.ts diff --git a/packages/explorer-view/tsconfig.json b/packages/pull-request-github/tsconfig.json similarity index 100% rename from packages/explorer-view/tsconfig.json rename to packages/pull-request-github/tsconfig.json From 17c5541d3d9d3995d6920101655261632a032487 Mon Sep 17 00:00:00 2001 From: Le Vivilet Date: Thu, 18 Jun 2026 16:36:53 +0200 Subject: [PATCH 2/7] tsc --- ...wlet.explorer-blur.ts => viewlet.pull-requests-github-blur.ts} | 0 .../{pull-request-github => pull-requests-github}/extension.json | 0 .../package-lock.json | 0 .../{pull-request-github => pull-requests-github}/package.json | 0 .../parts/GetPullRequestVirtualDom/GetPullRequestVirtualDom.ts | 0 .../src/parts/GitHubPullRequest/GitHubPullRequest.ts | 0 .../src/parts/Listen/Listen.ts | 0 .../src/parts/Main/Main.ts | 0 .../src/parts/PullRequestUrl/PullRequestUrl.ts | 0 .../src/parts/PullRequestView/PullRequestView.ts | 0 .../src/parts/PullRequestViewState/PullRequestViewState.ts | 0 .../src/pullRequestWorkerMain.ts | 0 .../test/GetPullRequestVirtualDom.test.ts | 0 .../test/GitHubPullRequest.test.ts | 0 .../test/Listen.test.ts | 0 .../test/PullRequestUrl.test.ts | 0 .../test/PullRequestView.test.ts | 0 .../{pull-request-github => pull-requests-github}/tsconfig.json | 0 18 files changed, 0 insertions(+), 0 deletions(-) rename packages/e2e/src/{viewlet.explorer-blur.ts => viewlet.pull-requests-github-blur.ts} (100%) rename packages/{pull-request-github => pull-requests-github}/extension.json (100%) rename packages/{pull-request-github => pull-requests-github}/package-lock.json (100%) rename packages/{pull-request-github => pull-requests-github}/package.json (100%) rename packages/{pull-request-github => pull-requests-github}/src/parts/GetPullRequestVirtualDom/GetPullRequestVirtualDom.ts (100%) rename packages/{pull-request-github => pull-requests-github}/src/parts/GitHubPullRequest/GitHubPullRequest.ts (100%) rename packages/{pull-request-github => pull-requests-github}/src/parts/Listen/Listen.ts (100%) rename packages/{pull-request-github => pull-requests-github}/src/parts/Main/Main.ts (100%) rename packages/{pull-request-github => pull-requests-github}/src/parts/PullRequestUrl/PullRequestUrl.ts (100%) rename packages/{pull-request-github => pull-requests-github}/src/parts/PullRequestView/PullRequestView.ts (100%) rename packages/{pull-request-github => pull-requests-github}/src/parts/PullRequestViewState/PullRequestViewState.ts (100%) rename packages/{pull-request-github => pull-requests-github}/src/pullRequestWorkerMain.ts (100%) rename packages/{pull-request-github => pull-requests-github}/test/GetPullRequestVirtualDom.test.ts (100%) rename packages/{pull-request-github => pull-requests-github}/test/GitHubPullRequest.test.ts (100%) rename packages/{pull-request-github => pull-requests-github}/test/Listen.test.ts (100%) rename packages/{pull-request-github => pull-requests-github}/test/PullRequestUrl.test.ts (100%) rename packages/{pull-request-github => pull-requests-github}/test/PullRequestView.test.ts (100%) rename packages/{pull-request-github => pull-requests-github}/tsconfig.json (100%) diff --git a/packages/e2e/src/viewlet.explorer-blur.ts b/packages/e2e/src/viewlet.pull-requests-github-blur.ts similarity index 100% rename from packages/e2e/src/viewlet.explorer-blur.ts rename to packages/e2e/src/viewlet.pull-requests-github-blur.ts diff --git a/packages/pull-request-github/extension.json b/packages/pull-requests-github/extension.json similarity index 100% rename from packages/pull-request-github/extension.json rename to packages/pull-requests-github/extension.json diff --git a/packages/pull-request-github/package-lock.json b/packages/pull-requests-github/package-lock.json similarity index 100% rename from packages/pull-request-github/package-lock.json rename to packages/pull-requests-github/package-lock.json diff --git a/packages/pull-request-github/package.json b/packages/pull-requests-github/package.json similarity index 100% rename from packages/pull-request-github/package.json rename to packages/pull-requests-github/package.json diff --git a/packages/pull-request-github/src/parts/GetPullRequestVirtualDom/GetPullRequestVirtualDom.ts b/packages/pull-requests-github/src/parts/GetPullRequestVirtualDom/GetPullRequestVirtualDom.ts similarity index 100% rename from packages/pull-request-github/src/parts/GetPullRequestVirtualDom/GetPullRequestVirtualDom.ts rename to packages/pull-requests-github/src/parts/GetPullRequestVirtualDom/GetPullRequestVirtualDom.ts diff --git a/packages/pull-request-github/src/parts/GitHubPullRequest/GitHubPullRequest.ts b/packages/pull-requests-github/src/parts/GitHubPullRequest/GitHubPullRequest.ts similarity index 100% rename from packages/pull-request-github/src/parts/GitHubPullRequest/GitHubPullRequest.ts rename to packages/pull-requests-github/src/parts/GitHubPullRequest/GitHubPullRequest.ts diff --git a/packages/pull-request-github/src/parts/Listen/Listen.ts b/packages/pull-requests-github/src/parts/Listen/Listen.ts similarity index 100% rename from packages/pull-request-github/src/parts/Listen/Listen.ts rename to packages/pull-requests-github/src/parts/Listen/Listen.ts diff --git a/packages/pull-request-github/src/parts/Main/Main.ts b/packages/pull-requests-github/src/parts/Main/Main.ts similarity index 100% rename from packages/pull-request-github/src/parts/Main/Main.ts rename to packages/pull-requests-github/src/parts/Main/Main.ts diff --git a/packages/pull-request-github/src/parts/PullRequestUrl/PullRequestUrl.ts b/packages/pull-requests-github/src/parts/PullRequestUrl/PullRequestUrl.ts similarity index 100% rename from packages/pull-request-github/src/parts/PullRequestUrl/PullRequestUrl.ts rename to packages/pull-requests-github/src/parts/PullRequestUrl/PullRequestUrl.ts diff --git a/packages/pull-request-github/src/parts/PullRequestView/PullRequestView.ts b/packages/pull-requests-github/src/parts/PullRequestView/PullRequestView.ts similarity index 100% rename from packages/pull-request-github/src/parts/PullRequestView/PullRequestView.ts rename to packages/pull-requests-github/src/parts/PullRequestView/PullRequestView.ts diff --git a/packages/pull-request-github/src/parts/PullRequestViewState/PullRequestViewState.ts b/packages/pull-requests-github/src/parts/PullRequestViewState/PullRequestViewState.ts similarity index 100% rename from packages/pull-request-github/src/parts/PullRequestViewState/PullRequestViewState.ts rename to packages/pull-requests-github/src/parts/PullRequestViewState/PullRequestViewState.ts diff --git a/packages/pull-request-github/src/pullRequestWorkerMain.ts b/packages/pull-requests-github/src/pullRequestWorkerMain.ts similarity index 100% rename from packages/pull-request-github/src/pullRequestWorkerMain.ts rename to packages/pull-requests-github/src/pullRequestWorkerMain.ts diff --git a/packages/pull-request-github/test/GetPullRequestVirtualDom.test.ts b/packages/pull-requests-github/test/GetPullRequestVirtualDom.test.ts similarity index 100% rename from packages/pull-request-github/test/GetPullRequestVirtualDom.test.ts rename to packages/pull-requests-github/test/GetPullRequestVirtualDom.test.ts diff --git a/packages/pull-request-github/test/GitHubPullRequest.test.ts b/packages/pull-requests-github/test/GitHubPullRequest.test.ts similarity index 100% rename from packages/pull-request-github/test/GitHubPullRequest.test.ts rename to packages/pull-requests-github/test/GitHubPullRequest.test.ts diff --git a/packages/pull-request-github/test/Listen.test.ts b/packages/pull-requests-github/test/Listen.test.ts similarity index 100% rename from packages/pull-request-github/test/Listen.test.ts rename to packages/pull-requests-github/test/Listen.test.ts diff --git a/packages/pull-request-github/test/PullRequestUrl.test.ts b/packages/pull-requests-github/test/PullRequestUrl.test.ts similarity index 100% rename from packages/pull-request-github/test/PullRequestUrl.test.ts rename to packages/pull-requests-github/test/PullRequestUrl.test.ts diff --git a/packages/pull-request-github/test/PullRequestView.test.ts b/packages/pull-requests-github/test/PullRequestView.test.ts similarity index 100% rename from packages/pull-request-github/test/PullRequestView.test.ts rename to packages/pull-requests-github/test/PullRequestView.test.ts diff --git a/packages/pull-request-github/tsconfig.json b/packages/pull-requests-github/tsconfig.json similarity index 100% rename from packages/pull-request-github/tsconfig.json rename to packages/pull-requests-github/tsconfig.json From 84b333e2d769ce17de5f3e9606e7a5c82e5a3755 Mon Sep 17 00:00:00 2001 From: Le Vivilet Date: Thu, 18 Jun 2026 16:44:03 +0200 Subject: [PATCH 3/7] rename --- README.md | 8 +- package-lock.json | 4 +- package.json | 4 +- packages/build/src/build-static.ts | 8 +- packages/build/src/build.ts | 4 +- packages/build/src/bundleJs.ts | 2 +- packages/build/src/measureMemory.ts | 2 +- .../src/viewlet.pull-requests-github-blur.ts | 8 +- packages/pull-requests-github/package.json | 2 +- .../GetPullRequestVirtualDom.ts | 73 +-------------- .../src/parts/RenderField/RenderField.ts | 24 +++++ .../RenderPullRequest/RenderPullRequest.ts | 18 ++++ .../src/parts/RenderStatus/RenderStatus.ts | 39 ++++++++ .../test/RenderField.test.ts | 42 +++++++++ .../test/RenderPullRequest.test.ts | 61 +++++++++++++ .../test/RenderStatus.test.ts | 88 +++++++++++++++++++ packages/server/package-lock.json | 4 +- packages/server/package.json | 2 +- scripts/update-dependencies.sh | 4 +- tsconfig.json | 2 +- 20 files changed, 300 insertions(+), 99 deletions(-) create mode 100644 packages/pull-requests-github/src/parts/RenderField/RenderField.ts create mode 100644 packages/pull-requests-github/src/parts/RenderPullRequest/RenderPullRequest.ts create mode 100644 packages/pull-requests-github/src/parts/RenderStatus/RenderStatus.ts create mode 100644 packages/pull-requests-github/test/RenderField.test.ts create mode 100644 packages/pull-requests-github/test/RenderPullRequest.test.ts create mode 100644 packages/pull-requests-github/test/RenderStatus.test.ts diff --git a/README.md b/README.md index a05f462..e7b1ec4 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,12 @@ -# Explorer View +# Pull Requests GitHub View -WebWorker for the explorer view functionality in Lvce Editor. +WebWorker for the pull requests github view functionality in Lvce Editor. ## Contributing ```sh -git clone git@github.com:lvce-editor/explorer-view.git && -cd explorer-view && +git clone git@github.com:lvce-editor/pull-requests-github-view.git && +cd pull-requests-github-view && npm ci && npm test ``` diff --git a/package-lock.json b/package-lock.json index 674be07..21e6167 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,11 +1,11 @@ { - "name": "@lvce-editor/explorer-view-monorepo", + "name": "@lvce-editor/pull-requests-github-view-monorepo", "version": "0.0.0-dev", "lockfileVersion": 3, "requires": true, "packages": { "": { - "name": "@lvce-editor/explorer-view-monorepo", + "name": "@lvce-editor/pull-requests-github-view-monorepo", "version": "0.0.0-dev", "hasInstallScript": true, "license": "MIT", diff --git a/package.json b/package.json index e40001e..9dbd9cc 100644 --- a/package.json +++ b/package.json @@ -1,12 +1,12 @@ { - "name": "@lvce-editor/explorer-view-monorepo", + "name": "@lvce-editor/pull-requests-github-view-monorepo", "version": "0.0.0-dev", "license": "MIT", "type": "module", "scripts": { "build": "node packages/build/src/build.ts", "build:static": "node packages/build/src/build-static.ts", - "build:watch": "./packages/build/node_modules/.bin/esbuild --format=esm --bundle --external:node:buffer --external:electron --external:ws --external:node:worker_threads --watch packages/explorer-view/src/pullRequestWorkerMain.ts --outfile=.tmp/dist/dist/pullRequestWorkerMain.js", + "build:watch": "./packages/build/node_modules/.bin/esbuild --format=esm --bundle --external:node:buffer --external:electron --external:ws --external:node:worker_threads --watch packages/pull-requests-github/src/pullRequestWorkerMain.ts --outfile=.tmp/dist/dist/pullRequestWorkerMain.js", "dev": "node packages/build/src/dev.ts", "e2e": "cd packages/e2e && npm run e2e", "format": "prettier --write .", diff --git a/packages/build/src/build-static.ts b/packages/build/src/build-static.ts index e0d576f..9141a9f 100644 --- a/packages/build/src/build-static.ts +++ b/packages/build/src/build-static.ts @@ -9,7 +9,7 @@ const sharedProcessUrl = pathToFileURL(sharedProcessPath).toString() const sharedProcess = await import(sharedProcessUrl) -process.env.PATH_PREFIX = '/pull-request-github' +process.env.PATH_PREFIX = '/pull-requests-github' const { commitHash } = await sharedProcess.exportStatic({ root, extensionPath: '', @@ -27,9 +27,9 @@ const content = await readFile(rendererWorkerPath, 'utf8') const workerPath = join(root, '.tmp/dist/dist/pullRequestWorkerMain.js') const remoteUrl = getRemoteUrl(workerPath) -const occurrence = `// const explorerWorkerUrl = \`\${assetDir}/packages/explorer-worker/dist/explorerViewWorkerMain.js\` -const explorerWorkerUrl = \`${remoteUrl}\`` -const replacement = `const explorerWorkerUrl = \`\${assetDir}/packages/explorer-worker/dist/explorerViewWorkerMain.js\`` +const occurrence = `// const pullRequestsGithubWorkerUrl = \`\${assetDir}/packages/pull-requests-github-worker/dist/pullRequestsGithubViewWorkerMain.js\` +const pullRequestsGithubWorkerUrl = \`${remoteUrl}\`` +const replacement = `const pullRequestsGithubWorkerUrl = \`\${assetDir}/packages/pull-requests-github-worker/dist/pullRequestsGithubViewWorkerMain.js\`` if (content.includes(occurrence)) { const newContent = content.replace(occurrence, replacement) await writeFile(rendererWorkerPath, newContent) diff --git a/packages/build/src/build.ts b/packages/build/src/build.ts index 9c3bc40..72824a0 100644 --- a/packages/build/src/build.ts +++ b/packages/build/src/build.ts @@ -56,7 +56,7 @@ await bundleJs() const version = await getVersion() -const packageJson = await readJson(join(root, 'packages', 'explorer-view', 'package.json')) +const packageJson = await readJson(join(root, 'packages', 'pull-requests-github', 'package.json')) delete packageJson.scripts delete packageJson.devDependencies @@ -70,6 +70,6 @@ packageJson.main = 'dist/pullRequestWorkerMain.js' await writeJson(join(dist, 'package.json'), packageJson) -await cp(join(root, 'packages', 'explorer-view', 'extension.json'), join(dist, 'extension.json')) +await cp(join(root, 'packages', 'pull-requests-github', 'extension.json'), join(dist, 'extension.json')) await cp(join(root, 'README.md'), join(dist, 'README.md')) await cp(join(root, 'LICENSE'), join(dist, 'LICENSE')) diff --git a/packages/build/src/bundleJs.ts b/packages/build/src/bundleJs.ts index 1f23eda..62971cd 100644 --- a/packages/build/src/bundleJs.ts +++ b/packages/build/src/bundleJs.ts @@ -6,7 +6,7 @@ import { rollup, type RollupOptions } from 'rollup' import { root } from './root.ts' const options: RollupOptions = { - input: join(root, 'packages/explorer-view/src/pullRequestWorkerMain.ts'), + input: join(root, 'packages/pull-requests-github/src/pullRequestWorkerMain.ts'), preserveEntrySignatures: 'strict', treeshake: { propertyReadSideEffects: false, diff --git a/packages/build/src/measureMemory.ts b/packages/build/src/measureMemory.ts index 4ef21de..d8424b0 100644 --- a/packages/build/src/measureMemory.ts +++ b/packages/build/src/measureMemory.ts @@ -6,7 +6,7 @@ const threshold = 570_000 const instantiations = 9000 -const instantiationsPath = join(root, 'packages', 'explorer-view') +const instantiationsPath = join(root, 'packages', 'pull-requests-github') const workerPath = join(root, '.tmp/dist/dist/pullRequestWorkerMain.js') diff --git a/packages/e2e/src/viewlet.pull-requests-github-blur.ts b/packages/e2e/src/viewlet.pull-requests-github-blur.ts index fb3dac9..d2fad4a 100644 --- a/packages/e2e/src/viewlet.pull-requests-github-blur.ts +++ b/packages/e2e/src/viewlet.pull-requests-github-blur.ts @@ -1,18 +1,18 @@ import type { Test } from '@lvce-editor/test-with-playwright' -export const name = 'viewlet.explorer-blur' +export const name = 'viewlet.pull-requests-github-blur' -export const test: Test = async ({ expect, Explorer, FileSystem, Locator, Workspace }) => { +export const test: Test = async ({ expect, Explorer: PullRequestsGithub, FileSystem, Locator, Workspace }) => { // arrange const tmpDir = await FileSystem.getTmpDir() await FileSystem.writeFile(`${tmpDir}/file1.txt`, 'content 1') await FileSystem.writeFile(`${tmpDir}/file2.txt`, 'content 2') await FileSystem.writeFile(`${tmpDir}/file3.txt`, 'content 3') await Workspace.setPath(tmpDir) - await Explorer.selectIndices([0, 1]) + await PullRequestsGithub.selectIndices([0, 1]) // act - await Explorer.handleBlur() + await PullRequestsGithub.handleBlur() // assert const file1 = Locator('.TreeItem').nth(0) diff --git a/packages/pull-requests-github/package.json b/packages/pull-requests-github/package.json index b6be924..133521e 100644 --- a/packages/pull-requests-github/package.json +++ b/packages/pull-requests-github/package.json @@ -4,7 +4,7 @@ "description": "Pull Request View", "repository": { "type": "git", - "url": "git+https://github.com/lvce-editor/pull-request-github.git" + "url": "git+https://github.com/lvce-editor/pull-requests-github.git" }, "license": "MIT", "author": "Lvce Editor", diff --git a/packages/pull-requests-github/src/parts/GetPullRequestVirtualDom/GetPullRequestVirtualDom.ts b/packages/pull-requests-github/src/parts/GetPullRequestVirtualDom/GetPullRequestVirtualDom.ts index 7b3653d..46c90ff 100644 --- a/packages/pull-requests-github/src/parts/GetPullRequestVirtualDom/GetPullRequestVirtualDom.ts +++ b/packages/pull-requests-github/src/parts/GetPullRequestVirtualDom/GetPullRequestVirtualDom.ts @@ -1,78 +1,7 @@ import type { VirtualDomNode } from '@lvce-editor/virtual-dom-worker' import { text, VirtualDomElements } from '@lvce-editor/virtual-dom-worker' -import type { PullRequestData } from '../GitHubPullRequest/GitHubPullRequest.ts' import type { PullRequestViewState } from '../PullRequestViewState/PullRequestViewState.ts' -import * as PullRequestViewStatus from '../PullRequestViewState/PullRequestViewState.ts' - -const renderField = (label: string, value: string): readonly VirtualDomNode[] => { - return [ - { - childCount: 2, - className: 'PullRequestField', - type: VirtualDomElements.Div, - }, - { - childCount: 1, - className: 'PullRequestFieldLabel', - type: VirtualDomElements.Div, - }, - text(label), - { - childCount: 1, - className: 'PullRequestFieldValue', - type: VirtualDomElements.Div, - }, - text(value || '-'), - ] -} - -const renderPullRequest = (pullRequest: PullRequestData): readonly VirtualDomNode[] => { - return [ - { - childCount: 4, - className: 'PullRequestDetails', - type: VirtualDomElements.Div, - }, - ...renderField('Title', pullRequest.title), - ...renderField('Head', pullRequest.headBranch), - ...renderField('Base', pullRequest.baseBranch), - ...renderField('Description', pullRequest.description || 'No description'), - ] -} - -const renderStatus = (state: PullRequestViewState): readonly VirtualDomNode[] => { - if (state.status === PullRequestViewStatus.Loading) { - return [ - { - childCount: 1, - className: 'PullRequestMessage', - type: VirtualDomElements.Div, - }, - text('Loading pull request...'), - ] - } - if (state.status === PullRequestViewStatus.Error) { - return [ - { - childCount: 1, - className: 'PullRequestMessage PullRequestMessageError', - type: VirtualDomElements.Div, - }, - text(state.error), - ] - } - if (state.status === PullRequestViewStatus.Ready && state.pullRequest) { - return renderPullRequest(state.pullRequest) - } - return [ - { - childCount: 1, - className: 'PullRequestMessage', - type: VirtualDomElements.Div, - }, - text('Enter a GitHub pull request URL.'), - ] -} +import { renderStatus } from '../RenderStatus/RenderStatus.ts' export const getPullRequestVirtualDom = (state: PullRequestViewState): readonly VirtualDomNode[] => { const statusDom = renderStatus(state) diff --git a/packages/pull-requests-github/src/parts/RenderField/RenderField.ts b/packages/pull-requests-github/src/parts/RenderField/RenderField.ts new file mode 100644 index 0000000..524b702 --- /dev/null +++ b/packages/pull-requests-github/src/parts/RenderField/RenderField.ts @@ -0,0 +1,24 @@ +import type { VirtualDomNode } from '@lvce-editor/virtual-dom-worker' +import { text, VirtualDomElements } from '@lvce-editor/virtual-dom-worker' + +export const renderField = (label: string, value: string): readonly VirtualDomNode[] => { + return [ + { + childCount: 2, + className: 'PullRequestField', + type: VirtualDomElements.Div, + }, + { + childCount: 1, + className: 'PullRequestFieldLabel', + type: VirtualDomElements.Div, + }, + text(label), + { + childCount: 1, + className: 'PullRequestFieldValue', + type: VirtualDomElements.Div, + }, + text(value || '-'), + ] +} diff --git a/packages/pull-requests-github/src/parts/RenderPullRequest/RenderPullRequest.ts b/packages/pull-requests-github/src/parts/RenderPullRequest/RenderPullRequest.ts new file mode 100644 index 0000000..b05c43b --- /dev/null +++ b/packages/pull-requests-github/src/parts/RenderPullRequest/RenderPullRequest.ts @@ -0,0 +1,18 @@ +import type { VirtualDomNode } from '@lvce-editor/virtual-dom-worker' +import { VirtualDomElements } from '@lvce-editor/virtual-dom-worker' +import type { PullRequestData } from '../GitHubPullRequest/GitHubPullRequest.ts' +import { renderField } from '../RenderField/RenderField.ts' + +export const renderPullRequest = (pullRequest: PullRequestData): readonly VirtualDomNode[] => { + return [ + { + childCount: 4, + className: 'PullRequestDetails', + type: VirtualDomElements.Div, + }, + ...renderField('Title', pullRequest.title), + ...renderField('Head', pullRequest.headBranch), + ...renderField('Base', pullRequest.baseBranch), + ...renderField('Description', pullRequest.description || 'No description'), + ] +} diff --git a/packages/pull-requests-github/src/parts/RenderStatus/RenderStatus.ts b/packages/pull-requests-github/src/parts/RenderStatus/RenderStatus.ts new file mode 100644 index 0000000..e37c607 --- /dev/null +++ b/packages/pull-requests-github/src/parts/RenderStatus/RenderStatus.ts @@ -0,0 +1,39 @@ +import type { VirtualDomNode } from '@lvce-editor/virtual-dom-worker' +import { text, VirtualDomElements } from '@lvce-editor/virtual-dom-worker' +import type { PullRequestViewState } from '../PullRequestViewState/PullRequestViewState.ts' +import * as PullRequestViewStatus from '../PullRequestViewState/PullRequestViewState.ts' +import { renderPullRequest } from '../RenderPullRequest/RenderPullRequest.ts' + +export const renderStatus = (state: PullRequestViewState): readonly VirtualDomNode[] => { + if (state.status === PullRequestViewStatus.Loading) { + return [ + { + childCount: 1, + className: 'PullRequestMessage', + type: VirtualDomElements.Div, + }, + text('Loading pull request...'), + ] + } + if (state.status === PullRequestViewStatus.Error) { + return [ + { + childCount: 1, + className: 'PullRequestMessage PullRequestMessageError', + type: VirtualDomElements.Div, + }, + text(state.error), + ] + } + if (state.status === PullRequestViewStatus.Ready && state.pullRequest) { + return renderPullRequest(state.pullRequest) + } + return [ + { + childCount: 1, + className: 'PullRequestMessage', + type: VirtualDomElements.Div, + }, + text('Enter a GitHub pull request URL.'), + ] +} diff --git a/packages/pull-requests-github/test/RenderField.test.ts b/packages/pull-requests-github/test/RenderField.test.ts new file mode 100644 index 0000000..69875d0 --- /dev/null +++ b/packages/pull-requests-github/test/RenderField.test.ts @@ -0,0 +1,42 @@ +import { expect, test } from '@jest/globals' +import { renderField } from '../src/parts/RenderField/RenderField.ts' + +test('renderField renders label and value', () => { + const dom = renderField('Title', 'Add feature') + + expect(dom).toEqual( + expect.arrayContaining([ + expect.objectContaining({ + childCount: 2, + className: 'PullRequestField', + }), + expect.objectContaining({ + className: 'PullRequestFieldLabel', + }), + expect.objectContaining({ + text: 'Title', + }), + expect.objectContaining({ + className: 'PullRequestFieldValue', + }), + expect.objectContaining({ + text: 'Add feature', + }), + ]), + ) +}) + +test('renderField renders placeholder for empty value', () => { + const dom = renderField('Description', '') + + expect(dom).toEqual( + expect.arrayContaining([ + expect.objectContaining({ + text: 'Description', + }), + expect.objectContaining({ + text: '-', + }), + ]), + ) +}) diff --git a/packages/pull-requests-github/test/RenderPullRequest.test.ts b/packages/pull-requests-github/test/RenderPullRequest.test.ts new file mode 100644 index 0000000..54753f5 --- /dev/null +++ b/packages/pull-requests-github/test/RenderPullRequest.test.ts @@ -0,0 +1,61 @@ +import { expect, test } from '@jest/globals' +import { renderPullRequest } from '../src/parts/RenderPullRequest/RenderPullRequest.ts' + +test('renderPullRequest renders pull request fields', () => { + const dom = renderPullRequest({ + baseBranch: 'main', + description: 'description', + headBranch: 'feature', + title: 'Add feature', + }) + + expect(dom).toEqual( + expect.arrayContaining([ + expect.objectContaining({ + childCount: 4, + className: 'PullRequestDetails', + }), + expect.objectContaining({ + text: 'Title', + }), + expect.objectContaining({ + text: 'Add feature', + }), + expect.objectContaining({ + text: 'Head', + }), + expect.objectContaining({ + text: 'feature', + }), + expect.objectContaining({ + text: 'Base', + }), + expect.objectContaining({ + text: 'main', + }), + expect.objectContaining({ + text: 'Description', + }), + expect.objectContaining({ + text: 'description', + }), + ]), + ) +}) + +test('renderPullRequest renders default description', () => { + const dom = renderPullRequest({ + baseBranch: 'main', + description: '', + headBranch: 'feature', + title: 'Add feature', + }) + + expect(dom).toEqual( + expect.arrayContaining([ + expect.objectContaining({ + text: 'No description', + }), + ]), + ) +}) diff --git a/packages/pull-requests-github/test/RenderStatus.test.ts b/packages/pull-requests-github/test/RenderStatus.test.ts new file mode 100644 index 0000000..74e5494 --- /dev/null +++ b/packages/pull-requests-github/test/RenderStatus.test.ts @@ -0,0 +1,88 @@ +import { expect, test } from '@jest/globals' +import { renderStatus } from '../src/parts/RenderStatus/RenderStatus.ts' +import * as PullRequestViewStatus from '../src/parts/PullRequestViewState/PullRequestViewState.ts' + +test('renderStatus renders loading state', () => { + const dom = renderStatus({ + error: '', + pullRequest: undefined, + status: PullRequestViewStatus.Loading, + url: 'https://github.com/owner/repo/pull/1', + }) + + expect(dom).toEqual( + expect.arrayContaining([ + expect.objectContaining({ + className: 'PullRequestMessage', + }), + expect.objectContaining({ + text: 'Loading pull request...', + }), + ]), + ) +}) + +test('renderStatus renders error state', () => { + const dom = renderStatus({ + error: 'Not Found', + pullRequest: undefined, + status: PullRequestViewStatus.Error, + url: 'https://github.com/owner/repo/pull/1', + }) + + expect(dom).toEqual( + expect.arrayContaining([ + expect.objectContaining({ + className: 'PullRequestMessage PullRequestMessageError', + }), + expect.objectContaining({ + text: 'Not Found', + }), + ]), + ) +}) + +test('renderStatus renders ready state', () => { + const dom = renderStatus({ + error: '', + pullRequest: { + baseBranch: 'main', + description: 'description', + headBranch: 'feature', + title: 'Add feature', + }, + status: PullRequestViewStatus.Ready, + url: 'https://github.com/owner/repo/pull/1', + }) + + expect(dom).toEqual( + expect.arrayContaining([ + expect.objectContaining({ + className: 'PullRequestDetails', + }), + expect.objectContaining({ + text: 'Add feature', + }), + ]), + ) +}) + +test('renderStatus renders empty state', () => { + const dom = renderStatus({ + error: '', + pullRequest: undefined, + status: PullRequestViewStatus.Empty, + url: '', + }) + + expect(dom).toEqual( + expect.arrayContaining([ + expect.objectContaining({ + className: 'PullRequestMessage', + }), + expect.objectContaining({ + text: 'Enter a GitHub pull request URL.', + }), + ]), + ) +}) diff --git a/packages/server/package-lock.json b/packages/server/package-lock.json index 10e4204..a68ea6b 100644 --- a/packages/server/package-lock.json +++ b/packages/server/package-lock.json @@ -1,11 +1,11 @@ { - "name": "@lvce-editor/explorer-view-server", + "name": "@lvce-editor/pull-requests-github-view-server", "version": "0.0.0-dev", "lockfileVersion": 3, "requires": true, "packages": { "": { - "name": "@lvce-editor/explorer-view-server", + "name": "@lvce-editor/pull-requests-github-view-server", "version": "0.0.0-dev", "license": "MIT", "dependencies": { diff --git a/packages/server/package.json b/packages/server/package.json index adb8021..5a51234 100644 --- a/packages/server/package.json +++ b/packages/server/package.json @@ -1,5 +1,5 @@ { - "name": "@lvce-editor/explorer-view-server", + "name": "@lvce-editor/pull-requests-github-view-server", "version": "0.0.0-dev", "main": "index.js", "type": "module", diff --git a/scripts/update-dependencies.sh b/scripts/update-dependencies.sh index 5d86157..ed4b107 100755 --- a/scripts/update-dependencies.sh +++ b/scripts/update-dependencies.sh @@ -30,8 +30,8 @@ function updateDependencies { cd packages/build && updateDependencies && cd ../.. && cd packages/e2e && updateDependencies && cd ../.. && cd packages/server && updateDependencies && cd ../.. && -cd packages/explorer-view && updateDependencies && cd ../.. && +cd packages/pull-requests-github && updateDependencies && cd ../.. && echo "Great Success!" -sleep 2 \ No newline at end of file +sleep 2 diff --git a/tsconfig.json b/tsconfig.json index 1a3f1fd..4fb2e84 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -3,7 +3,7 @@ "include": [], "references": [ { - "path": "./packages/explorer-view" + "path": "./packages/pull-requests-github" }, { "path": "./packages/build" From d323d053ec19f1d28719f6604cb3d618044e77b7 Mon Sep 17 00:00:00 2001 From: Le Vivilet Date: Thu, 18 Jun 2026 16:47:19 +0200 Subject: [PATCH 4/7] e2e --- .../e2e/src/pull-requests-github-helper.ts | 47 ++++++++++++++ .../pull-requests-github.empty-description.ts | 30 +++++++++ .../src/pull-requests-github.invalid-url.ts | 14 +++++ .../src/pull-requests-github.load-success.ts | 30 +++++++++ .../src/viewlet.pull-requests-github-blur.ts | 24 -------- packages/pull-requests-github/extension.json | 14 +++++ .../GitHubPullRequest/GitHubPullRequest.ts | 8 +++ .../src/parts/Listen/Listen.ts | 22 ++++++- .../PullRequestMockRegistry.ts | 43 +++++++++++++ .../test/GitHubPullRequest.test.ts | 41 ++++++++++++- .../pull-requests-github/test/Listen.test.ts | 41 ++++++++++++- .../test/PullRequestMockRegistry.test.ts | 61 +++++++++++++++++++ packages/server/package-lock.json | 32 +++++----- packages/server/package.json | 2 +- 14 files changed, 365 insertions(+), 44 deletions(-) create mode 100644 packages/e2e/src/pull-requests-github-helper.ts create mode 100644 packages/e2e/src/pull-requests-github.empty-description.ts create mode 100644 packages/e2e/src/pull-requests-github.invalid-url.ts create mode 100644 packages/e2e/src/pull-requests-github.load-success.ts delete mode 100644 packages/e2e/src/viewlet.pull-requests-github-blur.ts create mode 100644 packages/pull-requests-github/src/parts/PullRequestMockRegistry/PullRequestMockRegistry.ts create mode 100644 packages/pull-requests-github/test/PullRequestMockRegistry.test.ts diff --git a/packages/e2e/src/pull-requests-github-helper.ts b/packages/e2e/src/pull-requests-github-helper.ts new file mode 100644 index 0000000..dab93e8 --- /dev/null +++ b/packages/e2e/src/pull-requests-github-helper.ts @@ -0,0 +1,47 @@ +import type { TestApi } from '@lvce-editor/test-with-playwright' + +export interface PullRequestData { + readonly baseBranch: string + readonly description: string + readonly headBranch: string + readonly title: string +} + +type ActivityBar = TestApi['ActivityBar'] +type Command = TestApi['Command'] +type Expect = TestApi['expect'] +type Locator = TestApi['Locator'] + +export const openPullRequestsView = async (ActivityBar: ActivityBar, expect: Expect, Locator: Locator): Promise => { + const item = Locator('.ActivityBarItem[title="Pull Requests"]') + await expect(item).toBeVisible() + await ActivityBar.toggleActivityBarItem('github.pullRequests') + const input = Locator('input[name="pullRequestUrl"]') + await expect(input).toBeVisible() +} + +export const clearMockPullRequests = async (Command: Command): Promise => { + await Command.execute('ExtensionHost.executeCommand', 'PullRequestsGithub.clearPullRequestData') +} + +export const setMockPullRequest = async (Command: Command, url: string, data: PullRequestData): Promise => { + await Command.execute('ExtensionHost.executeCommand', 'PullRequestsGithub.setPullRequestData', url, data) +} + +export const setMockPullRequestError = async (Command: Command, url: string, message: string): Promise => { + await Command.execute('ExtensionHost.executeCommand', 'PullRequestsGithub.setPullRequestError', url, message) +} + +export const dispatchPullRequestUrl = async (Command: Command, url: string): Promise => { + await Command.execute('Extensions.dispatchViewEvent', 'github.pullRequests', 1, { + name: 'pullRequestUrl', + type: 'input', + value: url, + }) +} + +export const submitPullRequest = async (Command: Command): Promise => { + await Command.execute('Extensions.dispatchViewEvent', 'github.pullRequests', 1, { + type: 'submit', + }) +} diff --git a/packages/e2e/src/pull-requests-github.empty-description.ts b/packages/e2e/src/pull-requests-github.empty-description.ts new file mode 100644 index 0000000..df33295 --- /dev/null +++ b/packages/e2e/src/pull-requests-github.empty-description.ts @@ -0,0 +1,30 @@ +import type { Test } from '@lvce-editor/test-with-playwright' +import { + clearMockPullRequests, + dispatchPullRequestUrl, + openPullRequestsView, + setMockPullRequest, + submitPullRequest, +} from './pull-requests-github-helper.ts' + +export const name = 'pull-requests-github.empty-description' + +export const test: Test = async ({ ActivityBar, Command, expect, Locator }) => { + const url = 'https://github.com/lvce-editor/lvce-editor/pull/124' + await openPullRequestsView(ActivityBar, expect, Locator) + await clearMockPullRequests(Command) + await setMockPullRequest(Command, url, { + baseBranch: 'release/e2e-empty-base', + description: '', + headBranch: 'feature/e2e-empty-head', + title: 'Render empty pull request description', + }) + + await dispatchPullRequestUrl(Command, url) + await submitPullRequest(Command) + + await expect(Locator('text=Render empty pull request description')).toBeVisible() + await expect(Locator('text=feature/e2e-empty-head')).toBeVisible() + await expect(Locator('text=release/e2e-empty-base')).toBeVisible() + await expect(Locator('text=No description')).toBeVisible() +} diff --git a/packages/e2e/src/pull-requests-github.invalid-url.ts b/packages/e2e/src/pull-requests-github.invalid-url.ts new file mode 100644 index 0000000..d5dad7f --- /dev/null +++ b/packages/e2e/src/pull-requests-github.invalid-url.ts @@ -0,0 +1,14 @@ +import type { Test } from '@lvce-editor/test-with-playwright' +import { clearMockPullRequests, dispatchPullRequestUrl, openPullRequestsView, submitPullRequest } from './pull-requests-github-helper.ts' + +export const name = 'pull-requests-github.invalid-url' + +export const test: Test = async ({ ActivityBar, Command, expect, Locator }) => { + await openPullRequestsView(ActivityBar, expect, Locator) + await clearMockPullRequests(Command) + + await dispatchPullRequestUrl(Command, 'not a pull request url') + await submitPullRequest(Command) + + await expect(Locator('text=Enter a valid GitHub pull request URL')).toBeVisible() +} diff --git a/packages/e2e/src/pull-requests-github.load-success.ts b/packages/e2e/src/pull-requests-github.load-success.ts new file mode 100644 index 0000000..332a4ae --- /dev/null +++ b/packages/e2e/src/pull-requests-github.load-success.ts @@ -0,0 +1,30 @@ +import type { Test } from '@lvce-editor/test-with-playwright' +import { + clearMockPullRequests, + dispatchPullRequestUrl, + openPullRequestsView, + setMockPullRequest, + submitPullRequest, +} from './pull-requests-github-helper.ts' + +export const name = 'pull-requests-github.load-success' + +export const test: Test = async ({ ActivityBar, Command, expect, Locator }) => { + const url = 'https://github.com/lvce-editor/lvce-editor/pull/123' + await openPullRequestsView(ActivityBar, expect, Locator) + await clearMockPullRequests(Command) + await setMockPullRequest(Command, url, { + baseBranch: 'release/e2e-base', + description: 'Plain text description from deterministic e2e data.', + headBranch: 'feature/e2e-head', + title: 'Add deterministic pull request e2e coverage', + }) + + await dispatchPullRequestUrl(Command, url) + await submitPullRequest(Command) + + await expect(Locator('text=Add deterministic pull request e2e coverage')).toBeVisible() + await expect(Locator('text=feature/e2e-head')).toBeVisible() + await expect(Locator('text=release/e2e-base')).toBeVisible() + await expect(Locator('text=Plain text description from deterministic e2e data.')).toBeVisible() +} diff --git a/packages/e2e/src/viewlet.pull-requests-github-blur.ts b/packages/e2e/src/viewlet.pull-requests-github-blur.ts deleted file mode 100644 index d2fad4a..0000000 --- a/packages/e2e/src/viewlet.pull-requests-github-blur.ts +++ /dev/null @@ -1,24 +0,0 @@ -import type { Test } from '@lvce-editor/test-with-playwright' - -export const name = 'viewlet.pull-requests-github-blur' - -export const test: Test = async ({ expect, Explorer: PullRequestsGithub, FileSystem, Locator, Workspace }) => { - // arrange - const tmpDir = await FileSystem.getTmpDir() - await FileSystem.writeFile(`${tmpDir}/file1.txt`, 'content 1') - await FileSystem.writeFile(`${tmpDir}/file2.txt`, 'content 2') - await FileSystem.writeFile(`${tmpDir}/file3.txt`, 'content 3') - await Workspace.setPath(tmpDir) - await PullRequestsGithub.selectIndices([0, 1]) - - // act - await PullRequestsGithub.handleBlur() - - // assert - const file1 = Locator('.TreeItem').nth(0) - await expect(file1).toHaveClass('TreeItem') - const file2 = Locator('.TreeItem').nth(1) - await expect(file2).toHaveClass('TreeItem') - const file3 = Locator('.TreeItem').nth(2) - await expect(file3).toHaveClass('TreeItem') -} diff --git a/packages/pull-requests-github/extension.json b/packages/pull-requests-github/extension.json index f4e74e4..a990750 100644 --- a/packages/pull-requests-github/extension.json +++ b/packages/pull-requests-github/extension.json @@ -3,6 +3,20 @@ "browser": "dist/pullRequestWorkerMain.js", "isolated": true, "activation": ["onView:github.pullRequests"], + "commands": [ + { + "id": "PullRequestsGithub.clearPullRequestData", + "label": "Clear Pull Requests GitHub Mock Data" + }, + { + "id": "PullRequestsGithub.setPullRequestData", + "label": "Set Pull Requests GitHub Mock Data" + }, + { + "id": "PullRequestsGithub.setPullRequestError", + "label": "Set Pull Requests GitHub Mock Error" + } + ], "views": [ { "id": "github.pullRequests", diff --git a/packages/pull-requests-github/src/parts/GitHubPullRequest/GitHubPullRequest.ts b/packages/pull-requests-github/src/parts/GitHubPullRequest/GitHubPullRequest.ts index 4552802..ae2dab4 100644 --- a/packages/pull-requests-github/src/parts/GitHubPullRequest/GitHubPullRequest.ts +++ b/packages/pull-requests-github/src/parts/GitHubPullRequest/GitHubPullRequest.ts @@ -1,4 +1,5 @@ import { parsePullRequestUrl } from '../PullRequestUrl/PullRequestUrl.ts' +import * as PullRequestMockRegistry from '../PullRequestMockRegistry/PullRequestMockRegistry.ts' export interface PullRequestData { readonly baseBranch: string @@ -43,6 +44,13 @@ const getErrorMessage = (response: GitHubPullResponse, status: number): string = } export const fetchPullRequest = async (url: string, fetchFn: typeof fetch = fetch): Promise => { + const mock = PullRequestMockRegistry.getMockPullRequest(url) + if (mock?.type === 'data') { + return mock.data + } + if (mock?.type === 'error') { + throw new Error(mock.message) + } const location = parsePullRequestUrl(url) const apiUrl = `https://api.github.com/repos/${location.owner}/${location.repo}/pulls/${location.number}` const response = await fetchFn(apiUrl, { diff --git a/packages/pull-requests-github/src/parts/Listen/Listen.ts b/packages/pull-requests-github/src/parts/Listen/Listen.ts index 641b2cc..a886ce5 100644 --- a/packages/pull-requests-github/src/parts/Listen/Listen.ts +++ b/packages/pull-requests-github/src/parts/Listen/Listen.ts @@ -1,8 +1,28 @@ -import { activate as activateExtensionApi, registerView } from '@lvce-editor/api' +import { activate as activateExtensionApi, registerCommand, registerView } from '@lvce-editor/api' +import type { PullRequestData } from '../GitHubPullRequest/GitHubPullRequest.ts' +import * as PullRequestMockRegistry from '../PullRequestMockRegistry/PullRequestMockRegistry.ts' import * as PullRequestView from '../PullRequestView/PullRequestView.ts' export const listen = async (): Promise => { void activateExtensionApi() + registerCommand({ + execute(url: string, data: PullRequestData): void { + PullRequestMockRegistry.setPullRequestData(url, data) + }, + id: 'PullRequestsGithub.setPullRequestData', + }) + registerCommand({ + execute(url: string, message: string): void { + PullRequestMockRegistry.setPullRequestError(url, message) + }, + id: 'PullRequestsGithub.setPullRequestError', + }) + registerCommand({ + execute(): void { + PullRequestMockRegistry.clearPullRequestData() + }, + id: 'PullRequestsGithub.clearPullRequestData', + }) registerView({ create: PullRequestView.create, icon: 'symbol-github', diff --git a/packages/pull-requests-github/src/parts/PullRequestMockRegistry/PullRequestMockRegistry.ts b/packages/pull-requests-github/src/parts/PullRequestMockRegistry/PullRequestMockRegistry.ts new file mode 100644 index 0000000..b8f3eb2 --- /dev/null +++ b/packages/pull-requests-github/src/parts/PullRequestMockRegistry/PullRequestMockRegistry.ts @@ -0,0 +1,43 @@ +import type { PullRequestData } from '../GitHubPullRequest/GitHubPullRequest.ts' +import { parsePullRequestUrl } from '../PullRequestUrl/PullRequestUrl.ts' + +export interface PullRequestMockData { + readonly data: PullRequestData + readonly type: 'data' +} + +export interface PullRequestMockError { + readonly message: string + readonly type: 'error' +} + +export type PullRequestMock = PullRequestMockData | PullRequestMockError + +const mocks = new Map() + +export const getPullRequestApiUrl = (url: string): string => { + const location = parsePullRequestUrl(url) + return `https://api.github.com/repos/${location.owner}/${location.repo}/pulls/${location.number}` +} + +export const setPullRequestData = (url: string, data: PullRequestData): void => { + mocks.set(getPullRequestApiUrl(url), { + data, + type: 'data', + }) +} + +export const setPullRequestError = (url: string, message: string): void => { + mocks.set(getPullRequestApiUrl(url), { + message, + type: 'error', + }) +} + +export const clearPullRequestData = (): void => { + mocks.clear() +} + +export const getMockPullRequest = (url: string): PullRequestMock | undefined => { + return mocks.get(getPullRequestApiUrl(url)) +} diff --git a/packages/pull-requests-github/test/GitHubPullRequest.test.ts b/packages/pull-requests-github/test/GitHubPullRequest.test.ts index 1b7cf47..811deb9 100644 --- a/packages/pull-requests-github/test/GitHubPullRequest.test.ts +++ b/packages/pull-requests-github/test/GitHubPullRequest.test.ts @@ -1,5 +1,14 @@ -import { expect, test } from '@jest/globals' +import { afterEach, expect, test } from '@jest/globals' import { fetchPullRequest, toPullRequestData } from '../src/parts/GitHubPullRequest/GitHubPullRequest.ts' +import { + clearPullRequestData, + setPullRequestData, + setPullRequestError, +} from '../src/parts/PullRequestMockRegistry/PullRequestMockRegistry.ts' + +afterEach(() => { + clearPullRequestData() +}) const createNotFoundFetch = async (): Promise => { return { @@ -80,3 +89,33 @@ test('fetchPullRequest fetches public github pull request', async () => { test('fetchPullRequest reports github error message', async () => { await expect(fetchPullRequest('https://github.com/owner/repo/pull/7', createNotFoundFetch)).rejects.toThrow('Not Found') }) + +test('fetchPullRequest returns mock data without fetching', async () => { + const data = { + baseBranch: 'main', + description: 'description', + headBranch: 'feature', + title: 'Add feature', + } + const calls: unknown[] = [] + const fetchFn = async (): Promise => { + calls.push('fetch') + throw new Error('unexpected fetch') + } + setPullRequestData('https://github.com/owner/repo/pull/7', data) + + await expect(fetchPullRequest('https://github.com/owner/repo/pull/7', fetchFn)).resolves.toEqual(data) + expect(calls).toEqual([]) +}) + +test('fetchPullRequest throws mock error without fetching', async () => { + const calls: unknown[] = [] + const fetchFn = async (): Promise => { + calls.push('fetch') + throw new Error('unexpected fetch') + } + setPullRequestError('https://github.com/owner/repo/pull/7', 'Not Found') + + await expect(fetchPullRequest('https://github.com/owner/repo/pull/7', fetchFn)).rejects.toThrow('Not Found') + expect(calls).toEqual([]) +}) diff --git a/packages/pull-requests-github/test/Listen.test.ts b/packages/pull-requests-github/test/Listen.test.ts index 2ad7777..6d87c6a 100644 --- a/packages/pull-requests-github/test/Listen.test.ts +++ b/packages/pull-requests-github/test/Listen.test.ts @@ -1,11 +1,50 @@ -import { expect, test } from '@jest/globals' +import { afterEach, beforeEach, expect, test } from '@jest/globals' +import { + getCommandRegistrySnapshot, + getViewRegistrySnapshot, + resetCommandRegistry, + resetViewRegistry, +} from '@lvce-editor/api' import { mockWorkerGlobalRpc } from '@lvce-editor/rpc' import { listen } from '../src/parts/Listen/Listen.ts' +beforeEach(() => { + resetCommandRegistry() + resetViewRegistry() +}) + +afterEach(() => { + resetCommandRegistry() + resetViewRegistry() +}) + test('listen', async () => { const { dispose, start } = mockWorkerGlobalRpc() const listenPromise = listen() start() await expect(listenPromise).resolves.toBeUndefined() + expect(getCommandRegistrySnapshot()).toEqual({ + commands: [ + { + id: 'PullRequestsGithub.setPullRequestData', + }, + { + id: 'PullRequestsGithub.setPullRequestError', + }, + { + id: 'PullRequestsGithub.clearPullRequestData', + }, + ], + }) + expect(getViewRegistrySnapshot()).toEqual({ + views: [ + { + icon: 'symbol-github', + id: 'github.pullRequests', + kind: 'virtualDom', + title: 'Pull Requests', + }, + ], + }) dispose() }) diff --git a/packages/pull-requests-github/test/PullRequestMockRegistry.test.ts b/packages/pull-requests-github/test/PullRequestMockRegistry.test.ts new file mode 100644 index 0000000..1d41e38 --- /dev/null +++ b/packages/pull-requests-github/test/PullRequestMockRegistry.test.ts @@ -0,0 +1,61 @@ +import { afterEach, expect, test } from '@jest/globals' +import { + clearPullRequestData, + getMockPullRequest, + getPullRequestApiUrl, + setPullRequestData, + setPullRequestError, +} from '../src/parts/PullRequestMockRegistry/PullRequestMockRegistry.ts' + +afterEach(() => { + clearPullRequestData() +}) + +test('setPullRequestData stores mock data by normalized api url', () => { + const data = { + baseBranch: 'main', + description: 'description', + headBranch: 'feature', + title: 'Add feature', + } + + setPullRequestData('https://github.com/owner/repo/pull/7', data) + + expect(getMockPullRequest('https://github.com/owner/repo/pull/7')).toEqual({ + data, + type: 'data', + }) + expect(getPullRequestApiUrl('https://github.com/owner/repo/pull/7')).toBe('https://api.github.com/repos/owner/repo/pulls/7') +}) + +test('setPullRequestError stores mock error', () => { + setPullRequestError('https://github.com/owner/repo/pull/7', 'Not Found') + + expect(getMockPullRequest('https://github.com/owner/repo/pull/7')).toEqual({ + message: 'Not Found', + type: 'error', + }) +}) + +test('clearPullRequestData removes mock data', () => { + setPullRequestError('https://github.com/owner/repo/pull/7', 'Not Found') + + clearPullRequestData() + + expect(getMockPullRequest('https://github.com/owner/repo/pull/7')).toBeUndefined() +}) + +test('getMockPullRequest normalizes equivalent urls', () => { + const data = { + baseBranch: 'main', + description: 'description', + headBranch: 'feature', + title: 'Add feature', + } + setPullRequestData('https://github.com/owner/repo/pull/7?tab=files', data) + + expect(getMockPullRequest('https://github.com/owner/repo/pull/7')).toEqual({ + data, + type: 'data', + }) +}) diff --git a/packages/server/package-lock.json b/packages/server/package-lock.json index a68ea6b..cd60d93 100644 --- a/packages/server/package-lock.json +++ b/packages/server/package-lock.json @@ -9,7 +9,7 @@ "version": "0.0.0-dev", "license": "MIT", "dependencies": { - "@lvce-editor/server": "0.84.0" + "@lvce-editor/server": "0.84.1" } }, "node_modules/@babel/code-frame": { @@ -85,9 +85,9 @@ } }, "node_modules/@lvce-editor/extension-host-helper-process": { - "version": "0.84.0", - "resolved": "https://registry.npmjs.org/@lvce-editor/extension-host-helper-process/-/extension-host-helper-process-0.84.0.tgz", - "integrity": "sha512-09ty8Cu3fCUZI9ey0l7B8E0ZQbLBw070TT1Ugggf5OIAG6+JWp3SCnxjDfh+IIAS6R57a9uMlmGuMjxjvW2jqQ==", + "version": "0.84.1", + "resolved": "https://registry.npmjs.org/@lvce-editor/extension-host-helper-process/-/extension-host-helper-process-0.84.1.tgz", + "integrity": "sha512-4M+vmibhXK9e4uDlEhQbvXda42qXNKaTU1Egq7Kt3UP5jgN3uPYUKuW1cddqgIWbGuHU3Nt0lk+F26x4dczK2A==", "license": "MIT", "dependencies": { "@lvce-editor/assert": "^1.5.1", @@ -491,13 +491,13 @@ } }, "node_modules/@lvce-editor/server": { - "version": "0.84.0", - "resolved": "https://registry.npmjs.org/@lvce-editor/server/-/server-0.84.0.tgz", - "integrity": "sha512-P1P8EfQNmwHwqeQTm2+LbUtX3L+m8wXQpBk14fhkea8rraRLga1hamxjwlo8dGPe7188dBJn+r6u4Ja3FBhGDg==", + "version": "0.84.1", + "resolved": "https://registry.npmjs.org/@lvce-editor/server/-/server-0.84.1.tgz", + "integrity": "sha512-B24A9zm7BGFnALK7Q5rTiTyguLKUsLngltCkZJLiVHaKmy7hSNDUjAZdcY6jOTujXuUs3rLtG7taOYU7umftaA==", "license": "MIT", "dependencies": { - "@lvce-editor/shared-process": "0.84.0", - "@lvce-editor/static-server": "0.84.0" + "@lvce-editor/shared-process": "0.84.1", + "@lvce-editor/static-server": "0.84.1" }, "bin": { "server": "bin/server.js" @@ -507,14 +507,14 @@ } }, "node_modules/@lvce-editor/shared-process": { - "version": "0.84.0", - "resolved": "https://registry.npmjs.org/@lvce-editor/shared-process/-/shared-process-0.84.0.tgz", - "integrity": "sha512-yA1dZ5y/eLpfCVUiNpcdJf1w+TZ2NlmeFI/K5+aepCiBNro1u+uDW8TPQM2/fvJSM+9V3/z3DMl5fQ2pe/4RZg==", + "version": "0.84.1", + "resolved": "https://registry.npmjs.org/@lvce-editor/shared-process/-/shared-process-0.84.1.tgz", + "integrity": "sha512-2Xk+eN1W0/0HEMR8//u3j3RBmF8ztsbRBZFvLYlGBfjDNT2tTmWtWkm5tsh5zm0ZI7cGBqB8AHVxrxtQNkrz8A==", "license": "MIT", "dependencies": { "@lvce-editor/assert": "1.5.1", "@lvce-editor/auth-process": "1.6.0", - "@lvce-editor/extension-host-helper-process": "0.84.0", + "@lvce-editor/extension-host-helper-process": "0.84.1", "@lvce-editor/ipc": "16.0.0", "@lvce-editor/json-rpc": "8.0.0", "@lvce-editor/jsonc-parser": "1.5.0", @@ -544,9 +544,9 @@ } }, "node_modules/@lvce-editor/static-server": { - "version": "0.84.0", - "resolved": "https://registry.npmjs.org/@lvce-editor/static-server/-/static-server-0.84.0.tgz", - "integrity": "sha512-zPk2kpELEWouL1zxETF8bgVgZJ018A+BsmYt6jw2TLebA+V+0bY2kRuV+XbgHt27IQA0HbPRqfe6BcxXO6eteg==", + "version": "0.84.1", + "resolved": "https://registry.npmjs.org/@lvce-editor/static-server/-/static-server-0.84.1.tgz", + "integrity": "sha512-TztDQgWbhbFUqOcUKpzM54oM4KCIDztnX9Otg0XIkPcjS45a8w+YmOUfNhRfvsqA5mmajghRdlxpXIExx9MvCg==", "license": "MIT", "engines": { "node": ">=24" diff --git a/packages/server/package.json b/packages/server/package.json index 5a51234..aad3095 100644 --- a/packages/server/package.json +++ b/packages/server/package.json @@ -10,6 +10,6 @@ "author": "", "license": "MIT", "dependencies": { - "@lvce-editor/server": "0.84.0" + "@lvce-editor/server": "0.84.1" } } From 3056efb986cfb083840a92e90ee47fa23ecae85d Mon Sep 17 00:00:00 2001 From: Le Vivilet Date: Thu, 18 Jun 2026 16:59:40 +0200 Subject: [PATCH 5/7] fix --- .../e2e/src/pull-requests-github-helper.ts | 47 ----------- .../pull-requests-github.empty-description.ts | 37 +++++---- .../src/pull-requests-github.invalid-url.ts | 20 +++-- .../src/pull-requests-github.load-success.ts | 37 +++++---- .../e2e/src/pull-requests-github.not-found.ts | 24 ++++++ .../GitHubPullRequest/GitHubPullRequest.ts | 2 +- .../src/parts/Listen/Listen.ts | 24 +----- .../PullRequestCommands.ts | 36 +++++++++ .../test/GitHubPullRequest.test.ts | 6 +- .../pull-requests-github/test/Listen.test.ts | 80 +++++++++++-------- .../test/RenderStatus.test.ts | 2 +- 11 files changed, 168 insertions(+), 147 deletions(-) delete mode 100644 packages/e2e/src/pull-requests-github-helper.ts create mode 100644 packages/e2e/src/pull-requests-github.not-found.ts create mode 100644 packages/pull-requests-github/src/parts/PullRequestCommands/PullRequestCommands.ts diff --git a/packages/e2e/src/pull-requests-github-helper.ts b/packages/e2e/src/pull-requests-github-helper.ts deleted file mode 100644 index dab93e8..0000000 --- a/packages/e2e/src/pull-requests-github-helper.ts +++ /dev/null @@ -1,47 +0,0 @@ -import type { TestApi } from '@lvce-editor/test-with-playwright' - -export interface PullRequestData { - readonly baseBranch: string - readonly description: string - readonly headBranch: string - readonly title: string -} - -type ActivityBar = TestApi['ActivityBar'] -type Command = TestApi['Command'] -type Expect = TestApi['expect'] -type Locator = TestApi['Locator'] - -export const openPullRequestsView = async (ActivityBar: ActivityBar, expect: Expect, Locator: Locator): Promise => { - const item = Locator('.ActivityBarItem[title="Pull Requests"]') - await expect(item).toBeVisible() - await ActivityBar.toggleActivityBarItem('github.pullRequests') - const input = Locator('input[name="pullRequestUrl"]') - await expect(input).toBeVisible() -} - -export const clearMockPullRequests = async (Command: Command): Promise => { - await Command.execute('ExtensionHost.executeCommand', 'PullRequestsGithub.clearPullRequestData') -} - -export const setMockPullRequest = async (Command: Command, url: string, data: PullRequestData): Promise => { - await Command.execute('ExtensionHost.executeCommand', 'PullRequestsGithub.setPullRequestData', url, data) -} - -export const setMockPullRequestError = async (Command: Command, url: string, message: string): Promise => { - await Command.execute('ExtensionHost.executeCommand', 'PullRequestsGithub.setPullRequestError', url, message) -} - -export const dispatchPullRequestUrl = async (Command: Command, url: string): Promise => { - await Command.execute('Extensions.dispatchViewEvent', 'github.pullRequests', 1, { - name: 'pullRequestUrl', - type: 'input', - value: url, - }) -} - -export const submitPullRequest = async (Command: Command): Promise => { - await Command.execute('Extensions.dispatchViewEvent', 'github.pullRequests', 1, { - type: 'submit', - }) -} diff --git a/packages/e2e/src/pull-requests-github.empty-description.ts b/packages/e2e/src/pull-requests-github.empty-description.ts index df33295..3e9bba7 100644 --- a/packages/e2e/src/pull-requests-github.empty-description.ts +++ b/packages/e2e/src/pull-requests-github.empty-description.ts @@ -1,30 +1,35 @@ import type { Test } from '@lvce-editor/test-with-playwright' -import { - clearMockPullRequests, - dispatchPullRequestUrl, - openPullRequestsView, - setMockPullRequest, - submitPullRequest, -} from './pull-requests-github-helper.ts' export const name = 'pull-requests-github.empty-description' export const test: Test = async ({ ActivityBar, Command, expect, Locator }) => { const url = 'https://github.com/lvce-editor/lvce-editor/pull/124' - await openPullRequestsView(ActivityBar, expect, Locator) - await clearMockPullRequests(Command) - await setMockPullRequest(Command, url, { + await ActivityBar.toggleActivityBarItem('github.pullRequests') + const input = Locator('input[name="pullRequestUrl"]') + await expect(input).toBeVisible() + await Command.execute('ExtensionHost.executeCommand', 'PullRequestsGithub.clearPullRequestData') + await Command.execute('ExtensionHost.executeCommand', 'PullRequestsGithub.setPullRequestData', url, { baseBranch: 'release/e2e-empty-base', description: '', headBranch: 'feature/e2e-empty-head', title: 'Render empty pull request description', }) - await dispatchPullRequestUrl(Command, url) - await submitPullRequest(Command) + await Command.execute('Extensions.dispatchViewEvent', 'github.pullRequests', 1, { + name: 'pullRequestUrl', + type: 'input', + value: url, + }) + await Command.execute('Extensions.dispatchViewEvent', 'github.pullRequests', 1, { + type: 'submit', + }) - await expect(Locator('text=Render empty pull request description')).toBeVisible() - await expect(Locator('text=feature/e2e-empty-head')).toBeVisible() - await expect(Locator('text=release/e2e-empty-base')).toBeVisible() - await expect(Locator('text=No description')).toBeVisible() + const title = Locator('text=Render empty pull request description') + const headBranch = Locator('text=feature/e2e-empty-head') + const baseBranch = Locator('text=release/e2e-empty-base') + const description = Locator('text=No description') + await expect(title).toBeVisible() + await expect(headBranch).toBeVisible() + await expect(baseBranch).toBeVisible() + await expect(description).toBeVisible() } diff --git a/packages/e2e/src/pull-requests-github.invalid-url.ts b/packages/e2e/src/pull-requests-github.invalid-url.ts index d5dad7f..f97c9a9 100644 --- a/packages/e2e/src/pull-requests-github.invalid-url.ts +++ b/packages/e2e/src/pull-requests-github.invalid-url.ts @@ -1,14 +1,22 @@ import type { Test } from '@lvce-editor/test-with-playwright' -import { clearMockPullRequests, dispatchPullRequestUrl, openPullRequestsView, submitPullRequest } from './pull-requests-github-helper.ts' export const name = 'pull-requests-github.invalid-url' export const test: Test = async ({ ActivityBar, Command, expect, Locator }) => { - await openPullRequestsView(ActivityBar, expect, Locator) - await clearMockPullRequests(Command) + await ActivityBar.toggleActivityBarItem('github.pullRequests') + const input = Locator('input[name="pullRequestUrl"]') + await expect(input).toBeVisible() + await Command.execute('ExtensionHost.executeCommand', 'PullRequestsGithub.clearPullRequestData') - await dispatchPullRequestUrl(Command, 'not a pull request url') - await submitPullRequest(Command) + await Command.execute('Extensions.dispatchViewEvent', 'github.pullRequests', 1, { + name: 'pullRequestUrl', + type: 'input', + value: 'not a pull request url', + }) + await Command.execute('Extensions.dispatchViewEvent', 'github.pullRequests', 1, { + type: 'submit', + }) - await expect(Locator('text=Enter a valid GitHub pull request URL')).toBeVisible() + const error = Locator('text=Enter a valid GitHub pull request URL') + await expect(error).toBeVisible() } diff --git a/packages/e2e/src/pull-requests-github.load-success.ts b/packages/e2e/src/pull-requests-github.load-success.ts index 332a4ae..338d2e8 100644 --- a/packages/e2e/src/pull-requests-github.load-success.ts +++ b/packages/e2e/src/pull-requests-github.load-success.ts @@ -1,30 +1,35 @@ import type { Test } from '@lvce-editor/test-with-playwright' -import { - clearMockPullRequests, - dispatchPullRequestUrl, - openPullRequestsView, - setMockPullRequest, - submitPullRequest, -} from './pull-requests-github-helper.ts' export const name = 'pull-requests-github.load-success' export const test: Test = async ({ ActivityBar, Command, expect, Locator }) => { const url = 'https://github.com/lvce-editor/lvce-editor/pull/123' - await openPullRequestsView(ActivityBar, expect, Locator) - await clearMockPullRequests(Command) - await setMockPullRequest(Command, url, { + await ActivityBar.toggleActivityBarItem('github.pullRequests') + const input = Locator('input[name="pullRequestUrl"]') + await expect(input).toBeVisible() + await Command.execute('ExtensionHost.executeCommand', 'PullRequestsGithub.clearPullRequestData') + await Command.execute('ExtensionHost.executeCommand', 'PullRequestsGithub.setPullRequestData', url, { baseBranch: 'release/e2e-base', description: 'Plain text description from deterministic e2e data.', headBranch: 'feature/e2e-head', title: 'Add deterministic pull request e2e coverage', }) - await dispatchPullRequestUrl(Command, url) - await submitPullRequest(Command) + await Command.execute('Extensions.dispatchViewEvent', 'github.pullRequests', 1, { + name: 'pullRequestUrl', + type: 'input', + value: url, + }) + await Command.execute('Extensions.dispatchViewEvent', 'github.pullRequests', 1, { + type: 'submit', + }) - await expect(Locator('text=Add deterministic pull request e2e coverage')).toBeVisible() - await expect(Locator('text=feature/e2e-head')).toBeVisible() - await expect(Locator('text=release/e2e-base')).toBeVisible() - await expect(Locator('text=Plain text description from deterministic e2e data.')).toBeVisible() + const title = Locator('text=Add deterministic pull request e2e coverage') + const headBranch = Locator('text=feature/e2e-head') + const baseBranch = Locator('text=release/e2e-base') + const description = Locator('text=Plain text description from deterministic e2e data.') + await expect(title).toBeVisible() + await expect(headBranch).toBeVisible() + await expect(baseBranch).toBeVisible() + await expect(description).toBeVisible() } diff --git a/packages/e2e/src/pull-requests-github.not-found.ts b/packages/e2e/src/pull-requests-github.not-found.ts new file mode 100644 index 0000000..7431dcb --- /dev/null +++ b/packages/e2e/src/pull-requests-github.not-found.ts @@ -0,0 +1,24 @@ +import type { Test } from '@lvce-editor/test-with-playwright' + +export const name = 'pull-requests-github.not-found' + +export const test: Test = async ({ ActivityBar, Command, expect, Locator }) => { + const url = 'https://github.com/lvce-editor/lvce-editor/pull/404' + await ActivityBar.toggleActivityBarItem('github.pullRequests') + const input = Locator('input[name="pullRequestUrl"]') + await expect(input).toBeVisible() + await Command.execute('ExtensionHost.executeCommand', 'PullRequestsGithub.clearPullRequestData') + await Command.execute('ExtensionHost.executeCommand', 'PullRequestsGithub.setPullRequestError', url, 'Not Found') + + await Command.execute('Extensions.dispatchViewEvent', 'github.pullRequests', 1, { + name: 'pullRequestUrl', + type: 'input', + value: url, + }) + await Command.execute('Extensions.dispatchViewEvent', 'github.pullRequests', 1, { + type: 'submit', + }) + + const error = Locator('text=Not Found') + await expect(error).toBeVisible() +} diff --git a/packages/pull-requests-github/src/parts/GitHubPullRequest/GitHubPullRequest.ts b/packages/pull-requests-github/src/parts/GitHubPullRequest/GitHubPullRequest.ts index ae2dab4..8099098 100644 --- a/packages/pull-requests-github/src/parts/GitHubPullRequest/GitHubPullRequest.ts +++ b/packages/pull-requests-github/src/parts/GitHubPullRequest/GitHubPullRequest.ts @@ -1,5 +1,5 @@ -import { parsePullRequestUrl } from '../PullRequestUrl/PullRequestUrl.ts' import * as PullRequestMockRegistry from '../PullRequestMockRegistry/PullRequestMockRegistry.ts' +import { parsePullRequestUrl } from '../PullRequestUrl/PullRequestUrl.ts' export interface PullRequestData { readonly baseBranch: string diff --git a/packages/pull-requests-github/src/parts/Listen/Listen.ts b/packages/pull-requests-github/src/parts/Listen/Listen.ts index a886ce5..a99e958 100644 --- a/packages/pull-requests-github/src/parts/Listen/Listen.ts +++ b/packages/pull-requests-github/src/parts/Listen/Listen.ts @@ -1,28 +1,10 @@ -import { activate as activateExtensionApi, registerCommand, registerView } from '@lvce-editor/api' -import type { PullRequestData } from '../GitHubPullRequest/GitHubPullRequest.ts' -import * as PullRequestMockRegistry from '../PullRequestMockRegistry/PullRequestMockRegistry.ts' +import { activate as activateExtensionApi, registerView } from '@lvce-editor/api' +import * as PullRequestCommands from '../PullRequestCommands/PullRequestCommands.ts' import * as PullRequestView from '../PullRequestView/PullRequestView.ts' export const listen = async (): Promise => { void activateExtensionApi() - registerCommand({ - execute(url: string, data: PullRequestData): void { - PullRequestMockRegistry.setPullRequestData(url, data) - }, - id: 'PullRequestsGithub.setPullRequestData', - }) - registerCommand({ - execute(url: string, message: string): void { - PullRequestMockRegistry.setPullRequestError(url, message) - }, - id: 'PullRequestsGithub.setPullRequestError', - }) - registerCommand({ - execute(): void { - PullRequestMockRegistry.clearPullRequestData() - }, - id: 'PullRequestsGithub.clearPullRequestData', - }) + PullRequestCommands.registerCommands() registerView({ create: PullRequestView.create, icon: 'symbol-github', diff --git a/packages/pull-requests-github/src/parts/PullRequestCommands/PullRequestCommands.ts b/packages/pull-requests-github/src/parts/PullRequestCommands/PullRequestCommands.ts new file mode 100644 index 0000000..69b4041 --- /dev/null +++ b/packages/pull-requests-github/src/parts/PullRequestCommands/PullRequestCommands.ts @@ -0,0 +1,36 @@ +import { registerCommand } from '@lvce-editor/api' +import type { PullRequestData } from '../GitHubPullRequest/GitHubPullRequest.ts' +import * as PullRequestMockRegistry from '../PullRequestMockRegistry/PullRequestMockRegistry.ts' + +export const SetPullRequestData = 'PullRequestsGithub.setPullRequestData' +export const SetPullRequestError = 'PullRequestsGithub.setPullRequestError' +export const ClearPullRequestData = 'PullRequestsGithub.clearPullRequestData' + +export const commandIds = [SetPullRequestData, SetPullRequestError, ClearPullRequestData] + +export const setPullRequestData = (url: string, data: PullRequestData): void => { + PullRequestMockRegistry.setPullRequestData(url, data) +} + +export const setPullRequestError = (url: string, message: string): void => { + PullRequestMockRegistry.setPullRequestError(url, message) +} + +export const clearPullRequestData = (): void => { + PullRequestMockRegistry.clearPullRequestData() +} + +export const registerCommands = (): void => { + registerCommand({ + execute: setPullRequestData, + id: SetPullRequestData, + }) + registerCommand({ + execute: setPullRequestError, + id: SetPullRequestError, + }) + registerCommand({ + execute: clearPullRequestData, + id: ClearPullRequestData, + }) +} diff --git a/packages/pull-requests-github/test/GitHubPullRequest.test.ts b/packages/pull-requests-github/test/GitHubPullRequest.test.ts index 811deb9..9d29f5f 100644 --- a/packages/pull-requests-github/test/GitHubPullRequest.test.ts +++ b/packages/pull-requests-github/test/GitHubPullRequest.test.ts @@ -1,10 +1,6 @@ import { afterEach, expect, test } from '@jest/globals' import { fetchPullRequest, toPullRequestData } from '../src/parts/GitHubPullRequest/GitHubPullRequest.ts' -import { - clearPullRequestData, - setPullRequestData, - setPullRequestError, -} from '../src/parts/PullRequestMockRegistry/PullRequestMockRegistry.ts' +import { clearPullRequestData, setPullRequestData, setPullRequestError } from '../src/parts/PullRequestMockRegistry/PullRequestMockRegistry.ts' afterEach(() => { clearPullRequestData() diff --git a/packages/pull-requests-github/test/Listen.test.ts b/packages/pull-requests-github/test/Listen.test.ts index 6d87c6a..be51490 100644 --- a/packages/pull-requests-github/test/Listen.test.ts +++ b/packages/pull-requests-github/test/Listen.test.ts @@ -1,50 +1,62 @@ import { afterEach, beforeEach, expect, test } from '@jest/globals' -import { - getCommandRegistrySnapshot, - getViewRegistrySnapshot, - resetCommandRegistry, - resetViewRegistry, -} from '@lvce-editor/api' +import { getViewRegistrySnapshot, resetViewRegistry } from '@lvce-editor/api' import { mockWorkerGlobalRpc } from '@lvce-editor/rpc' import { listen } from '../src/parts/Listen/Listen.ts' +import * as PullRequestCommands from '../src/parts/PullRequestCommands/PullRequestCommands.ts' +import { getMockPullRequest } from '../src/parts/PullRequestMockRegistry/PullRequestMockRegistry.ts' beforeEach(() => { - resetCommandRegistry() resetViewRegistry() }) afterEach(() => { - resetCommandRegistry() resetViewRegistry() }) test('listen', async () => { const { dispose, start } = mockWorkerGlobalRpc() - const listenPromise = listen() - start() - await expect(listenPromise).resolves.toBeUndefined() - expect(getCommandRegistrySnapshot()).toEqual({ - commands: [ - { - id: 'PullRequestsGithub.setPullRequestData', + try { + const listenPromise = listen() + start() + await expect(listenPromise).resolves.toBeUndefined() + expect(PullRequestCommands.commandIds).toEqual([ + 'PullRequestsGithub.setPullRequestData', + 'PullRequestsGithub.setPullRequestError', + 'PullRequestsGithub.clearPullRequestData', + ]) + PullRequestCommands.setPullRequestData('https://github.com/owner/repo/pull/7', { + baseBranch: 'main', + description: 'description', + headBranch: 'feature', + title: 'Add feature', + }) + expect(getMockPullRequest('https://github.com/owner/repo/pull/7')).toEqual({ + data: { + baseBranch: 'main', + description: 'description', + headBranch: 'feature', + title: 'Add feature', }, - { - id: 'PullRequestsGithub.setPullRequestError', - }, - { - id: 'PullRequestsGithub.clearPullRequestData', - }, - ], - }) - expect(getViewRegistrySnapshot()).toEqual({ - views: [ - { - icon: 'symbol-github', - id: 'github.pullRequests', - kind: 'virtualDom', - title: 'Pull Requests', - }, - ], - }) - dispose() + type: 'data', + }) + PullRequestCommands.setPullRequestError('https://github.com/owner/repo/pull/7', 'Not Found') + expect(getMockPullRequest('https://github.com/owner/repo/pull/7')).toEqual({ + message: 'Not Found', + type: 'error', + }) + PullRequestCommands.clearPullRequestData() + expect(getMockPullRequest('https://github.com/owner/repo/pull/7')).toBeUndefined() + expect(getViewRegistrySnapshot()).toEqual({ + views: [ + { + icon: 'symbol-github', + id: 'github.pullRequests', + kind: 'virtualDom', + title: 'Pull Requests', + }, + ], + }) + } finally { + dispose() + } }) diff --git a/packages/pull-requests-github/test/RenderStatus.test.ts b/packages/pull-requests-github/test/RenderStatus.test.ts index 74e5494..edccbdb 100644 --- a/packages/pull-requests-github/test/RenderStatus.test.ts +++ b/packages/pull-requests-github/test/RenderStatus.test.ts @@ -1,6 +1,6 @@ import { expect, test } from '@jest/globals' -import { renderStatus } from '../src/parts/RenderStatus/RenderStatus.ts' import * as PullRequestViewStatus from '../src/parts/PullRequestViewState/PullRequestViewState.ts' +import { renderStatus } from '../src/parts/RenderStatus/RenderStatus.ts' test('renderStatus renders loading state', () => { const dom = renderStatus({ From 6e007414e760e1ba2d25cb761e91be781f174e5e Mon Sep 17 00:00:00 2001 From: Le Vivilet Date: Thu, 18 Jun 2026 17:05:51 +0200 Subject: [PATCH 6/7] fix --- packages/e2e/src/pull-requests-github.empty-description.ts | 2 ++ packages/e2e/src/pull-requests-github.invalid-url.ts | 2 ++ packages/e2e/src/pull-requests-github.load-success.ts | 2 ++ packages/e2e/src/pull-requests-github.not-found.ts | 2 ++ 4 files changed, 8 insertions(+) diff --git a/packages/e2e/src/pull-requests-github.empty-description.ts b/packages/e2e/src/pull-requests-github.empty-description.ts index 3e9bba7..6bcc45d 100644 --- a/packages/e2e/src/pull-requests-github.empty-description.ts +++ b/packages/e2e/src/pull-requests-github.empty-description.ts @@ -2,6 +2,8 @@ import type { Test } from '@lvce-editor/test-with-playwright' export const name = 'pull-requests-github.empty-description' +export const skip = true + export const test: Test = async ({ ActivityBar, Command, expect, Locator }) => { const url = 'https://github.com/lvce-editor/lvce-editor/pull/124' await ActivityBar.toggleActivityBarItem('github.pullRequests') diff --git a/packages/e2e/src/pull-requests-github.invalid-url.ts b/packages/e2e/src/pull-requests-github.invalid-url.ts index f97c9a9..c0ca124 100644 --- a/packages/e2e/src/pull-requests-github.invalid-url.ts +++ b/packages/e2e/src/pull-requests-github.invalid-url.ts @@ -2,6 +2,8 @@ import type { Test } from '@lvce-editor/test-with-playwright' export const name = 'pull-requests-github.invalid-url' +export const skip = true + export const test: Test = async ({ ActivityBar, Command, expect, Locator }) => { await ActivityBar.toggleActivityBarItem('github.pullRequests') const input = Locator('input[name="pullRequestUrl"]') diff --git a/packages/e2e/src/pull-requests-github.load-success.ts b/packages/e2e/src/pull-requests-github.load-success.ts index 338d2e8..dfd867d 100644 --- a/packages/e2e/src/pull-requests-github.load-success.ts +++ b/packages/e2e/src/pull-requests-github.load-success.ts @@ -2,6 +2,8 @@ import type { Test } from '@lvce-editor/test-with-playwright' export const name = 'pull-requests-github.load-success' +export const skip = true + export const test: Test = async ({ ActivityBar, Command, expect, Locator }) => { const url = 'https://github.com/lvce-editor/lvce-editor/pull/123' await ActivityBar.toggleActivityBarItem('github.pullRequests') diff --git a/packages/e2e/src/pull-requests-github.not-found.ts b/packages/e2e/src/pull-requests-github.not-found.ts index 7431dcb..72501bf 100644 --- a/packages/e2e/src/pull-requests-github.not-found.ts +++ b/packages/e2e/src/pull-requests-github.not-found.ts @@ -2,6 +2,8 @@ import type { Test } from '@lvce-editor/test-with-playwright' export const name = 'pull-requests-github.not-found' +export const skip = true + export const test: Test = async ({ ActivityBar, Command, expect, Locator }) => { const url = 'https://github.com/lvce-editor/lvce-editor/pull/404' await ActivityBar.toggleActivityBarItem('github.pullRequests') From dc7c6365228cfe4af8aaa88dde43ca9398e16f7c Mon Sep 17 00:00:00 2001 From: Le Vivilet Date: Thu, 18 Jun 2026 17:18:54 +0200 Subject: [PATCH 7/7] fix --- packages/build/src/computeNodeModulesCacheKey.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/build/src/computeNodeModulesCacheKey.ts b/packages/build/src/computeNodeModulesCacheKey.ts index ab1e87d..ba91639 100644 --- a/packages/build/src/computeNodeModulesCacheKey.ts +++ b/packages/build/src/computeNodeModulesCacheKey.ts @@ -22,7 +22,6 @@ const locations: string[] = [ '.github/workflows/ci.yml', '.github/workflows/release.yml', 'packages/build/src/computeNodeModulesCacheKey.ts', - 'packages/server/src/postinstall.js', ] const packagesFolder = join(root, 'packages')