Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .talismanrc
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ fileignoreconfig:
allowed_patterns:
- "FlagKey"
- filename: src/resources.test.ts
checksum: 6ff9df735323c036cbd5eb5fb321fef110a05b7ae99e61d7687bebc2c0b6dde1
checksum: 6c2a0938d406767bbc80890aece988fbef1b01f809bd4b488403946aaef2ad37
allowed_patterns:
- "a project name passed on argv to the project resolver"
- "expect\\(Object.keys\\(DEPENDENCIES\\)\\).toEqual\\(\\['project', 'env'\\]\\)"
Expand All @@ -253,7 +253,7 @@ fileignoreconfig:
- filename: src/core/resolve.ts
checksum: a5608d22286efdd4915639faff6e05a588e60e205c74e0398e389822eb8c7292
- filename: src/core/resolve.test.ts
checksum: 8740a27f759a106e0ddcf38874f83394d2226dd8a908d9499898d774fea3a7a0
checksum: 7491778e802793695ae6a63e0d0652dd36f1058d8a608f28c9991807adf1cfd2
- filename: src/git/local-repository.ts
checksum: b9091ed135dfebdf590a5412bbfba2b2f96d4a177cf944a20909b93405268e9f
- filename: test/guards/layering.test.ts
Expand All @@ -267,7 +267,7 @@ fileignoreconfig:
- filename: src/core/launch-command.ts
checksum: 999468661532665870b81face9086998e543df648175e2417045840dc97cb1dd
- filename: src/core/launch-command.test.ts
checksum: c4488f07834e0c6e765a954cd30b3222eba05944f48bec01839f024b1cb7622f
checksum: 40c554e420c60e38d738190128588bc43c6f347da2d1e648b65d93419ca9f2c3
- filename: src/projects/project.inputs.test.ts
checksum: 8242f4d40388f1a7f1d08c11d2571cb45a9294069a8248a5272bc5606807bb60
- filename: test/integration/projects-command-flows.test.ts
Expand All @@ -279,7 +279,7 @@ fileignoreconfig:
- filename: src/commands/launch/env/list.test.ts
checksum: f5de16e0fd37a85ceb31a7fbc8e9058347ccc072f53c95d4f49ef15e923f4e95
- filename: src/commands/launch/projects/get.test.ts
checksum: ecc48c6a381de44858eafa57fdfd8c24c087837d2869909c8326db8e77148f29
checksum: 3aeffc4e4742ea9c5b3d9e6c5ea2248ced1d19a273bbc7d7948d471774b0d739
- filename: test/integration/projects-list-command.test.ts
checksum: 5f49dc7f384fb9e33c8fb91f1c67b17ffc2fd3bbde3663f90f820056407e98a0
- filename: src/functions/cloud-functions.test.ts
Expand Down
10 changes: 6 additions & 4 deletions src/commands/launch/projects/get.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import { resolveInputs } from '../../../core/resolve';
import type { UxLike } from '../../../core/prompt';
import ProjectsGet from './get';

const ORG_UID = 'blt1111111111111111';

