@nexical/cli 0.1.7 → 0.11.0
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/.github/workflows/deploy.yml +3 -3
- package/GEMINI.md +193 -0
- package/README.md +317 -104
- package/dist/chunk-JYASTIIW.js +42 -0
- package/dist/chunk-JYASTIIW.js.map +1 -0
- package/dist/chunk-LZ3YQWAR.js +2204 -0
- package/dist/chunk-LZ3YQWAR.js.map +1 -0
- package/dist/chunk-OKXOCNXP.js +105 -0
- package/dist/chunk-OKXOCNXP.js.map +1 -0
- package/dist/chunk-OYFWMYPG.js +52 -0
- package/dist/chunk-OYFWMYPG.js.map +1 -0
- package/dist/chunk-WKERTCM6.js +74 -0
- package/dist/chunk-WKERTCM6.js.map +1 -0
- package/dist/index.js +32 -5
- package/dist/index.js.map +1 -1
- package/dist/src/commands/init.d.ts +11 -0
- package/dist/src/commands/init.js +89 -0
- package/dist/src/commands/init.js.map +1 -0
- package/dist/src/commands/module/add.d.ts +14 -0
- package/dist/src/commands/module/add.js +136 -0
- package/dist/src/commands/module/add.js.map +1 -0
- package/dist/src/commands/module/list.d.ts +10 -0
- package/dist/src/commands/module/list.js +73 -0
- package/dist/src/commands/module/list.js.map +1 -0
- package/dist/src/commands/module/remove.d.ts +12 -0
- package/dist/src/commands/module/remove.js +71 -0
- package/dist/src/commands/module/remove.js.map +1 -0
- package/dist/src/commands/module/update.d.ts +11 -0
- package/dist/src/commands/module/update.js +52 -0
- package/dist/src/commands/module/update.js.map +1 -0
- package/dist/src/commands/run.d.ts +11 -0
- package/dist/src/commands/run.js +93 -0
- package/dist/src/commands/run.js.map +1 -0
- package/dist/src/commands/{login.d.ts → setup.d.ts} +2 -2
- package/dist/src/commands/setup.js +62 -0
- package/dist/src/commands/setup.js.map +1 -0
- package/dist/src/utils/discovery.d.ts +13 -0
- package/dist/src/utils/discovery.js +9 -0
- package/dist/src/utils/git.d.ts +16 -0
- package/dist/src/utils/git.js +29 -0
- package/dist/src/utils/git.js.map +1 -0
- package/dist/src/utils/url-resolver.d.ts +15 -0
- package/dist/src/utils/url-resolver.js +9 -0
- package/dist/src/utils/url-resolver.js.map +1 -0
- package/index.ts +29 -5
- package/package.json +32 -30
- package/src/commands/init.ts +86 -0
- package/src/commands/module/add.ts +169 -0
- package/src/commands/module/list.ts +69 -0
- package/src/commands/module/remove.ts +74 -0
- package/src/commands/module/update.ts +50 -0
- package/src/commands/run.ts +98 -0
- package/src/commands/setup.ts +74 -0
- package/src/utils/discovery.ts +134 -0
- package/src/utils/git.ts +65 -0
- package/src/utils/url-resolver.ts +57 -0
- package/test/e2e/lifecycle.e2e.test.ts +153 -0
- package/test/integration/commands/init.integration.test.ts +85 -0
- package/test/integration/commands/module.integration.test.ts +144 -0
- package/test/integration/commands/run.integration.test.ts +90 -0
- package/test/integration/utils/command-loading.integration.test.ts +80 -0
- package/test/unit/commands/init.test.ts +153 -0
- package/test/unit/commands/module/add.test.ts +262 -0
- package/test/unit/commands/module/list.test.ts +115 -0
- package/test/unit/commands/module/remove.test.ts +89 -0
- package/test/unit/commands/module/update.test.ts +91 -0
- package/test/unit/commands/run.test.ts +252 -0
- package/test/unit/commands/setup.test.ts +169 -0
- package/test/unit/utils/command-discovery.test.ts +176 -0
- package/test/unit/utils/git.test.ts +152 -0
- package/test/unit/utils/integration-helpers.test.ts +72 -0
- package/test/unit/utils/url-resolver.test.ts +39 -0
- package/test/utils/integration-helpers.ts +66 -0
- package/vitest.e2e.config.ts +0 -1
- package/dist/chunk-JDRAVUKK.js +0 -48
- package/dist/chunk-JDRAVUKK.js.map +0 -1
- package/dist/src/commands/admin/create-user.d.ts +0 -15
- package/dist/src/commands/admin/create-user.js +0 -49
- package/dist/src/commands/admin/create-user.js.map +0 -1
- package/dist/src/commands/branch/create.d.ts +0 -19
- package/dist/src/commands/branch/create.js +0 -59
- package/dist/src/commands/branch/create.js.map +0 -1
- package/dist/src/commands/branch/delete.d.ts +0 -15
- package/dist/src/commands/branch/delete.js +0 -50
- package/dist/src/commands/branch/delete.js.map +0 -1
- package/dist/src/commands/branch/get.d.ts +0 -15
- package/dist/src/commands/branch/get.js +0 -53
- package/dist/src/commands/branch/get.js.map +0 -1
- package/dist/src/commands/branch/list.d.ts +0 -15
- package/dist/src/commands/branch/list.js +0 -51
- package/dist/src/commands/branch/list.js.map +0 -1
- package/dist/src/commands/job/get.d.ts +0 -15
- package/dist/src/commands/job/get.js +0 -62
- package/dist/src/commands/job/get.js.map +0 -1
- package/dist/src/commands/job/list.d.ts +0 -15
- package/dist/src/commands/job/list.js +0 -57
- package/dist/src/commands/job/list.js.map +0 -1
- package/dist/src/commands/job/logs.d.ts +0 -15
- package/dist/src/commands/job/logs.js +0 -67
- package/dist/src/commands/job/logs.js.map +0 -1
- package/dist/src/commands/job/trigger.d.ts +0 -19
- package/dist/src/commands/job/trigger.js +0 -74
- package/dist/src/commands/job/trigger.js.map +0 -1
- package/dist/src/commands/login.js +0 -31
- package/dist/src/commands/login.js.map +0 -1
- package/dist/src/commands/project/create.d.ts +0 -24
- package/dist/src/commands/project/create.js +0 -63
- package/dist/src/commands/project/create.js.map +0 -1
- package/dist/src/commands/project/delete.d.ts +0 -20
- package/dist/src/commands/project/delete.js +0 -58
- package/dist/src/commands/project/delete.js.map +0 -1
- package/dist/src/commands/project/get.d.ts +0 -15
- package/dist/src/commands/project/get.js +0 -49
- package/dist/src/commands/project/get.js.map +0 -1
- package/dist/src/commands/project/list.d.ts +0 -15
- package/dist/src/commands/project/list.js +0 -45
- package/dist/src/commands/project/list.js.map +0 -1
- package/dist/src/commands/project/update.d.ts +0 -19
- package/dist/src/commands/project/update.js +0 -66
- package/dist/src/commands/project/update.js.map +0 -1
- package/dist/src/commands/team/create.d.ts +0 -19
- package/dist/src/commands/team/create.js +0 -45
- package/dist/src/commands/team/create.js.map +0 -1
- package/dist/src/commands/team/delete.d.ts +0 -20
- package/dist/src/commands/team/delete.js +0 -52
- package/dist/src/commands/team/delete.js.map +0 -1
- package/dist/src/commands/team/get.d.ts +0 -15
- package/dist/src/commands/team/get.js +0 -42
- package/dist/src/commands/team/get.js.map +0 -1
- package/dist/src/commands/team/list.d.ts +0 -8
- package/dist/src/commands/team/list.js +0 -30
- package/dist/src/commands/team/list.js.map +0 -1
- package/dist/src/commands/team/member/invite.d.ts +0 -20
- package/dist/src/commands/team/member/invite.js +0 -54
- package/dist/src/commands/team/member/invite.js.map +0 -1
- package/dist/src/commands/team/member/remove.d.ts +0 -15
- package/dist/src/commands/team/member/remove.js +0 -43
- package/dist/src/commands/team/member/remove.js.map +0 -1
- package/dist/src/commands/team/update.d.ts +0 -19
- package/dist/src/commands/team/update.js +0 -55
- package/dist/src/commands/team/update.js.map +0 -1
- package/dist/src/commands/token/generate.d.ts +0 -19
- package/dist/src/commands/token/generate.js +0 -48
- package/dist/src/commands/token/generate.js.map +0 -1
- package/dist/src/commands/token/list.d.ts +0 -8
- package/dist/src/commands/token/list.js +0 -31
- package/dist/src/commands/token/list.js.map +0 -1
- package/dist/src/commands/token/revoke.d.ts +0 -15
- package/dist/src/commands/token/revoke.js +0 -38
- package/dist/src/commands/token/revoke.js.map +0 -1
- package/dist/src/commands/whoami.d.ts +0 -8
- package/dist/src/commands/whoami.js +0 -26
- package/dist/src/commands/whoami.js.map +0 -1
- package/dist/src/utils/nexical-client.d.ts +0 -10
- package/dist/src/utils/nexical-client.js +0 -12
- package/src/commands/admin/create-user.ts +0 -46
- package/src/commands/branch/create.ts +0 -57
- package/src/commands/branch/delete.ts +0 -47
- package/src/commands/branch/get.ts +0 -50
- package/src/commands/branch/list.ts +0 -50
- package/src/commands/job/get.ts +0 -59
- package/src/commands/job/list.ts +0 -56
- package/src/commands/job/logs.ts +0 -67
- package/src/commands/job/trigger.ts +0 -73
- package/src/commands/login.ts +0 -31
- package/src/commands/project/create.ts +0 -61
- package/src/commands/project/delete.ts +0 -56
- package/src/commands/project/get.ts +0 -46
- package/src/commands/project/list.ts +0 -44
- package/src/commands/project/update.ts +0 -63
- package/src/commands/team/create.ts +0 -43
- package/src/commands/team/delete.ts +0 -50
- package/src/commands/team/get.ts +0 -39
- package/src/commands/team/list.ts +0 -26
- package/src/commands/team/member/invite.ts +0 -56
- package/src/commands/team/member/remove.ts +0 -40
- package/src/commands/team/update.ts +0 -53
- package/src/commands/token/generate.ts +0 -45
- package/src/commands/token/list.ts +0 -27
- package/src/commands/token/revoke.ts +0 -35
- package/src/commands/whoami.ts +0 -21
- package/src/utils/nexical-client.ts +0 -47
- package/test/e2e/auth.e2e.test.ts +0 -46
- package/test/e2e/job-workflow.e2e.test.ts +0 -33
- package/test/e2e/project-lifecycle.e2e.test.ts +0 -48
- package/test/e2e/setup.ts +0 -237
- package/test/e2e/utils.ts +0 -33
- package/test/integration/commands/admin/create-user.test.ts +0 -51
- package/test/integration/commands/branch/create.test.ts +0 -51
- package/test/integration/commands/branch/delete.test.ts +0 -43
- package/test/integration/commands/branch/get.test.ts +0 -49
- package/test/integration/commands/branch/list.test.ts +0 -47
- package/test/integration/commands/job/get.test.ts +0 -54
- package/test/integration/commands/job/list.test.ts +0 -47
- package/test/integration/commands/job/logs.test.ts +0 -47
- package/test/integration/commands/job/trigger.test.ts +0 -57
- package/test/integration/commands/login.test.ts +0 -62
- package/test/integration/commands/project/create.test.ts +0 -53
- package/test/integration/commands/project/delete.test.ts +0 -43
- package/test/integration/commands/project/get.test.ts +0 -51
- package/test/integration/commands/project/list.test.ts +0 -47
- package/test/integration/commands/project/update.test.ts +0 -53
- package/test/integration/commands/team/create.test.ts +0 -53
- package/test/integration/commands/team/delete.test.ts +0 -43
- package/test/integration/commands/team/get.test.ts +0 -50
- package/test/integration/commands/team/list.test.ts +0 -47
- package/test/integration/commands/team/member/invite.test.ts +0 -46
- package/test/integration/commands/team/member/remove.test.ts +0 -43
- package/test/integration/commands/team/update.test.ts +0 -50
- package/test/integration/commands/token/generate.test.ts +0 -51
- package/test/integration/commands/token/list.test.ts +0 -47
- package/test/integration/commands/token/revoke.test.ts +0 -43
- package/test/integration/commands/whoami.test.ts +0 -49
- package/test/unit/commands/admin/create-user.test.ts +0 -51
- package/test/unit/commands/branch/create.test.ts +0 -57
- package/test/unit/commands/branch/delete.test.ts +0 -49
- package/test/unit/commands/branch/get.test.ts +0 -67
- package/test/unit/commands/branch/list.test.ts +0 -62
- package/test/unit/commands/job/get.test.ts +0 -76
- package/test/unit/commands/job/list.test.ts +0 -62
- package/test/unit/commands/job/logs.test.ts +0 -60
- package/test/unit/commands/job/trigger.test.ts +0 -75
- package/test/unit/commands/login.test.ts +0 -64
- package/test/unit/commands/project/create.test.ts +0 -64
- package/test/unit/commands/project/delete.test.ts +0 -72
- package/test/unit/commands/project/get.test.ts +0 -73
- package/test/unit/commands/project/list.test.ts +0 -62
- package/test/unit/commands/project/update.test.ts +0 -58
- package/test/unit/commands/team/create.test.ts +0 -68
- package/test/unit/commands/team/delete.test.ts +0 -71
- package/test/unit/commands/team/get.test.ts +0 -70
- package/test/unit/commands/team/list.test.ts +0 -56
- package/test/unit/commands/team/member/invite.test.ts +0 -52
- package/test/unit/commands/team/member/remove.test.ts +0 -49
- package/test/unit/commands/team/update.test.ts +0 -63
- package/test/unit/commands/token/generate.test.ts +0 -65
- package/test/unit/commands/token/list.test.ts +0 -58
- package/test/unit/commands/token/revoke.test.ts +0 -49
- package/test/unit/commands/whoami.test.ts +0 -49
- package/test/unit/utils/nexical-client.test.ts +0 -113
- /package/dist/src/utils/{nexical-client.js.map → discovery.js.map} +0 -0
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
import { describe, it, expect, vi, beforeEach } from 'vitest';
|
|
3
|
-
import TeamsUpdateCommand from '../../../../src/commands/team/update.js';
|
|
4
|
-
import { getClient } from '../../../../src/utils/nexical-client.js';
|
|
5
|
-
|
|
6
|
-
vi.mock('../../../../src/utils/nexical-client.js');
|
|
7
|
-
|
|
8
|
-
describe('TeamsUpdateCommand Integration', () => {
|
|
9
|
-
let command: TeamsUpdateCommand;
|
|
10
|
-
let mockClient: any;
|
|
11
|
-
|
|
12
|
-
beforeEach(() => {
|
|
13
|
-
vi.resetAllMocks();
|
|
14
|
-
|
|
15
|
-
mockClient = {
|
|
16
|
-
teams: {
|
|
17
|
-
update: vi.fn(),
|
|
18
|
-
},
|
|
19
|
-
};
|
|
20
|
-
vi.mocked(getClient).mockReturnValue(mockClient);
|
|
21
|
-
|
|
22
|
-
command = new TeamsUpdateCommand([], {} as any);
|
|
23
|
-
vi.spyOn(command, 'success').mockImplementation(() => { });
|
|
24
|
-
vi.spyOn(command, 'info').mockImplementation(() => { });
|
|
25
|
-
vi.spyOn(command, 'error').mockImplementation(() => { });
|
|
26
|
-
vi.spyOn(command, 'warn').mockImplementation(() => { });
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
it('should update team successfully', async () => {
|
|
30
|
-
mockClient.teams.update.mockResolvedValue({
|
|
31
|
-
id: '1',
|
|
32
|
-
name: 'New Name'
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
await command.run({ teamId: '1', name: 'New Name' });
|
|
36
|
-
|
|
37
|
-
expect(mockClient.teams.update).toHaveBeenCalledWith(1, {
|
|
38
|
-
name: 'New Name'
|
|
39
|
-
});
|
|
40
|
-
expect(command.success).toHaveBeenCalledWith('Team 1 updated!');
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
it('should handle update failure', async () => {
|
|
44
|
-
mockClient.teams.update.mockRejectedValue(new Error('Update failed'));
|
|
45
|
-
|
|
46
|
-
await command.run({ teamId: '1', name: 'New Name' });
|
|
47
|
-
|
|
48
|
-
expect(command.error).toHaveBeenCalledWith('Failed to update team: Update failed');
|
|
49
|
-
});
|
|
50
|
-
});
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
import { describe, it, expect, vi, beforeEach } from 'vitest';
|
|
3
|
-
import AuthTokensGenerateCommand from '../../../../src/commands/token/generate.js';
|
|
4
|
-
import { getClient } from '../../../../src/utils/nexical-client.js';
|
|
5
|
-
|
|
6
|
-
vi.mock('../../../../src/utils/nexical-client.js');
|
|
7
|
-
|
|
8
|
-
describe('AuthTokensGenerateCommand Integration', () => {
|
|
9
|
-
let command: AuthTokensGenerateCommand;
|
|
10
|
-
let mockClient: any;
|
|
11
|
-
|
|
12
|
-
beforeEach(() => {
|
|
13
|
-
vi.resetAllMocks();
|
|
14
|
-
|
|
15
|
-
mockClient = {
|
|
16
|
-
auth: {
|
|
17
|
-
generateToken: vi.fn(),
|
|
18
|
-
},
|
|
19
|
-
};
|
|
20
|
-
vi.mocked(getClient).mockReturnValue(mockClient);
|
|
21
|
-
|
|
22
|
-
command = new AuthTokensGenerateCommand([], {} as any);
|
|
23
|
-
vi.spyOn(command, 'success').mockImplementation(() => { });
|
|
24
|
-
vi.spyOn(command, 'warn').mockImplementation(() => { });
|
|
25
|
-
vi.spyOn(command, 'error').mockImplementation(() => { });
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
it('should generate token successfully', async () => {
|
|
29
|
-
mockClient.auth.generateToken.mockResolvedValue({
|
|
30
|
-
name: 'My Token',
|
|
31
|
-
token: 'secret-token'
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
await command.run({ name: 'My Token', scopes: 'read' });
|
|
35
|
-
|
|
36
|
-
expect(mockClient.auth.generateToken).toHaveBeenCalledWith({
|
|
37
|
-
name: 'My Token',
|
|
38
|
-
scopes: ['read']
|
|
39
|
-
});
|
|
40
|
-
expect(command.success).toHaveBeenCalledWith('Token "My Token" generated!');
|
|
41
|
-
expect(command.warn).toHaveBeenCalledWith('Token: secret-token');
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
it('should handle generation failure', async () => {
|
|
45
|
-
mockClient.auth.generateToken.mockRejectedValue(new Error('Limit exceeded'));
|
|
46
|
-
|
|
47
|
-
await command.run({ name: 'My Token' });
|
|
48
|
-
|
|
49
|
-
expect(command.error).toHaveBeenCalledWith('Failed to generate token: Limit exceeded');
|
|
50
|
-
});
|
|
51
|
-
});
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
import { describe, it, expect, vi, beforeEach } from 'vitest';
|
|
3
|
-
import AuthTokensListCommand from '../../../../src/commands/token/list.js';
|
|
4
|
-
import { getClient } from '../../../../src/utils/nexical-client.js';
|
|
5
|
-
|
|
6
|
-
vi.mock('../../../../src/utils/nexical-client.js');
|
|
7
|
-
|
|
8
|
-
describe('AuthTokensListCommand Integration', () => {
|
|
9
|
-
let command: AuthTokensListCommand;
|
|
10
|
-
let mockClient: any;
|
|
11
|
-
|
|
12
|
-
beforeEach(() => {
|
|
13
|
-
vi.resetAllMocks();
|
|
14
|
-
|
|
15
|
-
mockClient = {
|
|
16
|
-
auth: {
|
|
17
|
-
listTokens: vi.fn(),
|
|
18
|
-
},
|
|
19
|
-
};
|
|
20
|
-
vi.mocked(getClient).mockReturnValue(mockClient);
|
|
21
|
-
|
|
22
|
-
command = new AuthTokensListCommand([], {} as any);
|
|
23
|
-
vi.spyOn(command, 'info').mockImplementation(() => { });
|
|
24
|
-
vi.spyOn(command, 'error').mockImplementation(() => { });
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
it('should list tokens successfully', async () => {
|
|
28
|
-
mockClient.auth.listTokens.mockResolvedValue({
|
|
29
|
-
tokens: [
|
|
30
|
-
{ name: 'Token 1', tokenPrefix: 'abc', expiresAt: null }
|
|
31
|
-
]
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
await command.run();
|
|
35
|
-
|
|
36
|
-
expect(mockClient.auth.listTokens).toHaveBeenCalled();
|
|
37
|
-
expect(command.info).toHaveBeenCalledWith('Your API Tokens:');
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
it('should handle list failure', async () => {
|
|
41
|
-
mockClient.auth.listTokens.mockRejectedValue(new Error('Network error'));
|
|
42
|
-
|
|
43
|
-
await command.run();
|
|
44
|
-
|
|
45
|
-
expect(command.error).toHaveBeenCalledWith('Failed to list tokens: Network error');
|
|
46
|
-
});
|
|
47
|
-
});
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
import { describe, it, expect, vi, beforeEach } from 'vitest';
|
|
3
|
-
import AuthTokensRevokeCommand from '../../../../src/commands/token/revoke.js';
|
|
4
|
-
import { getClient } from '../../../../src/utils/nexical-client.js';
|
|
5
|
-
|
|
6
|
-
vi.mock('../../../../src/utils/nexical-client.js');
|
|
7
|
-
|
|
8
|
-
describe('AuthTokensRevokeCommand Integration', () => {
|
|
9
|
-
let command: AuthTokensRevokeCommand;
|
|
10
|
-
let mockClient: any;
|
|
11
|
-
|
|
12
|
-
beforeEach(() => {
|
|
13
|
-
vi.resetAllMocks();
|
|
14
|
-
|
|
15
|
-
mockClient = {
|
|
16
|
-
auth: {
|
|
17
|
-
revokeToken: vi.fn(),
|
|
18
|
-
},
|
|
19
|
-
};
|
|
20
|
-
vi.mocked(getClient).mockReturnValue(mockClient);
|
|
21
|
-
|
|
22
|
-
command = new AuthTokensRevokeCommand([], {} as any);
|
|
23
|
-
vi.spyOn(command, 'success').mockImplementation(() => { });
|
|
24
|
-
vi.spyOn(command, 'error').mockImplementation(() => { });
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
it('should revoke token successfully', async () => {
|
|
28
|
-
mockClient.auth.revokeToken.mockResolvedValue({});
|
|
29
|
-
|
|
30
|
-
await command.run({ id: '1' });
|
|
31
|
-
|
|
32
|
-
expect(mockClient.auth.revokeToken).toHaveBeenCalledWith(1);
|
|
33
|
-
expect(command.success).toHaveBeenCalledWith('Token 1 revoked.');
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
it('should handle revocation failure', async () => {
|
|
37
|
-
mockClient.auth.revokeToken.mockRejectedValue(new Error('Not found'));
|
|
38
|
-
|
|
39
|
-
await command.run({ id: '1' });
|
|
40
|
-
|
|
41
|
-
expect(command.error).toHaveBeenCalledWith('Failed to revoke token: Not found');
|
|
42
|
-
});
|
|
43
|
-
});
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
import { describe, it, expect, vi, beforeEach } from 'vitest';
|
|
3
|
-
import WhoamiCommand from '../../../src/commands/whoami.js';
|
|
4
|
-
import { getClient } from '../../../src/utils/nexical-client.js';
|
|
5
|
-
|
|
6
|
-
vi.mock('../../../src/utils/nexical-client.js');
|
|
7
|
-
|
|
8
|
-
describe('WhoamiCommand Integration', () => {
|
|
9
|
-
let command: WhoamiCommand;
|
|
10
|
-
let mockClient: any;
|
|
11
|
-
|
|
12
|
-
beforeEach(() => {
|
|
13
|
-
vi.resetAllMocks();
|
|
14
|
-
|
|
15
|
-
mockClient = {
|
|
16
|
-
users: {
|
|
17
|
-
me: vi.fn(),
|
|
18
|
-
},
|
|
19
|
-
};
|
|
20
|
-
vi.mocked(getClient).mockReturnValue(mockClient);
|
|
21
|
-
|
|
22
|
-
command = new WhoamiCommand([], {} as any);
|
|
23
|
-
vi.spyOn(command, 'info').mockImplementation(() => { });
|
|
24
|
-
vi.spyOn(command, 'error').mockImplementation(() => { });
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
it('should display user info when logged in', async () => {
|
|
28
|
-
mockClient.users.me.mockResolvedValue({
|
|
29
|
-
fullName: 'Integration User',
|
|
30
|
-
email: 'int@example.com',
|
|
31
|
-
id: 'user-int'
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
await command.run();
|
|
35
|
-
|
|
36
|
-
expect(command.info).toHaveBeenCalledWith('Logged in as:');
|
|
37
|
-
expect(command.info).toHaveBeenCalledWith(' Name: Integration User');
|
|
38
|
-
expect(command.info).toHaveBeenCalledWith(' Email: int@example.com');
|
|
39
|
-
expect(command.info).toHaveBeenCalledWith(' ID: user-int');
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
it('should display error when not logged in', async () => {
|
|
43
|
-
mockClient.users.me.mockRejectedValue(new Error('Unauthorized'));
|
|
44
|
-
|
|
45
|
-
await command.run();
|
|
46
|
-
|
|
47
|
-
expect(command.error).toHaveBeenCalledWith('Not logged in or token expired. Run `astrical login`.');
|
|
48
|
-
});
|
|
49
|
-
});
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
import { describe, it, expect, vi, beforeEach } from 'vitest';
|
|
3
|
-
import AdminUsersCreateSystemCommand from '../../../../src/commands/admin/create-user.js';
|
|
4
|
-
import { getClient } from '../../../../src/utils/nexical-client.js';
|
|
5
|
-
|
|
6
|
-
vi.mock('../../../../src/utils/nexical-client.js');
|
|
7
|
-
|
|
8
|
-
describe('AdminUsersCreateSystemCommand', () => {
|
|
9
|
-
let command: AdminUsersCreateSystemCommand;
|
|
10
|
-
let mockClient: any;
|
|
11
|
-
|
|
12
|
-
beforeEach(() => {
|
|
13
|
-
vi.resetAllMocks();
|
|
14
|
-
|
|
15
|
-
mockClient = {
|
|
16
|
-
auth: {
|
|
17
|
-
createSystemUser: vi.fn(),
|
|
18
|
-
},
|
|
19
|
-
};
|
|
20
|
-
vi.mocked(getClient).mockReturnValue(mockClient);
|
|
21
|
-
|
|
22
|
-
command = new AdminUsersCreateSystemCommand([], {} as any);
|
|
23
|
-
vi.spyOn(command, 'info').mockImplementation(() => { });
|
|
24
|
-
vi.spyOn(command, 'success').mockImplementation(() => { });
|
|
25
|
-
vi.spyOn(command, 'error').mockImplementation(() => { });
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
it('should create system user successfully', async () => {
|
|
29
|
-
mockClient.auth.createSystemUser.mockResolvedValue({
|
|
30
|
-
user: { fullName: 'System User', id: 'sys-123' }
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
await command.run({ name: 'System User', email: 'sys@example.com', password: 'password123' });
|
|
34
|
-
|
|
35
|
-
expect(mockClient.auth.createSystemUser).toHaveBeenCalledWith({
|
|
36
|
-
fullName: 'System User',
|
|
37
|
-
email: 'sys@example.com',
|
|
38
|
-
password: 'password123'
|
|
39
|
-
});
|
|
40
|
-
expect(command.success).toHaveBeenCalledWith('System user "System User" created!');
|
|
41
|
-
expect(command.info).toHaveBeenCalledWith('ID: sys-123');
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
it('should handle creation failure', async () => {
|
|
45
|
-
mockClient.auth.createSystemUser.mockRejectedValue(new Error('Email already exists'));
|
|
46
|
-
|
|
47
|
-
await command.run({ name: 'System User', email: 'sys@example.com', password: 'password123' });
|
|
48
|
-
|
|
49
|
-
expect(command.error).toHaveBeenCalledWith('Failed to create system user: Email already exists');
|
|
50
|
-
});
|
|
51
|
-
});
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
import { describe, it, expect, vi, beforeEach } from 'vitest';
|
|
3
|
-
import BranchesCreateCommand from '../../../../src/commands/branch/create.js';
|
|
4
|
-
import { getClient } from '../../../../src/utils/nexical-client.js';
|
|
5
|
-
|
|
6
|
-
vi.mock('../../../../src/utils/nexical-client.js');
|
|
7
|
-
|
|
8
|
-
describe('BranchesCreateCommand', () => {
|
|
9
|
-
let command: BranchesCreateCommand;
|
|
10
|
-
let mockClient: any;
|
|
11
|
-
|
|
12
|
-
beforeEach(() => {
|
|
13
|
-
vi.resetAllMocks();
|
|
14
|
-
|
|
15
|
-
mockClient = {
|
|
16
|
-
branches: {
|
|
17
|
-
create: vi.fn(),
|
|
18
|
-
},
|
|
19
|
-
};
|
|
20
|
-
vi.mocked(getClient).mockReturnValue(mockClient);
|
|
21
|
-
|
|
22
|
-
command = new BranchesCreateCommand([], {} as any);
|
|
23
|
-
vi.spyOn(command, 'info').mockImplementation(() => { });
|
|
24
|
-
vi.spyOn(command, 'success').mockImplementation(() => { });
|
|
25
|
-
vi.spyOn(command, 'error').mockImplementation(() => { });
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
it('should create branch successfully', async () => {
|
|
29
|
-
mockClient.branches.create.mockResolvedValue({
|
|
30
|
-
name: 'main',
|
|
31
|
-
id: '100'
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
await command.run({ teamId: '1', projectId: '2', name: 'main', preview: 'http://test.com' });
|
|
35
|
-
|
|
36
|
-
expect(mockClient.branches.create).toHaveBeenCalledWith(1, 2, {
|
|
37
|
-
name: 'main',
|
|
38
|
-
previewUrl: 'http://test.com',
|
|
39
|
-
});
|
|
40
|
-
expect(command.success).toHaveBeenCalledWith('Branch "main" created!');
|
|
41
|
-
expect(command.info).toHaveBeenCalledWith('ID: 100');
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
it('should validate IDs', async () => {
|
|
45
|
-
await command.run({ teamId: 'invalid', projectId: '2', name: 'main' });
|
|
46
|
-
expect(command.error).toHaveBeenCalledWith('IDs must be numbers.');
|
|
47
|
-
expect(mockClient.branches.create).not.toHaveBeenCalled();
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
it('should handle creation failure', async () => {
|
|
51
|
-
mockClient.branches.create.mockRejectedValue(new Error('Branch exists'));
|
|
52
|
-
|
|
53
|
-
await command.run({ teamId: '1', projectId: '2', name: 'main' });
|
|
54
|
-
|
|
55
|
-
expect(command.error).toHaveBeenCalledWith('Failed to create branch: Branch exists');
|
|
56
|
-
});
|
|
57
|
-
});
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
import { describe, it, expect, vi, beforeEach } from 'vitest';
|
|
3
|
-
import BranchesDeleteCommand from '../../../../src/commands/branch/delete.js';
|
|
4
|
-
import { getClient } from '../../../../src/utils/nexical-client.js';
|
|
5
|
-
|
|
6
|
-
vi.mock('../../../../src/utils/nexical-client.js');
|
|
7
|
-
|
|
8
|
-
describe('BranchesDeleteCommand', () => {
|
|
9
|
-
let command: BranchesDeleteCommand;
|
|
10
|
-
let mockClient: any;
|
|
11
|
-
|
|
12
|
-
beforeEach(() => {
|
|
13
|
-
vi.resetAllMocks();
|
|
14
|
-
|
|
15
|
-
mockClient = {
|
|
16
|
-
branches: {
|
|
17
|
-
delete: vi.fn(),
|
|
18
|
-
},
|
|
19
|
-
};
|
|
20
|
-
vi.mocked(getClient).mockReturnValue(mockClient);
|
|
21
|
-
|
|
22
|
-
command = new BranchesDeleteCommand([], {} as any);
|
|
23
|
-
vi.spyOn(command, 'success').mockImplementation(() => { });
|
|
24
|
-
vi.spyOn(command, 'error').mockImplementation(() => { });
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
it('should delete branch successfully', async () => {
|
|
28
|
-
mockClient.branches.delete.mockResolvedValue({});
|
|
29
|
-
|
|
30
|
-
await command.run({ teamId: '1', projectId: '2', branchId: '3' });
|
|
31
|
-
|
|
32
|
-
expect(mockClient.branches.delete).toHaveBeenCalledWith(1, 2, 3);
|
|
33
|
-
expect(command.success).toHaveBeenCalledWith('Branch 3 deleted.');
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
it('should validate IDs', async () => {
|
|
37
|
-
await command.run({ teamId: '1', projectId: 'invalid', branchId: '3' });
|
|
38
|
-
expect(command.error).toHaveBeenCalledWith('IDs must be numbers.');
|
|
39
|
-
expect(mockClient.branches.delete).not.toHaveBeenCalled();
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
it('should handle deletion failure', async () => {
|
|
43
|
-
mockClient.branches.delete.mockRejectedValue(new Error('Not found'));
|
|
44
|
-
|
|
45
|
-
await command.run({ teamId: '1', projectId: '2', branchId: '3' });
|
|
46
|
-
|
|
47
|
-
expect(command.error).toHaveBeenCalledWith('Failed to delete branch: Not found');
|
|
48
|
-
});
|
|
49
|
-
});
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
import { describe, it, expect, vi, beforeEach } from 'vitest';
|
|
3
|
-
import BranchesGetCommand from '../../../../src/commands/branch/get.js';
|
|
4
|
-
import { getClient } from '../../../../src/utils/nexical-client.js';
|
|
5
|
-
|
|
6
|
-
vi.mock('../../../../src/utils/nexical-client.js');
|
|
7
|
-
|
|
8
|
-
describe('BranchesGetCommand', () => {
|
|
9
|
-
let command: BranchesGetCommand;
|
|
10
|
-
let mockClient: any;
|
|
11
|
-
|
|
12
|
-
beforeEach(() => {
|
|
13
|
-
vi.resetAllMocks();
|
|
14
|
-
|
|
15
|
-
mockClient = {
|
|
16
|
-
branches: {
|
|
17
|
-
get: vi.fn(),
|
|
18
|
-
},
|
|
19
|
-
};
|
|
20
|
-
vi.mocked(getClient).mockReturnValue(mockClient);
|
|
21
|
-
|
|
22
|
-
command = new BranchesGetCommand([], {} as any);
|
|
23
|
-
vi.spyOn(command, 'info').mockImplementation(() => { });
|
|
24
|
-
vi.spyOn(command, 'error').mockImplementation(() => { });
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
it('should get branch details successfully', async () => {
|
|
28
|
-
mockClient.branches.get.mockResolvedValue({
|
|
29
|
-
id: '100',
|
|
30
|
-
name: 'main',
|
|
31
|
-
previewUrl: 'http://test.com'
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
await command.run({ teamId: '1', projectId: '2', branchId: '3' });
|
|
35
|
-
|
|
36
|
-
expect(mockClient.branches.get).toHaveBeenCalledWith(1, 2, 3);
|
|
37
|
-
expect(command.info).toHaveBeenCalledWith('Branch Details:');
|
|
38
|
-
expect(command.info).toHaveBeenCalledWith(' ID: 100');
|
|
39
|
-
expect(command.info).toHaveBeenCalledWith(' Name: main');
|
|
40
|
-
expect(command.info).toHaveBeenCalledWith(' Preview: http://test.com');
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
it('should show N/A for missing preview', async () => {
|
|
44
|
-
mockClient.branches.get.mockResolvedValue({
|
|
45
|
-
id: '100',
|
|
46
|
-
name: 'main'
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
await command.run({ teamId: '1', projectId: '2', branchId: '3' });
|
|
50
|
-
|
|
51
|
-
expect(command.info).toHaveBeenCalledWith(' Preview: N/A');
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
it('should validate IDs', async () => {
|
|
55
|
-
await command.run({ teamId: '1', projectId: 'invalid', branchId: '3' });
|
|
56
|
-
expect(command.error).toHaveBeenCalledWith('IDs must be numbers.');
|
|
57
|
-
expect(mockClient.branches.get).not.toHaveBeenCalled();
|
|
58
|
-
});
|
|
59
|
-
|
|
60
|
-
it('should handle get failure', async () => {
|
|
61
|
-
mockClient.branches.get.mockRejectedValue(new Error('Not found'));
|
|
62
|
-
|
|
63
|
-
await command.run({ teamId: '1', projectId: '2', branchId: '3' });
|
|
64
|
-
|
|
65
|
-
expect(command.error).toHaveBeenCalledWith('Failed to get branch: Not found');
|
|
66
|
-
});
|
|
67
|
-
});
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
import { describe, it, expect, vi, beforeEach } from 'vitest';
|
|
3
|
-
import BranchesListCommand from '../../../../src/commands/branch/list.js';
|
|
4
|
-
import { getClient } from '../../../../src/utils/nexical-client.js';
|
|
5
|
-
|
|
6
|
-
vi.mock('../../../../src/utils/nexical-client.js');
|
|
7
|
-
|
|
8
|
-
describe('BranchesListCommand', () => {
|
|
9
|
-
let command: BranchesListCommand;
|
|
10
|
-
let mockClient: any;
|
|
11
|
-
|
|
12
|
-
beforeEach(() => {
|
|
13
|
-
vi.resetAllMocks();
|
|
14
|
-
|
|
15
|
-
mockClient = {
|
|
16
|
-
branches: {
|
|
17
|
-
list: vi.fn(),
|
|
18
|
-
},
|
|
19
|
-
};
|
|
20
|
-
vi.mocked(getClient).mockReturnValue(mockClient);
|
|
21
|
-
|
|
22
|
-
command = new BranchesListCommand([], {} as any);
|
|
23
|
-
vi.spyOn(command, 'info').mockImplementation(() => { });
|
|
24
|
-
vi.spyOn(command, 'error').mockImplementation(() => { });
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
it('should list branches successfully', async () => {
|
|
28
|
-
mockClient.branches.list.mockResolvedValue([
|
|
29
|
-
{ id: '100', name: 'main' },
|
|
30
|
-
{ id: '101', name: 'dev' }
|
|
31
|
-
]);
|
|
32
|
-
|
|
33
|
-
await command.run({ teamId: '1', projectId: '2' });
|
|
34
|
-
|
|
35
|
-
expect(mockClient.branches.list).toHaveBeenCalledWith(1, 2);
|
|
36
|
-
expect(command.info).toHaveBeenCalledWith('Branches for Project 2:');
|
|
37
|
-
expect(command.info).toHaveBeenCalledWith('- main (ID: 100)');
|
|
38
|
-
expect(command.info).toHaveBeenCalledWith('- dev (ID: 101)');
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
it('should handle empty list', async () => {
|
|
42
|
-
mockClient.branches.list.mockResolvedValue([]);
|
|
43
|
-
|
|
44
|
-
await command.run({ teamId: '1', projectId: '2' });
|
|
45
|
-
|
|
46
|
-
expect(command.info).toHaveBeenCalledWith('No branches found.');
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
it('should validate IDs', async () => {
|
|
50
|
-
await command.run({ teamId: 'invalid', projectId: '2' });
|
|
51
|
-
expect(command.error).toHaveBeenCalledWith('IDs must be numbers.');
|
|
52
|
-
expect(mockClient.branches.list).not.toHaveBeenCalled();
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
it('should handle list failure', async () => {
|
|
56
|
-
mockClient.branches.list.mockRejectedValue(new Error('Network error'));
|
|
57
|
-
|
|
58
|
-
await command.run({ teamId: '1', projectId: '2' });
|
|
59
|
-
|
|
60
|
-
expect(command.error).toHaveBeenCalledWith('Failed to list branches: Network error');
|
|
61
|
-
});
|
|
62
|
-
});
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
import { describe, it, expect, vi, beforeEach } from 'vitest';
|
|
3
|
-
import JobsGetCommand from '../../../../src/commands/job/get.js';
|
|
4
|
-
import { getClient } from '../../../../src/utils/nexical-client.js';
|
|
5
|
-
|
|
6
|
-
vi.mock('../../../../src/utils/nexical-client.js');
|
|
7
|
-
|
|
8
|
-
describe('JobsGetCommand', () => {
|
|
9
|
-
let command: JobsGetCommand;
|
|
10
|
-
let mockClient: any;
|
|
11
|
-
|
|
12
|
-
beforeEach(() => {
|
|
13
|
-
vi.resetAllMocks();
|
|
14
|
-
|
|
15
|
-
mockClient = {
|
|
16
|
-
jobs: {
|
|
17
|
-
get: vi.fn(),
|
|
18
|
-
},
|
|
19
|
-
};
|
|
20
|
-
vi.mocked(getClient).mockReturnValue(mockClient);
|
|
21
|
-
|
|
22
|
-
command = new JobsGetCommand([], {} as any);
|
|
23
|
-
vi.spyOn(command, 'info').mockImplementation(() => { });
|
|
24
|
-
vi.spyOn(command, 'error').mockImplementation(() => { });
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
it('should get job details successfully', async () => {
|
|
28
|
-
mockClient.jobs.get.mockResolvedValue({
|
|
29
|
-
id: '100',
|
|
30
|
-
type: 'preview',
|
|
31
|
-
status: 'completed',
|
|
32
|
-
startedAt: '2023-01-01',
|
|
33
|
-
completedAt: '2023-01-02',
|
|
34
|
-
queue: 'default'
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
await command.run({ teamId: '1', projectId: '2', branchId: '3', jobId: '4' });
|
|
38
|
-
|
|
39
|
-
expect(mockClient.jobs.get).toHaveBeenCalledWith(1, 2, 3, 4);
|
|
40
|
-
expect(command.info).toHaveBeenCalledWith('Job Details:');
|
|
41
|
-
expect(command.info).toHaveBeenCalledWith(' ID: 100');
|
|
42
|
-
expect(command.info).toHaveBeenCalledWith(' Type: preview');
|
|
43
|
-
expect(command.info).toHaveBeenCalledWith(' Status: completed');
|
|
44
|
-
expect(command.info).toHaveBeenCalledWith(' Started: 2023-01-01');
|
|
45
|
-
expect(command.info).toHaveBeenCalledWith(' Ended: 2023-01-02');
|
|
46
|
-
expect(command.info).toHaveBeenCalledWith(' Queue: default');
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
it('should display defaults for missing times', async () => {
|
|
50
|
-
mockClient.jobs.get.mockResolvedValue({
|
|
51
|
-
id: '100',
|
|
52
|
-
type: 'preview',
|
|
53
|
-
status: 'pending',
|
|
54
|
-
queue: 'default'
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
await command.run({ teamId: '1', projectId: '2', branchId: '3', jobId: '4' });
|
|
58
|
-
|
|
59
|
-
expect(command.info).toHaveBeenCalledWith(' Started: Waiting');
|
|
60
|
-
expect(command.info).toHaveBeenCalledWith(' Ended: Running');
|
|
61
|
-
});
|
|
62
|
-
|
|
63
|
-
it('should validate IDs', async () => {
|
|
64
|
-
await command.run({ teamId: '1', projectId: '2', branchId: '3', jobId: 'invalid' });
|
|
65
|
-
expect(command.error).toHaveBeenCalledWith('IDs must be numbers.');
|
|
66
|
-
expect(mockClient.jobs.get).not.toHaveBeenCalled();
|
|
67
|
-
});
|
|
68
|
-
|
|
69
|
-
it('should handle get failure', async () => {
|
|
70
|
-
mockClient.jobs.get.mockRejectedValue(new Error('Job not found'));
|
|
71
|
-
|
|
72
|
-
await command.run({ teamId: '1', projectId: '2', branchId: '3', jobId: '4' });
|
|
73
|
-
|
|
74
|
-
expect(command.error).toHaveBeenCalledWith('Failed to get job: Job not found');
|
|
75
|
-
});
|
|
76
|
-
});
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
import { describe, it, expect, vi, beforeEach } from 'vitest';
|
|
3
|
-
import JobsListCommand from '../../../../src/commands/job/list.js';
|
|
4
|
-
import { getClient } from '../../../../src/utils/nexical-client.js';
|
|
5
|
-
|
|
6
|
-
vi.mock('../../../../src/utils/nexical-client.js');
|
|
7
|
-
|
|
8
|
-
describe('JobsListCommand', () => {
|
|
9
|
-
let command: JobsListCommand;
|
|
10
|
-
let mockClient: any;
|
|
11
|
-
|
|
12
|
-
beforeEach(() => {
|
|
13
|
-
vi.resetAllMocks();
|
|
14
|
-
|
|
15
|
-
mockClient = {
|
|
16
|
-
jobs: {
|
|
17
|
-
list: vi.fn(),
|
|
18
|
-
},
|
|
19
|
-
};
|
|
20
|
-
vi.mocked(getClient).mockReturnValue(mockClient);
|
|
21
|
-
|
|
22
|
-
command = new JobsListCommand([], {} as any);
|
|
23
|
-
vi.spyOn(command, 'info').mockImplementation(() => { });
|
|
24
|
-
vi.spyOn(command, 'error').mockImplementation(() => { });
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
it('should list jobs successfully', async () => {
|
|
28
|
-
mockClient.jobs.list.mockResolvedValue([
|
|
29
|
-
{ id: '100', type: 'preview', status: 'completed', startedAt: '2023-01-01' },
|
|
30
|
-
{ id: '101', type: 'deploy', status: 'running' }
|
|
31
|
-
]);
|
|
32
|
-
|
|
33
|
-
await command.run({ teamId: '1', projectId: '2', branchId: '3' });
|
|
34
|
-
|
|
35
|
-
expect(mockClient.jobs.list).toHaveBeenCalledWith(1, 2, 3);
|
|
36
|
-
expect(command.info).toHaveBeenCalledWith('Jobs for Branch 3:');
|
|
37
|
-
expect(command.info).toHaveBeenCalledWith('100 - preview [completed] (Started: 2023-01-01)');
|
|
38
|
-
expect(command.info).toHaveBeenCalledWith('101 - deploy [running] (Started: Waiting)');
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
it('should handle empty list', async () => {
|
|
42
|
-
mockClient.jobs.list.mockResolvedValue([]);
|
|
43
|
-
|
|
44
|
-
await command.run({ teamId: '1', projectId: '2', branchId: '3' });
|
|
45
|
-
|
|
46
|
-
expect(command.info).toHaveBeenCalledWith('No jobs found.');
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
it('should validate IDs', async () => {
|
|
50
|
-
await command.run({ teamId: '1', projectId: '2', branchId: 'invalid' });
|
|
51
|
-
expect(command.error).toHaveBeenCalledWith('IDs must be numbers.');
|
|
52
|
-
expect(mockClient.jobs.list).not.toHaveBeenCalled();
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
it('should handle list failure', async () => {
|
|
56
|
-
mockClient.jobs.list.mockRejectedValue(new Error('Network error'));
|
|
57
|
-
|
|
58
|
-
await command.run({ teamId: '1', projectId: '2', branchId: '3' });
|
|
59
|
-
|
|
60
|
-
expect(command.error).toHaveBeenCalledWith('Failed to list jobs: Network error');
|
|
61
|
-
});
|
|
62
|
-
});
|