Files
api/plugin/builder/__tests__/cli/setup-txz-environment.spec.ts
Eli Bosley 88087d5201 feat: mount vue apps, not web components (#1639)
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

* **New Features**
* Standalone web bundle with auto-mount utilities and a self-contained
test page.
* New responsive modal components for consistent mobile/desktop dialogs.
  * Header actions to copy OS/API versions.

* **Improvements**
* Refreshed UI styles (muted borders), accessibility and animation
refinements.
  * Theming updates and Tailwind v4–aligned, component-scoped styles.
  * Runtime GraphQL endpoint override and CSRF header support.

* **Bug Fixes**
* Safer network fetching and improved manifest/asset loading with
duplicate protection.

* **Tests/Chores**
* Parallel plugin tests, new extractor test suite, and updated
build/test scripts.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2025-09-03 15:42:21 -04:00

84 lines
2.3 KiB
TypeScript

import { join } from "path";
import { validateTxzEnv, TxzEnv } from "../../cli/setup-txz-environment";
import { describe, it, expect, vi } from "vitest";
import { startingDir } from "../../utils/consts";
import { deployDir } from "../../utils/paths";
describe("setupTxzEnvironment", () => {
it("should return default values when no arguments are provided", async () => {
const envArgs = {
apiVersion: "4.17.0",
baseUrl: "https://example.com"
};
const expected: TxzEnv = {
apiVersion: "4.17.0",
baseUrl: "https://example.com",
ci: false,
skipValidation: "false",
compress: "1",
txzOutputDir: join(startingDir, deployDir),
tag: "",
buildNumber: 1
};
const result = await validateTxzEnv(envArgs);
expect(result).toEqual(expected);
});
it("should parse and return provided environment arguments", async () => {
const envArgs = {
apiVersion: "4.17.0",
baseUrl: "https://example.com",
ci: true,
skipValidation: "true",
txzOutputDir: join(startingDir, "deploy/release/test"),
compress: '8'
};
const expected: TxzEnv = {
apiVersion: "4.17.0",
baseUrl: "https://example.com",
ci: true,
skipValidation: "true",
compress: "8",
txzOutputDir: join(startingDir, "deploy/release/test"),
tag: "",
buildNumber: 1
};
const result = await validateTxzEnv(envArgs);
expect(result).toEqual(expected);
});
it("should warn and skip validation when skipValidation is true", async () => {
const envArgs = {
apiVersion: "4.17.0",
baseUrl: "https://example.com",
skipValidation: "true"
};
const consoleWarnSpy = vi
.spyOn(console, "warn")
.mockImplementation(() => {});
await validateTxzEnv(envArgs);
expect(consoleWarnSpy).toHaveBeenCalledWith(
"skipValidation is true, skipping validation"
);
consoleWarnSpy.mockRestore();
});
it("should throw an error for invalid SKIP_VALIDATION value", async () => {
const envArgs = {
apiVersion: "4.17.0",
baseUrl: "https://example.com",
skipValidation: "invalid"
};
await expect(validateTxzEnv(envArgs)).rejects.toThrow(
"Must be true or false"
);
});
});