@minniexcode/codex-switch 0.0.5 → 0.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.AI.md +5 -2
- package/README.md +44 -100
- package/dist/app/add-provider.js +28 -4
- package/dist/app/edit-provider.js +47 -19
- package/dist/app/export-providers.js +2 -2
- package/dist/app/get-current-profile.js +1 -1
- package/dist/app/get-status.js +10 -3
- package/dist/app/import-providers.js +15 -7
- package/dist/app/init-codex.js +68 -0
- package/dist/app/list-backups.js +1 -1
- package/dist/app/list-config-profiles.js +3 -2
- package/dist/app/list-providers.js +2 -1
- package/dist/app/remove-provider.js +2 -2
- package/dist/app/rollback-backup.js +1 -1
- package/dist/app/rollback-latest.js +1 -1
- package/dist/app/run-doctor.js +83 -6
- package/dist/app/run-mutation.js +2 -2
- package/dist/app/setup-codex.js +21 -12
- package/dist/app/show-config.js +11 -3
- package/dist/app/show-provider.js +1 -1
- package/dist/app/switch-provider.js +16 -9
- package/dist/cli/add-interactive.js +7 -104
- package/dist/cli/args.js +6 -135
- package/dist/cli/help.js +8 -313
- package/dist/cli/interactive.js +17 -225
- package/dist/cli/output.js +21 -6
- package/dist/cli/prompt.js +4 -106
- package/dist/cli.js +10 -404
- package/dist/commands/args.js +132 -0
- package/dist/commands/dispatch.js +16 -0
- package/dist/commands/handlers.js +460 -0
- package/dist/commands/help.js +120 -0
- package/dist/commands/registry.js +351 -0
- package/dist/commands/types.js +2 -0
- package/dist/domain/config.js +235 -21
- package/dist/domain/providers.js +16 -2
- package/dist/domain/setup.js +1 -0
- package/dist/infra/backup-repo.js +9 -206
- package/dist/infra/codex-cli.js +9 -126
- package/dist/infra/codex-paths.js +6 -67
- package/dist/infra/config-repo.js +59 -0
- package/dist/infra/fs-utils.js +8 -93
- package/dist/infra/lock-repo.js +4 -95
- package/dist/infra/providers-repo.js +8 -94
- package/dist/interaction/add-interactive.js +99 -0
- package/dist/interaction/interactive.js +289 -0
- package/dist/interaction/prompt.js +110 -0
- package/dist/runtime/codex-cli.js +130 -0
- package/dist/runtime/codex-probe.js +57 -0
- package/dist/runtime/types.js +2 -0
- package/dist/storage/auth-repo.js +160 -0
- package/dist/storage/backup-repo.js +210 -0
- package/dist/storage/codex-paths.js +71 -0
- package/dist/storage/config-repo.js +266 -0
- package/dist/storage/fs-utils.js +97 -0
- package/dist/storage/lock-repo.js +99 -0
- package/dist/storage/providers-repo.js +98 -0
- package/docs/Design/codex-switch-v0.0.5-design.md +32 -22
- package/docs/Design/codex-switch-v0.0.6-design.md +708 -0
- package/docs/Design/codex-switch-v0.0.7-design.md +862 -0
- package/docs/PRD/codex-switch-prd-v0.0.5-to-v0.1.0.md +227 -89
- package/docs/PRD/codex-switch-prd-v0.1.0.md +200 -226
- package/docs/PRD/codex-switch-prd.md +1 -1
- package/docs/Reference/codex-config-reference.md +604 -0
- package/docs/Reference/codex-config-reference.zh-CN.md +633 -0
- package/docs/cli-usage.md +78 -29
- package/docs/codex-switch-technical-architecture.md +73 -4
- package/docs/test-report-0.0.5.md +163 -0
- package/docs/test-report-0.0.7.md +118 -0
- package/docs/testing.md +151 -0
- package/package.json +1 -1
package/docs/testing.md
ADDED
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
# Testing Guide
|
|
2
|
+
|
|
3
|
+
`codex-switch` currently ships with five active test layers:
|
|
4
|
+
|
|
5
|
+
- `tests/commands.spec.js`: argument parsing, help rendering, and command dispatch contracts
|
|
6
|
+
- `tests/cli-e2e.spec.js`: built CLI entrypoint checks for user-visible command behavior and rendered output
|
|
7
|
+
- `tests/interaction.spec.js`: prompt boundary and interactive data collection behavior
|
|
8
|
+
- `tests/runtime.spec.js`: Codex runtime probing and version checks
|
|
9
|
+
- `tests/workflows.spec.js`: file-backed app workflow coverage for write operations and rollback paths
|
|
10
|
+
|
|
11
|
+
## Commands
|
|
12
|
+
|
|
13
|
+
Build the CLI:
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
npm run build
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
Run the full suite:
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
npm test
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
`npm test` is not compile-only. It runs:
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
npm run build
|
|
29
|
+
node tests/run-tests.js
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
Run one suite manually:
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
node -e "require('./tests/cli-e2e.spec').tests[0].run()"
|
|
36
|
+
node -e "require('./tests/workflows.spec').tests[0].run()"
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## Development Fixture
|
|
40
|
+
|
|
41
|
+
The repository fixture lives at:
|
|
42
|
+
|
|
43
|
+
```text
|
|
44
|
+
dev-codex/local-sandbox/
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
It is used in two different ways:
|
|
48
|
+
|
|
49
|
+
- read-oriented CLI subprocess tests point at it directly
|
|
50
|
+
- write-oriented tests copy it into a temporary directory before running mutations
|
|
51
|
+
|
|
52
|
+
Do not point destructive automation directly at `dev-codex/local-sandbox` unless you intentionally want to update the fixture.
|
|
53
|
+
|
|
54
|
+
## Built CLI Coverage
|
|
55
|
+
|
|
56
|
+
`tests/cli-e2e.spec.js` executes the built CLI entrypoint logic from `dist/` and asserts the same JSON and human-readable payloads users see.
|
|
57
|
+
|
|
58
|
+
Covered entrypoint checks:
|
|
59
|
+
|
|
60
|
+
- `--help`
|
|
61
|
+
- `--version`
|
|
62
|
+
|
|
63
|
+
Covered read commands against the repository sandbox:
|
|
64
|
+
|
|
65
|
+
- `list --json`
|
|
66
|
+
- `show --json`
|
|
67
|
+
- `current --json`
|
|
68
|
+
- `status --json`
|
|
69
|
+
- `config show --json`
|
|
70
|
+
- `config list-profiles --json`
|
|
71
|
+
- `backups list --json`
|
|
72
|
+
- `doctor --json`
|
|
73
|
+
|
|
74
|
+
Covered write commands against temporary sandbox copies:
|
|
75
|
+
|
|
76
|
+
- `init --json`
|
|
77
|
+
- `add --json`
|
|
78
|
+
- `add --create-profile --json`
|
|
79
|
+
- `edit --json`
|
|
80
|
+
- `switch --json`
|
|
81
|
+
- `remove --force --json`
|
|
82
|
+
- `import --json`
|
|
83
|
+
- `export --force --json`
|
|
84
|
+
- `rollback --json`
|
|
85
|
+
- `setup --json`
|
|
86
|
+
|
|
87
|
+
Covered non-interactive failure contracts:
|
|
88
|
+
|
|
89
|
+
- `add` without an existing profile or `--create-profile`
|
|
90
|
+
- blocking destructive removal of the active provider profile
|
|
91
|
+
- `rollback <missing-id>`
|
|
92
|
+
- `migrate --overwrite --json`
|
|
93
|
+
- `setup --json`
|
|
94
|
+
|
|
95
|
+
This harness intentionally avoids `child_process` subprocess spawning because the current Windows sandbox used by automation blocks nested process launches with `EPERM`. The suite still validates the built CLI layer rather than calling app functions directly.
|
|
96
|
+
|
|
97
|
+
## Workflow Coverage
|
|
98
|
+
|
|
99
|
+
`tests/workflows.spec.js` keeps the deeper file-backed mutation coverage at the app/dispatch layer.
|
|
100
|
+
|
|
101
|
+
Important workflow scenarios already covered there include:
|
|
102
|
+
|
|
103
|
+
- non-interactive `init`
|
|
104
|
+
- non-interactive `migrate` failure behavior
|
|
105
|
+
- interactive `migrate` adoption via injected runtime
|
|
106
|
+
- `add`, `edit`, `remove`
|
|
107
|
+
- `switch` plus rollback
|
|
108
|
+
- `export` and `import`
|
|
109
|
+
- auth write rollback on failure
|
|
110
|
+
|
|
111
|
+
## Fixture Rules
|
|
112
|
+
|
|
113
|
+
- Prefer `--codex-dir <temp-copy>` for all write tests.
|
|
114
|
+
- Prefer `--json` when assertions need stable output.
|
|
115
|
+
- Treat `show --json` output as sensitive because it includes unmasked API keys.
|
|
116
|
+
- If a test needs `codex login` or `codex --version`, prefer mocking the spawn layer instead of assuming an installed local binary.
|
|
117
|
+
- Keep fixture assertions focused on stable data such as provider names, active profile, backup count, and typed error codes.
|
|
118
|
+
|
|
119
|
+
## Reporting Template
|
|
120
|
+
|
|
121
|
+
Use this template for release checks:
|
|
122
|
+
|
|
123
|
+
```text
|
|
124
|
+
Version under test: 0.0.x
|
|
125
|
+
Build: PASS/FAIL
|
|
126
|
+
Suite results:
|
|
127
|
+
- commands: PASS/FAIL
|
|
128
|
+
- cli-e2e: PASS/FAIL
|
|
129
|
+
- interaction: PASS/FAIL
|
|
130
|
+
- runtime: PASS/FAIL
|
|
131
|
+
- workflows: PASS/FAIL
|
|
132
|
+
|
|
133
|
+
Read command checks:
|
|
134
|
+
- help/version/list/show/current/status/config/backups/doctor
|
|
135
|
+
|
|
136
|
+
Mutation checks:
|
|
137
|
+
- init/add/edit/switch/remove/import/export/rollback/migrate/setup
|
|
138
|
+
|
|
139
|
+
Open risks:
|
|
140
|
+
- <risk 1>
|
|
141
|
+
- <risk 2>
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
## Current Gaps
|
|
145
|
+
|
|
146
|
+
Known areas that still deserve more coverage:
|
|
147
|
+
|
|
148
|
+
- true subprocess automation for interactive TTY-only flows such as prompt-driven `migrate`
|
|
149
|
+
- explicit tests for `rollback-latest`
|
|
150
|
+
- more backup corruption cases inside historical manifests
|
|
151
|
+
- docs and report snapshots should stay in sync with the current package version
|