Skip to content

Commit aafef91

Browse files
committed
Fix test isolation, fast polling, and cleanup low-value command tests
Test Isolation: - Add `credentialsFile` parameter to ResolveConfigOptions and LoadConfigOptions - Update MobifySource to use credentialsFile when provided (overrides ~/.mobify) - Add --credentials-file flag with MRT_CREDENTIALS_FILE env var to MrtCommand - Add config-isolation.ts helper to clear SFCC_*/MRT_* env vars for tests Fast Polling Tests: - Use short pollInterval for site-archive tests instead of default 3000ms - Tests now complete in milliseconds instead of seconds Command Test Cleanup: - Delete cartridge-command.test.ts (100% trivial delegation tests) - Simplify base-command.test.ts (keep getExtraParams, catch tests) - Simplify instance-command.test.ts (keep requireX, context tests) - Simplify mrt-command.test.ts (keep requireMrtCredentials only) - Simplify oauth-command.test.ts (keep parseAuthMethods, requireOAuthCredentials) - Simplify ods-command.test.ts (keep odsClient lazy init tests) Documentation: - Update testing skill with config isolation, pollInterval patterns - Add command test guidelines (what to test vs avoid) - Remove general knowledge content (basic Mocha/Chai patterns)
1 parent 2f35511 commit aafef91

16 files changed

Lines changed: 329 additions & 1532 deletions

.claude/skills/testing/SKILL.md

Lines changed: 144 additions & 229 deletions
Large diffs are not rendered by default.

packages/b2c-tooling-sdk/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,9 +244,9 @@
244244
},
245245
"dependencies": {
246246
"archiver": "^7.0.1",
247-
"fuse.js": "^7.0.0",
248247
"chokidar": "^5.0.0",
249248
"cliui": "^9.0.1",
249+
"fuse.js": "^7.0.0",
250250
"glob": "^13.0.0",
251251
"i18next": "^25.6.3",
252252
"jszip": "^3.10.1",

packages/b2c-tooling-sdk/src/cli/config.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ export interface LoadConfigOptions {
4444
configPath?: string;
4545
/** Cloud origin for MRT ~/.mobify lookup (e.g., https://cloud-staging.mobify.com) */
4646
cloudOrigin?: string;
47+
/** Path to custom MRT credentials file (overrides default ~/.mobify) */
48+
credentialsFile?: string;
4749
}
4850

4951
/**
@@ -110,6 +112,7 @@ export function loadConfig(
110112
configPath: options.configPath,
111113
hostnameProtection: true,
112114
cloudOrigin: options.cloudOrigin,
115+
credentialsFile: options.credentialsFile,
113116
sourcesBefore: pluginSources.before,
114117
sourcesAfter: pluginSources.after,
115118
});

packages/b2c-tooling-sdk/src/cli/mrt-command.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,15 +55,21 @@ export abstract class MrtCommand<T extends typeof Command> extends BaseCommand<T
5555
description: `MRT cloud origin URL (default: ${DEFAULT_MRT_ORIGIN})`,
5656
env: 'SFCC_MRT_CLOUD_ORIGIN',
5757
}),
58+
'credentials-file': Flags.string({
59+
description: 'Path to MRT credentials file (overrides default ~/.mobify)',
60+
env: 'MRT_CREDENTIALS_FILE',
61+
}),
5862
};
5963

6064
protected override loadConfiguration(): ResolvedConfig {
6165
const cloudOrigin = this.flags['cloud-origin'] as string | undefined;
66+
const credentialsFile = this.flags['credentials-file'] as string | undefined;
6267

6368
const options: LoadConfigOptions = {
6469
instance: this.flags.instance,
6570
configPath: this.flags.config,
6671
cloudOrigin, // MobifySource uses this to load ~/.mobify--[hostname] if set
72+
credentialsFile, // Override path to MRT credentials file
6773
};
6874

6975
const flagConfig: Partial<ResolvedConfig> = {

packages/b2c-tooling-sdk/src/config/sources/mobify-source.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@ export class MobifySource implements ConfigSource {
4141
private lastPath?: string;
4242

4343
load(options: ResolveConfigOptions): NormalizedConfig | undefined {
44-
const mobifyPath = this.getMobifyPath(options.cloudOrigin);
44+
// Use explicit credentialsFile if provided, otherwise use default path
45+
const mobifyPath = options.credentialsFile ?? this.getMobifyPath(options.cloudOrigin);
4546
this.lastPath = mobifyPath;
4647

4748
if (!fs.existsSync(mobifyPath)) {

packages/b2c-tooling-sdk/src/config/types.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,8 @@ export interface ResolveConfigOptions {
123123
hostnameProtection?: boolean;
124124
/** Cloud origin for ~/.mobify lookup (MRT) */
125125
cloudOrigin?: string;
126+
/** Path to custom MRT credentials file (overrides default ~/.mobify) */
127+
credentialsFile?: string;
126128

127129
/**
128130
* Custom sources to add BEFORE default sources (higher priority).

0 commit comments

Comments
 (0)