-
-
Notifications
You must be signed in to change notification settings - Fork 447
fix(ui): restore cards after host reload #249
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
9b98cc7
fix(review): preserve historical change snapshots
Waishnav e70c2b1
fix(ui): restore cards from durable tool output
Waishnav 60f7f27
feat(cli): inspect Git-backed reviews
Waishnav ac1b616
fix(review): harden historical review restore
Waishnav 809f1a4
test(cli): bind review smoke to package entrypoint
Waishnav File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,108 @@ | ||
| import assert from "node:assert/strict"; | ||
| import { execFile } from "node:child_process"; | ||
| import { readFileSync } from "node:fs"; | ||
| import { mkdtemp, rm, writeFile } from "node:fs/promises"; | ||
| import { createRequire } from "node:module"; | ||
| import { tmpdir } from "node:os"; | ||
| import { dirname, join } from "node:path"; | ||
| import test from "node:test"; | ||
| import { fileURLToPath } from "node:url"; | ||
| import { promisify } from "node:util"; | ||
| import { createReviewCheckpointManager } from "./review-checkpoints.js"; | ||
| import { writeTestDevspaceConfig } from "./test-support/config.test.js"; | ||
|
|
||
| const execFileAsync = promisify(execFile); | ||
| const require = createRequire(import.meta.url); | ||
| const packageJsonPath = fileURLToPath(new URL("../package.json", import.meta.url)); | ||
| const repoRoot = dirname(packageJsonPath); | ||
| const packageJson = JSON.parse(readFileSync(packageJsonPath, "utf8")) as { | ||
| bin: { devspace: string }; | ||
| }; | ||
| // This verifies the compiled entrypoint declared for the installed `devspace` | ||
| // command. npm's package-install shim itself is outside this focused test. | ||
| const cliPath = join(repoRoot, packageJson.bin.devspace); | ||
| const tscPath = require.resolve("typescript/bin/tsc"); | ||
|
|
||
| test("show-changes prints a Git-backed historical review", async (t) => { | ||
| await execFileAsync(process.execPath, [tscPath, "-p", join(repoRoot, "tsconfig.build.json")], { | ||
| cwd: repoRoot, | ||
| }); | ||
|
|
||
| const root = await mkdtemp(join(tmpdir(), "devspace-cli-show-changes-")); | ||
| t.after(() => rm(root, { recursive: true, force: true })); | ||
| const project = join(root, "project"); | ||
| await execFileAsync("git", ["init", project]); | ||
| await git(project, ["config", "user.email", "devspace@example.com"]); | ||
| await git(project, ["config", "user.name", "DevSpace Test"]); | ||
| await writeFile(join(project, "README.md"), "hello\n"); | ||
| await git(project, ["add", "README.md"]); | ||
| await git(project, ["commit", "-m", "Initial commit"]); | ||
|
|
||
| const manager = createReviewCheckpointManager(); | ||
| await manager.initializeWorkspace({ workspaceId: "ws_cli", root: project }); | ||
| await writeFile(join(project, "README.md"), "hello\nreview me\n"); | ||
| const review = await manager.reviewChanges({ workspaceId: "ws_cli", root: project }); | ||
|
|
||
| const configDir = join(root, ".devspace"); | ||
| const env = writeTestDevspaceConfig(configDir, { | ||
| workspaces: { allowedRoots: [project] }, | ||
| storage: { stateDir: join(root, ".state") }, | ||
| }); | ||
| const cliArgs = [cliPath, "show-changes", review.reviewRef]; | ||
| const plain = await execFileAsync("node", cliArgs, { | ||
| cwd: project, | ||
| env: { | ||
| ...process.env, | ||
| ...env, | ||
| DEVSPACE_WORKSPACE_ID: "", | ||
| DEVSPACE_WORKSPACE_ROOT: "", | ||
| }, | ||
| encoding: "utf8", | ||
| }); | ||
| assert.match(plain.stdout, /\+review me/); | ||
|
|
||
| const json = await execFileAsync("node", [...cliArgs, "--json"], { | ||
| cwd: project, | ||
| env: { | ||
| ...process.env, | ||
| ...env, | ||
| DEVSPACE_WORKSPACE_ID: "", | ||
| DEVSPACE_WORKSPACE_ROOT: "", | ||
| }, | ||
| encoding: "utf8", | ||
| }); | ||
| const parsed = JSON.parse(json.stdout) as { | ||
| reviewRef: string; | ||
| patch: string; | ||
| }; | ||
| assert.equal(parsed.reviewRef, review.reviewRef); | ||
| assert.equal(parsed.patch, review.patch); | ||
|
|
||
| const head = (await execFileAsync("git", ["rev-parse", "HEAD"], { | ||
| cwd: project, | ||
| encoding: "utf8", | ||
| })).stdout.trim(); | ||
| await assert.rejects( | ||
| execFileAsync("node", [cliPath, "show-changes", head], { | ||
| cwd: project, | ||
| env: { | ||
| ...process.env, | ||
| ...env, | ||
| DEVSPACE_WORKSPACE_ID: "", | ||
| DEVSPACE_WORKSPACE_ROOT: "", | ||
| }, | ||
| encoding: "utf8", | ||
| }), | ||
| (error: unknown) => { | ||
| assert.match( | ||
| (error as { stderr?: string }).stderr ?? "", | ||
| /Unknown DevSpace review reference/, | ||
| ); | ||
| return true; | ||
| }, | ||
| ); | ||
| }); | ||
|
|
||
| async function git(cwd: string, args: string[]): Promise<void> { | ||
| await execFileAsync("git", args, { cwd }); | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.