test(app,server): align e2e specs with settings redesign, drop rg dep
- worktree-core test scans the server source via a pure Node walker instead of shelling out to `rg`, which is not installed on CI runners. Invariant and scope are unchanged. - settings-host-page specs target the new detail-header label + rename affordance (settings-detail-header-title / host-page-label-edit-button) since the label card moved into the shared header as part of the modular settings refactor. - settings-navigation compact tests assert the new two-tier Back semantics: root Back exits settings, detail Back returns to /settings.
This commit is contained in:
@@ -1,5 +1,13 @@
|
||||
import { execSync } from "node:child_process";
|
||||
import { existsSync, mkdtempSync, realpathSync, rmSync, writeFileSync } from "node:fs";
|
||||
import {
|
||||
existsSync,
|
||||
mkdtempSync,
|
||||
readdirSync,
|
||||
readFileSync,
|
||||
realpathSync,
|
||||
rmSync,
|
||||
writeFileSync,
|
||||
} from "node:fs";
|
||||
import { tmpdir } from "node:os";
|
||||
import path from "node:path";
|
||||
import { fileURLToPath } from "node:url";
|
||||
@@ -45,6 +53,42 @@ function createCoreDeps(options?: {
|
||||
};
|
||||
}
|
||||
|
||||
function findDirectCreateWorktreeCallSites(serverSrc: string): string[] {
|
||||
const matches: string[] = [];
|
||||
|
||||
function walk(directory: string) {
|
||||
for (const entry of readdirSync(directory, { withFileTypes: true })) {
|
||||
const absolutePath = path.join(directory, entry.name);
|
||||
|
||||
if (entry.isDirectory()) {
|
||||
walk(absolutePath);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!entry.isFile()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const relativePath = path
|
||||
.relative(serverSrc, absolutePath)
|
||||
.split(path.sep)
|
||||
.join(path.posix.sep);
|
||||
|
||||
if (relativePath === "utils/worktree.ts" || relativePath.endsWith(".test.ts")) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Keep this literal in the test file so the invariant proves tests are allowed to inspect createWorktree(.
|
||||
if (/createWorktree\(/.test(readFileSync(absolutePath, "utf8"))) {
|
||||
matches.push(relativePath);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
walk(serverSrc);
|
||||
return matches.sort();
|
||||
}
|
||||
|
||||
function createGitRepo(): { tempDir: string; repoDir: string; paseoHome: string } {
|
||||
const tempDir = realpathSync(mkdtempSync(path.join(tmpdir(), "worktree-core-test-")));
|
||||
const repoDir = path.join(tempDir, "repo");
|
||||
@@ -435,21 +479,6 @@ describe.skipIf(process.platform === "win32")("createWorktreeCore", () => {
|
||||
|
||||
test("keeps direct createWorktree calls isolated to the core layer", () => {
|
||||
const serverSrc = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "..");
|
||||
// Keep this literal in the test file so the invariant proves tests are allowed to inspect createWorktree(.
|
||||
const output = execSync(
|
||||
"rg --files-with-matches 'createWorktree\\(' . --glob '!**/utils/worktree.ts' --glob '!**/*.test.ts'",
|
||||
{
|
||||
cwd: serverSrc,
|
||||
stdio: "pipe",
|
||||
},
|
||||
)
|
||||
.toString()
|
||||
.trim()
|
||||
.split("\n")
|
||||
.map((line) => line.replace(/^\.\//, ""))
|
||||
.filter(Boolean)
|
||||
.sort();
|
||||
|
||||
expect(output).toEqual(["server/worktree-core.ts"]);
|
||||
expect(findDirectCreateWorktreeCallSites(serverSrc)).toEqual(["server/worktree-core.ts"]);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user