mirror of
https://github.com/stack-auth/stack.git
synced 2026-06-04 21:04:37 +08:00
test: update stale e2e CLI + RDE config tests after emulator removal & hexclave rename
cli.test.ts: the `stack emulator` command was removed in #1522 (which reworded its auth errors "local emulator" -> "development environment") but the e2e tests were never updated. Update the two error-string assertions and remove the dead "Stack CLI — Emulator" describe block (plus the now-unused CLI_SRC_BIN const). config-file.test.ts: fix leftover @stackframe/* references from the @hexclave rename — the defineStackConfig/defineHexclaveConfig fixtures now import from @hexclave/shared/config, and the rendered-config snapshot now imports the StackConfig type from @hexclave/js.
This commit is contained in:
parent
40dd1d2cd7
commit
a887d7209b
@ -24,7 +24,7 @@ afterEach(() => {
|
||||
describe("remote development environment config file", () => {
|
||||
it("loads config exports wrapped in defineStackConfig", async () => {
|
||||
const configPath = writeTempConfig(`
|
||||
import { defineStackConfig } from "@stackframe/stack-shared/config";
|
||||
import { defineStackConfig } from "@hexclave/shared/config";
|
||||
|
||||
export const config = defineStackConfig({
|
||||
auth: {
|
||||
@ -49,7 +49,7 @@ describe("remote development environment config file", () => {
|
||||
|
||||
it("loads config exports wrapped in defineHexclaveConfig", async () => {
|
||||
const configPath = writeTempConfig(`
|
||||
import { defineHexclaveConfig } from "@stackframe/stack-shared/config";
|
||||
import { defineHexclaveConfig } from "@hexclave/shared/config";
|
||||
|
||||
export const config = defineHexclaveConfig({
|
||||
auth: {
|
||||
@ -182,7 +182,7 @@ describe("remote development environment config file", () => {
|
||||
});
|
||||
|
||||
expect(readFileSync(configPath, "utf-8")).toMatchInlineSnapshot(`
|
||||
"import type { StackConfig } from "@stackframe/js";
|
||||
"import type { StackConfig } from "@hexclave/js";
|
||||
|
||||
export const config: StackConfig = {
|
||||
"auth": {
|
||||
|
||||
@ -10,7 +10,6 @@ import { it, niceFetch, STACK_BACKEND_BASE_URL, STACK_INTERNAL_PROJECT_CLIENT_KE
|
||||
const isLocalEmulator = process.env.NEXT_PUBLIC_STACK_IS_LOCAL_EMULATOR === "true";
|
||||
|
||||
const CLI_BIN = path.resolve("packages/stack-cli/dist/index.js");
|
||||
const CLI_SRC_BIN = path.resolve("packages/stack-cli/src/index.ts");
|
||||
|
||||
function extractConfigObjectString(content: string): string {
|
||||
const configMatch = content.match(/export const config:\s*StackConfig\s*=\s*(.+);\s*$/s);
|
||||
@ -375,7 +374,7 @@ describe("Stack CLI", () => {
|
||||
},
|
||||
);
|
||||
expect(exitCode).toBe(1);
|
||||
expect(stderr).toContain("Local emulator publishable client key not found");
|
||||
expect(stderr).toContain("Development environment publishable client key not found");
|
||||
} finally {
|
||||
fs.rmSync(fakeEmulatorHome, { recursive: true });
|
||||
}
|
||||
@ -401,7 +400,7 @@ describe("Stack CLI", () => {
|
||||
},
|
||||
);
|
||||
expect(exitCode).toBe(1);
|
||||
expect(stderr).toContain("Cannot reach local emulator");
|
||||
expect(stderr).toContain("Cannot reach development environment");
|
||||
} finally {
|
||||
fs.rmSync(fakeEmulatorHome, { recursive: true });
|
||||
}
|
||||
@ -669,75 +668,6 @@ describe("Stack CLI", () => {
|
||||
});
|
||||
});
|
||||
|
||||
// Emulator CLI tests — no backend required, just validates help/arg parsing
|
||||
describe("Stack CLI — Emulator", () => {
|
||||
function runCliBare(
|
||||
args: string[],
|
||||
): Promise<{ stdout: string, stderr: string, exitCode: number | null }> {
|
||||
return new Promise((resolve) => {
|
||||
execFile("node", [CLI_BIN, ...args], {
|
||||
env: { PATH: process.env.PATH ?? "", HOME: process.env.HOME ?? "", CI: "1" },
|
||||
timeout: 15_000,
|
||||
}, (error, stdout, stderr) => {
|
||||
resolve({
|
||||
stdout: stdout.toString(),
|
||||
stderr: stderr.toString(),
|
||||
exitCode: error ? (error as any).code ?? 1 : 0,
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function runCliBareFromSource(
|
||||
args: string[],
|
||||
): Promise<{ stdout: string, stderr: string, exitCode: number | null }> {
|
||||
return new Promise((resolve) => {
|
||||
execFile("node", ["--import", "tsx", CLI_SRC_BIN, ...args], {
|
||||
env: { PATH: process.env.PATH ?? "", HOME: process.env.HOME ?? "", CI: "1" },
|
||||
timeout: 15_000,
|
||||
}, (error, stdout, stderr) => {
|
||||
resolve({
|
||||
stdout: stdout.toString(),
|
||||
stderr: stderr.toString(),
|
||||
exitCode: error ? (error as any).code ?? 1 : 0,
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
it("emulator help shows subcommands", async ({ expect }) => {
|
||||
const { stdout, exitCode } = await runCliBare(["emulator", "--help"]);
|
||||
expect(exitCode).toBe(0);
|
||||
expect(stdout).toContain("pull");
|
||||
expect(stdout).toContain("start");
|
||||
expect(stdout).toContain("stop");
|
||||
expect(stdout).toContain("reset");
|
||||
expect(stdout).toContain("status");
|
||||
expect(stdout).toContain("list-releases");
|
||||
});
|
||||
|
||||
it("emulator pull help shows options", async ({ expect }) => {
|
||||
const { stdout, exitCode } = await runCliBare(["emulator", "pull", "--help"]);
|
||||
expect(exitCode).toBe(0);
|
||||
expect(stdout).toContain("--arch");
|
||||
expect(stdout).toContain("--branch");
|
||||
expect(stdout).toContain("--tag");
|
||||
expect(stdout).toContain("--repo");
|
||||
});
|
||||
|
||||
it("emulator pull rejects invalid arch values", async ({ expect }) => {
|
||||
const { stderr, exitCode } = await runCliBareFromSource(["emulator", "pull", "--arch", "sparc"]);
|
||||
expect(exitCode).toBe(1);
|
||||
expect(stderr).toContain("Invalid architecture: sparc. Expected arm64 or amd64.");
|
||||
});
|
||||
|
||||
it("emulator list-releases help shows repo option", async ({ expect }) => {
|
||||
const { stdout, exitCode } = await runCliBare(["emulator", "list-releases", "--help"]);
|
||||
expect(exitCode).toBe(0);
|
||||
expect(stdout).toContain("--repo");
|
||||
});
|
||||
});
|
||||
|
||||
// Doctor CLI tests — no backend required. Each test builds a fixture project
|
||||
// in a temp dir and runs `stack doctor --output-dir <dir> --json`.
|
||||
describe("Stack CLI — Doctor", () => {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user