function commandUnderTest(project: unknown) {
const lines: string[] = [];
const ux: UxLike = {
Expand All @@ -16,7 +18,7 @@ function commandUnderTest(project: unknown) {

Object.assign(command, {
ux,
resolved: { org: 'org1', project: 'a'.repeat(24) },
resolved: { org: ORG_UID, project: 'a'.repeat(24) },
services: {
ux,
isTTY: false,
Expand Down Expand Up @@ -45,7 +47,7 @@ describe('launch:projects:get', () => {

await command.run();

expect(fetched).toEqual([{ org: 'org1', project: 'a'.repeat(24) }]);
expect(fetched).toEqual([{ org: ORG_UID, project: 'a'.repeat(24) }]);
expect(lines).toEqual([
'\u250c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u252c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u252c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u252c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510',
'\u2502 NAME \u2502 TYPE \u2502 PROJECT UID \u2502 DESCRIPTION \u2502',
Expand Down Expand Up @@ -107,7 +109,7 @@ describe('launch:projects:get', () => {
} as unknown as ApiSurface;

const resolved = await resolveInputs(ProjectsGet.inputs, {
parsed: { org: 'org1', project: 'site' },
parsed: { org: ORG_UID, project: 'site' },
projectConfig: {},
services: { api, ux, isTTY: false },
});
Expand All @@ -117,6 +119,6 @@ describe('launch:projects:get', () => {
await command.run();

expect(resolved.project).toBe('a'.repeat(24));
expect(fetched).toEqual([{ org: 'org1', project: 'a'.repeat(24) }]);
expect(fetched).toEqual([{ org: ORG_UID, project: 'a'.repeat(24) }]);
});
});
28 changes: 15 additions & 13 deletions src/commands/launch/projects/update.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import type { ApiSurface } from '../../../resources';
import type { Project } from '../../../projects/types';
import ProjectsUpdate from './update';

const ORG_UID = 'blt1111111111111111';

const PROJECT_UID = 'a1b2c3d4e5f60718293a4b5c';

interface Terminal {
Expand Down Expand Up @@ -37,7 +39,7 @@ function commandUnderTest(

Object.assign(command, {
ux,
resolved: { org: 'org1', project: PROJECT_UID, ...resolved },
resolved: { org: ORG_UID, project: PROJECT_UID, ...resolved },
services: {
ux,
isTTY: terminal !== undefined,
Expand Down Expand Up @@ -68,7 +70,7 @@ function commandUnderTest(

function fakeServices() {
const ux: UxLike = { print: () => undefined, inquire: async () => undefined as never };
const projects = { get: async () => ({ uid: PROJECT_UID, organizationUid: 'org1' }) };
const projects = { get: async () => ({ uid: PROJECT_UID, organizationUid: ORG_UID }) };
return { api: { projects } as unknown as ApiSurface, ux, isTTY: false };
}

Expand All @@ -78,7 +80,7 @@ describe('launch:projects:update', () => {

await command.run();

expect(sent).toEqual([{ org: 'org1', project: PROJECT_UID, update: { name: 'Renamed Site' } }]);
expect(sent).toEqual([{ org: ORG_UID, project: PROJECT_UID, update: { name: 'Renamed Site' } }]);
expect(lines).toEqual(['✔ Project updated successfully.']);
});

Expand All @@ -94,7 +96,7 @@ describe('launch:projects:update', () => {

await command.run();

expect(sent).toEqual([{ org: 'org1', project: PROJECT_UID, update: { description: 'A new blurb' } }]);
expect(sent).toEqual([{ org: ORG_UID, project: PROJECT_UID, update: { description: 'A new blurb' } }]);
expect(lines).toEqual(['✔ Project updated successfully.']);
});

Expand All @@ -111,7 +113,7 @@ describe('launch:projects:update', () => {
await command.run();

expect(sent).toEqual([
{ org: 'org1', project: PROJECT_UID, update: { name: 'Renamed Site', description: 'A new blurb' } },
{ org: ORG_UID, project: PROJECT_UID, update: { name: 'Renamed Site', description: 'A new blurb' } },
]);
expect(lines).toEqual(['✔ Project updated successfully.']);
});
Expand Down Expand Up @@ -159,7 +161,7 @@ describe('launch:projects:update', () => {
await command.run();

expect(asked).toHaveLength(2);
expect(sent).toEqual([{ org: 'org1', project: PROJECT_UID, update: { name: 'test-renamed' } }]);
expect(sent).toEqual([{ org: ORG_UID, project: PROJECT_UID, update: { name: 'test-renamed' } }]);
expect(lines).toEqual(['✔ Project updated successfully.']);
});

Expand All @@ -173,7 +175,7 @@ describe('launch:projects:update', () => {

await command.run();

expect(sent).toEqual([{ org: 'org1', project: PROJECT_UID, update: { description: 'Marketing site for Q4' } }]);
expect(sent).toEqual([{ org: ORG_UID, project: PROJECT_UID, update: { description: 'Marketing site for Q4' } }]);
expect(lines).toEqual(['✔ Project updated successfully.']);
});

Expand All @@ -190,7 +192,7 @@ describe('launch:projects:update', () => {
expect(asked).toEqual([]);
expect(fetched).toEqual([]);
expect(sent).toEqual([
{ org: 'org1', project: PROJECT_UID, update: { name: 'Renamed Site', description: undefined } },
{ org: ORG_UID, project: PROJECT_UID, update: { name: 'Renamed Site', description: undefined } },
]);
expect(lines).toEqual(['✔ Project updated successfully.']);
});
Expand All @@ -208,7 +210,7 @@ describe('launch:projects:update', () => {
expect(asked).toEqual([]);
expect(fetched).toEqual([]);
expect(sent).toEqual([
{ org: 'org1', project: PROJECT_UID, update: { name: undefined, description: 'A new blurb' } },
{ org: ORG_UID, project: PROJECT_UID, update: { name: undefined, description: 'A new blurb' } },
]);
expect(lines).toEqual(['✔ Project updated successfully.']);
});
Expand All @@ -226,7 +228,7 @@ describe('launch:projects:update', () => {
expect(asked).toEqual([]);
expect(fetched).toEqual([]);
expect(sent).toEqual([
{ org: 'org1', project: PROJECT_UID, update: { name: 'Renamed Site', description: 'A new blurb' } },
{ org: ORG_UID, project: PROJECT_UID, update: { name: 'Renamed Site', description: 'A new blurb' } },
]);
});

Expand All @@ -238,7 +240,7 @@ describe('launch:projects:update', () => {
expect(asked).toEqual([]);
expect(fetched).toEqual([]);
expect(sent).toEqual([
{ org: 'org1', project: PROJECT_UID, update: { name: 'Renamed Site', description: undefined } },
{ org: ORG_UID, project: PROJECT_UID, update: { name: 'Renamed Site', description: undefined } },
]);
});

Expand Down Expand Up @@ -288,7 +290,7 @@ describe('launch:projects:update', () => {
it('accepts a resolution carrying only one of the two updatable fields', async () => {
await expect(
resolveInputs(ProjectsUpdate.inputs, {
parsed: { org: 'org1', project: PROJECT_UID, description: 'A new blurb' },
parsed: { org: ORG_UID, project: PROJECT_UID, description: 'A new blurb' },
projectConfig: {},
services: fakeServices(),
}),
Expand All @@ -297,7 +299,7 @@ describe('launch:projects:update', () => {

it('rejects a name over the server limit as a usage error before sending', async () => {
const error = (await resolveInputs(ProjectsUpdate.inputs, {
parsed: { org: 'org1', project: PROJECT_UID, name: 'n'.repeat(201) },
parsed: { org: ORG_UID, project: PROJECT_UID, name: 'n'.repeat(201) },
projectConfig: {},
services: fakeServices(),
}).catch((thrown: unknown) => thrown)) as UsageError;
Expand Down
25 changes: 14 additions & 11 deletions src/core/launch-command.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ import type { SearchListClass } from './search-list';
import { promptLibrary, utilitiesLoader } from './search-list';
import { pretendTerminal, stdinReportingTTY, stdoutReportingTTY } from '../../test/support/terminal';

const ORG_UID = 'blt1111111111111111';
const ORG_FROM_FLAG = 'blt2222222222222222';

class Probe extends LaunchCommand {
static flags = {};
static inputs = {};
Expand Down Expand Up @@ -322,7 +325,7 @@ describe('LaunchCommand.init', () => {
}));

await instance.init();
await instance['services'].api.projects.list({ org: 'org1' });
await instance['services'].api.projects.list({ org: ORG_UID });

expect(parseMock).toHaveBeenCalledWith({ flags: Probe.flags, baseFlags: LaunchCommand.baseFlags, strict: true });
expect(capturedBaseUrl).toBe(getManageApiBaseUrl('https://launch-api.test'));
Expand Down Expand Up @@ -389,7 +392,7 @@ describe('LaunchCommand.init', () => {
const contextSpy = jest.spyOn(serviceContext, 'buildServiceContext');

await instance.init();
await instance['services'].api.projects.list({ org: 'org1' });
await instance['services'].api.projects.list({ org: ORG_UID });

expect(capturedBaseUrl).toBe(getManageApiBaseUrl('https://launch-api.contentstack.com'));
expect(contextSpy).toHaveBeenCalledWith(
Expand Down Expand Up @@ -543,8 +546,8 @@ describe('LaunchCommand.init terminal detection', () => {
);

await instance.init();
await instance['services'].api.projects.list({ org: 'org1', limit: 5, skip: 10 });
await instance['services'].api.projects.update({ org: 'org1', project: 'p1', update: { name: 'Renamed' } });
await instance['services'].api.projects.list({ org: ORG_UID, limit: 5, skip: 10 });
await instance['services'].api.projects.update({ org: ORG_UID, project: 'p1', update: { name: 'Renamed' } });

expect(capturedHeaders?.['X-CS-CLI']).toBe('csdx-cli/2.0.0 darwin-arm64');
expect(wire.sent).toEqual([
Expand Down Expand Up @@ -616,7 +619,7 @@ describe('LaunchCommand.init config file notice', () => {
});

it('prints nothing when every value came from a flag', async () => {
const { printed } = await initInFolderHoldingAnOrg({ org: 'org-from-flag' });
const { printed } = await initInFolderHoldingAnOrg({ org: ORG_FROM_FLAG });

expect(printed).toEqual([]);
});
Expand All @@ -634,7 +637,7 @@ describe('LaunchCommand.init rules', () => {
Object.defineProperty(instance, 'config', { value: { userAgent: 'cli/2.0.0' }, configurable: true });
(instance as unknown as { parse: jest.Mock }).parse = jest
.fn()
.mockResolvedValue({ flags: { org: 'org1', limit: 10 } });
.mockResolvedValue({ flags: { org: ORG_UID, limit: 10 } });

await expect(instance.init()).rejects.toThrow('Pass exactly one of --org, --limit; --org, --limit were supplied.');

Expand All @@ -645,7 +648,7 @@ describe('LaunchCommand.init rules', () => {
describe('resolveLaunchContext rules', () => {
it('passes the declared rules through to the resolver, which evaluates them', async () => {
const promise = resolveLaunchContext({
flags: { org: 'org1', limit: 10 },
flags: { org: ORG_UID, limit: 10 },
inputs: { org: {}, limit: {} },
rules: [exactlyOneOf('org', 'limit')],
launchHubUrl: 'https://launch-api.test',
Expand Down Expand Up @@ -781,7 +784,7 @@ describe('resolveLaunchContext', () => {
});

it('words no notice when the flags supplied every value the config file also holds', async () => {
const result = await contextInFolderHoldingAnOrg({ org: 'org-from-flag' });
const result = await contextInFolderHoldingAnOrg({ org: ORG_FROM_FLAG });

expect(result.configNotice).toBeUndefined();
});
Expand All @@ -795,14 +798,14 @@ describe('projectConfigLoader', () => {
}

it('reads a default-location config only when a value is first needed, and only once', () => {
const { store: lazy, load } = store({ organizationUid: 'org1' });
const { store: lazy, load } = store({ organizationUid: ORG_UID });

const loader = projectConfigLoader(lazy, false);

expect(load).not.toHaveBeenCalled();
expect(typeof loader).toBe('function');
expect((loader as () => object)()).toEqual({ organizationUid: 'org1' });
expect((loader as () => object)()).toEqual({ organizationUid: 'org1' });
expect((loader as () => object)()).toEqual({ organizationUid: ORG_UID });
expect((loader as () => object)()).toEqual({ organizationUid: ORG_UID });
expect(load).toHaveBeenCalledTimes(1);
});

Expand Down
Loading
Loading