@newpeak/barista-cli 0.1.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.
Files changed (82) hide show
  1. package/.eslintrc.json +23 -0
  2. package/.prettierrc +9 -0
  3. package/.sisyphus/notepads/liberica-employees/learnings.md +73 -0
  4. package/AGENTS.md +270 -0
  5. package/CONTRIBUTING.md +291 -0
  6. package/README.md +707 -0
  7. package/bin/barista +6 -0
  8. package/bin/barista.js +3 -0
  9. package/docs/ARCHITECTURE.md +184 -0
  10. package/docs/COMMANDS.md +352 -0
  11. package/docs/COMMAND_DESIGN_SPEC.md +811 -0
  12. package/docs/INTEGRATION_NOTES.md +270 -0
  13. package/docs/commands/REFERENCE.md +297 -0
  14. package/docs/commands/arabica/auth/index.md +296 -0
  15. package/docs/commands/liberica/auth/index.md +133 -0
  16. package/docs/commands/liberica/context/index.md +60 -0
  17. package/docs/commands/liberica/employees/create.md +185 -0
  18. package/docs/commands/liberica/employees/disable.md +138 -0
  19. package/docs/commands/liberica/employees/enable.md +137 -0
  20. package/docs/commands/liberica/employees/get.md +153 -0
  21. package/docs/commands/liberica/employees/list.md +168 -0
  22. package/docs/commands/liberica/employees/update.md +180 -0
  23. package/docs/commands/liberica/orgs/list.md +62 -0
  24. package/docs/commands/liberica/positions/list.md +61 -0
  25. package/docs/commands/liberica/roles/list.md +67 -0
  26. package/docs/commands/liberica/users/create.md +170 -0
  27. package/docs/commands/liberica/users/get.md +151 -0
  28. package/docs/commands/liberica/users/list.md +175 -0
  29. package/package.json +37 -0
  30. package/src/commands/arabica/auth/index.ts +277 -0
  31. package/src/commands/arabica/auth/login.ts +5 -0
  32. package/src/commands/arabica/auth/logout.ts +5 -0
  33. package/src/commands/arabica/auth/register.ts +5 -0
  34. package/src/commands/arabica/auth/status.ts +5 -0
  35. package/src/commands/arabica/index.ts +23 -0
  36. package/src/commands/auth.ts +107 -0
  37. package/src/commands/context.ts +60 -0
  38. package/src/commands/liberica/auth/index.ts +170 -0
  39. package/src/commands/liberica/context/index.ts +43 -0
  40. package/src/commands/liberica/employees/create.ts +275 -0
  41. package/src/commands/liberica/employees/delete.ts +122 -0
  42. package/src/commands/liberica/employees/disable.ts +97 -0
  43. package/src/commands/liberica/employees/enable.ts +97 -0
  44. package/src/commands/liberica/employees/get.ts +115 -0
  45. package/src/commands/liberica/employees/index.ts +23 -0
  46. package/src/commands/liberica/employees/list.ts +131 -0
  47. package/src/commands/liberica/employees/update.ts +157 -0
  48. package/src/commands/liberica/index.ts +36 -0
  49. package/src/commands/liberica/orgs/index.ts +35 -0
  50. package/src/commands/liberica/positions/index.ts +30 -0
  51. package/src/commands/liberica/roles/index.ts +59 -0
  52. package/src/commands/liberica/users/create.ts +132 -0
  53. package/src/commands/liberica/users/delete.ts +49 -0
  54. package/src/commands/liberica/users/disable.ts +41 -0
  55. package/src/commands/liberica/users/enable.ts +30 -0
  56. package/src/commands/liberica/users/get.ts +46 -0
  57. package/src/commands/liberica/users/index.ts +27 -0
  58. package/src/commands/liberica/users/list.ts +68 -0
  59. package/src/commands/liberica/users/me.ts +42 -0
  60. package/src/commands/liberica/users/reset-password.ts +42 -0
  61. package/src/commands/liberica/users/update.ts +48 -0
  62. package/src/core/api/client.ts +825 -0
  63. package/src/core/auth/token-manager.ts +183 -0
  64. package/src/core/config/manager.ts +164 -0
  65. package/src/index.ts +37 -0
  66. package/src/types/employee.ts +102 -0
  67. package/src/types/index.ts +75 -0
  68. package/src/types/org.ts +25 -0
  69. package/src/types/position.ts +24 -0
  70. package/src/types/user.ts +64 -0
  71. package/tests/unit/commands/arabica/auth.test.ts +230 -0
  72. package/tests/unit/commands/liberica/auth.test.ts +175 -0
  73. package/tests/unit/commands/liberica/context.test.ts +98 -0
  74. package/tests/unit/commands/liberica/employees/create.test.ts +463 -0
  75. package/tests/unit/commands/liberica/employees/disable.test.ts +82 -0
  76. package/tests/unit/commands/liberica/employees/enable.test.ts +82 -0
  77. package/tests/unit/commands/liberica/employees/get.test.ts +111 -0
  78. package/tests/unit/commands/liberica/employees/list.test.ts +294 -0
  79. package/tests/unit/commands/liberica/employees/update.test.ts +210 -0
  80. package/tests/unit/config.test.ts +141 -0
  81. package/tests/unit/types.test.ts +195 -0
  82. package/tsconfig.json +20 -0
@@ -0,0 +1,230 @@
1
+ import { describe, it, expect, beforeEach, vi } from 'vitest';
2
+
3
+ vi.mock('chalk', () => ({
4
+ default: {
5
+ bold: vi.fn((text) => text),
6
+ green: vi.fn((text) => text),
7
+ red: vi.fn((text) => text),
8
+ gray: vi.fn((text) => text),
9
+ },
10
+ }));
11
+
12
+ vi.mock('inquirer', () => ({
13
+ default: {
14
+ prompt: vi.fn(),
15
+ },
16
+ }));
17
+
18
+ vi.mock('../../../../src/core/config/manager.js', () => ({
19
+ configManager: {
20
+ getCurrentContext: vi.fn(() => ({
21
+ environment: 'dev' as const,
22
+ service: 'arabica' as const,
23
+ })),
24
+ },
25
+ }));
26
+
27
+ vi.mock('../../../../src/core/auth/token-manager.js', () => ({
28
+ tokenManager: {
29
+ getToken: vi.fn(),
30
+ setToken: vi.fn(),
31
+ deleteToken: vi.fn(),
32
+ findAllTokens: vi.fn(() => []),
33
+ },
34
+ }));
35
+
36
+ vi.mock('../../../../src/core/api/client.js', () => ({
37
+ apiClient: {
38
+ loginArabica: vi.fn(),
39
+ registerArabica: vi.fn(),
40
+ },
41
+ }));
42
+
43
+ import { createArabicaAuthCommand } from '../../../../src/commands/arabica/auth/index.js';
44
+
45
+ describe('createArabicaAuthCommand', () => {
46
+ beforeEach(() => {
47
+ vi.clearAllMocks();
48
+ });
49
+
50
+ it('should create command with name "auth"', () => {
51
+ const command = createArabicaAuthCommand();
52
+ expect(command.name()).toBe('auth');
53
+ });
54
+
55
+ it('should have description "Manage Arabica authentication"', () => {
56
+ const command = createArabicaAuthCommand();
57
+ expect(command.description()).toBe('Manage Arabica authentication');
58
+ });
59
+
60
+ describe('login subcommand', () => {
61
+ it('should exist', () => {
62
+ const command = createArabicaAuthCommand();
63
+ const loginCmd = command.commands.find((cmd) => cmd.name() === 'login');
64
+ expect(loginCmd).toBeDefined();
65
+ });
66
+
67
+ it('should have correct description', () => {
68
+ const command = createArabicaAuthCommand();
69
+ const loginCmd = command.commands.find((cmd) => cmd.name() === 'login');
70
+ expect(loginCmd?.description()).toBe('Login to Arabica');
71
+ });
72
+
73
+ it('should have --env option', () => {
74
+ const command = createArabicaAuthCommand();
75
+ const loginCmd = command.commands.find((cmd) => cmd.name() === 'login');
76
+ const envOption = loginCmd?.options.find((opt) => opt.short === '-e' || opt.long === '--env');
77
+ expect(envOption).toBeDefined();
78
+ });
79
+
80
+ it('should have --account option', () => {
81
+ const command = createArabicaAuthCommand();
82
+ const loginCmd = command.commands.find((cmd) => cmd.name() === 'login');
83
+ const accountOption = loginCmd?.options.find((opt) => opt.long === '--account');
84
+ expect(accountOption).toBeDefined();
85
+ });
86
+
87
+ it('should have --password option', () => {
88
+ const command = createArabicaAuthCommand();
89
+ const loginCmd = command.commands.find((cmd) => cmd.name() === 'login');
90
+ const passwordOption = loginCmd?.options.find((opt) => opt.long === '--password');
91
+ expect(passwordOption).toBeDefined();
92
+ });
93
+
94
+ it('should have --remember option', () => {
95
+ const command = createArabicaAuthCommand();
96
+ const loginCmd = command.commands.find((cmd) => cmd.name() === 'login');
97
+ const rememberOption = loginCmd?.options.find((opt) => opt.long === '--remember');
98
+ expect(rememberOption).toBeDefined();
99
+ });
100
+
101
+ it('should NOT have --tenant option', () => {
102
+ const command = createArabicaAuthCommand();
103
+ const loginCmd = command.commands.find((cmd) => cmd.name() === 'login');
104
+ const tenantOption = loginCmd?.options.find((opt) => opt.long === '--tenant');
105
+ expect(tenantOption).toBeUndefined();
106
+ });
107
+ });
108
+
109
+ describe('register subcommand', () => {
110
+ it('should exist', () => {
111
+ const command = createArabicaAuthCommand();
112
+ const registerCmd = command.commands.find((cmd) => cmd.name() === 'register');
113
+ expect(registerCmd).toBeDefined();
114
+ });
115
+
116
+ it('should have correct description', () => {
117
+ const command = createArabicaAuthCommand();
118
+ const registerCmd = command.commands.find((cmd) => cmd.name() === 'register');
119
+ expect(registerCmd?.description()).toBe('Register new Arabica account');
120
+ });
121
+
122
+ it('should have --env option', () => {
123
+ const command = createArabicaAuthCommand();
124
+ const registerCmd = command.commands.find((cmd) => cmd.name() === 'register');
125
+ const envOption = registerCmd?.options.find((opt) => opt.long === '--env');
126
+ expect(envOption).toBeDefined();
127
+ });
128
+
129
+ it('should have --email option', () => {
130
+ const command = createArabicaAuthCommand();
131
+ const registerCmd = command.commands.find((cmd) => cmd.name() === 'register');
132
+ const emailOption = registerCmd?.options.find((opt) => opt.long === '--email');
133
+ expect(emailOption).toBeDefined();
134
+ });
135
+
136
+ it('should have --password option', () => {
137
+ const command = createArabicaAuthCommand();
138
+ const registerCmd = command.commands.find((cmd) => cmd.name() === 'register');
139
+ const passwordOption = registerCmd?.options.find((opt) => opt.long === '--password');
140
+ expect(passwordOption).toBeDefined();
141
+ });
142
+
143
+ it('should have --phone option', () => {
144
+ const command = createArabicaAuthCommand();
145
+ const registerCmd = command.commands.find((cmd) => cmd.name() === 'register');
146
+ const phoneOption = registerCmd?.options.find((opt) => opt.long === '--phone');
147
+ expect(phoneOption).toBeDefined();
148
+ });
149
+ });
150
+
151
+ describe('status subcommand', () => {
152
+ it('should exist', () => {
153
+ const command = createArabicaAuthCommand();
154
+ const statusCmd = command.commands.find((cmd) => cmd.name() === 'status');
155
+ expect(statusCmd).toBeDefined();
156
+ });
157
+
158
+ it('should have correct description', () => {
159
+ const command = createArabicaAuthCommand();
160
+ const statusCmd = command.commands.find((cmd) => cmd.name() === 'status');
161
+ expect(statusCmd?.description()).toBe('Check Arabica authentication status');
162
+ });
163
+
164
+ it('should have no options', () => {
165
+ const command = createArabicaAuthCommand();
166
+ const statusCmd = command.commands.find((cmd) => cmd.name() === 'status');
167
+ expect(statusCmd?.options).toHaveLength(0);
168
+ });
169
+ });
170
+
171
+ describe('logout subcommand', () => {
172
+ it('should exist', () => {
173
+ const command = createArabicaAuthCommand();
174
+ const logoutCmd = command.commands.find((cmd) => cmd.name() === 'logout');
175
+ expect(logoutCmd).toBeDefined();
176
+ });
177
+
178
+ it('should have correct description', () => {
179
+ const command = createArabicaAuthCommand();
180
+ const logoutCmd = command.commands.find((cmd) => cmd.name() === 'logout');
181
+ expect(logoutCmd?.description()).toBe('Logout from Arabica and clear token');
182
+ });
183
+
184
+ it('should have --env option', () => {
185
+ const command = createArabicaAuthCommand();
186
+ const logoutCmd = command.commands.find((cmd) => cmd.name() === 'logout');
187
+ const envOption = logoutCmd?.options.find((opt) => opt.long === '--env');
188
+ expect(envOption).toBeDefined();
189
+ });
190
+
191
+ it('should have --all option', () => {
192
+ const command = createArabicaAuthCommand();
193
+ const logoutCmd = command.commands.find((cmd) => cmd.name() === 'logout');
194
+ const allOption = logoutCmd?.options.find((opt) => opt.long === '--all');
195
+ expect(allOption).toBeDefined();
196
+ });
197
+ });
198
+ });
199
+
200
+ describe('auth command integration', () => {
201
+ it('should call apiClient.loginArabica with correct parameters on login', async () => {
202
+ const { apiClient } = await import('../../../../src/core/api/client.js');
203
+ expect(apiClient.loginArabica).toBeDefined();
204
+ });
205
+
206
+ it('should call apiClient.registerArabica with correct parameters on register', async () => {
207
+ const { apiClient } = await import('../../../../src/core/api/client.js');
208
+ expect(apiClient.registerArabica).toBeDefined();
209
+ });
210
+
211
+ it('should call tokenManager.setToken after successful login', async () => {
212
+ const { tokenManager } = await import('../../../../src/core/auth/token-manager.js');
213
+ expect(tokenManager.setToken).toBeDefined();
214
+ });
215
+
216
+ it('should call tokenManager.getToken for status check', async () => {
217
+ const { tokenManager } = await import('../../../../src/core/auth/token-manager.js');
218
+ expect(tokenManager.getToken).toBeDefined();
219
+ });
220
+
221
+ it('should call tokenManager.deleteToken on logout', async () => {
222
+ const { tokenManager } = await import('../../../../src/core/auth/token-manager.js');
223
+ expect(tokenManager.deleteToken).toBeDefined();
224
+ });
225
+
226
+ it('should call tokenManager.findAllTokens on logout --all', async () => {
227
+ const { tokenManager } = await import('../../../../src/core/auth/token-manager.js');
228
+ expect(tokenManager.findAllTokens).toBeDefined();
229
+ });
230
+ });
@@ -0,0 +1,175 @@
1
+ import { describe, it, expect, beforeEach, vi } from 'vitest';
2
+
3
+ vi.mock('chalk', () => ({
4
+ default: {
5
+ bold: vi.fn((text) => text),
6
+ green: vi.fn((text) => text),
7
+ red: vi.fn((text) => text),
8
+ gray: vi.fn((text) => text),
9
+ },
10
+ }));
11
+
12
+ vi.mock('inquirer', () => ({
13
+ default: {
14
+ prompt: vi.fn(),
15
+ },
16
+ }));
17
+
18
+ vi.mock('../../../../src/core/config/manager.js', () => ({
19
+ configManager: {
20
+ getCurrentContext: vi.fn(() => ({
21
+ environment: 'dev' as const,
22
+ service: 'liberica' as const,
23
+ tenant: 'test-tenant',
24
+ })),
25
+ setTenant: vi.fn(),
26
+ },
27
+ }));
28
+
29
+ vi.mock('../../../../src/core/auth/token-manager.js', () => ({
30
+ tokenManager: {
31
+ getToken: vi.fn(),
32
+ setToken: vi.fn(),
33
+ deleteToken: vi.fn(),
34
+ findAllTokens: vi.fn(() => []),
35
+ },
36
+ }));
37
+
38
+ vi.mock('../../../../src/core/api/client.js', () => ({
39
+ apiClient: {
40
+ login: vi.fn(),
41
+ },
42
+ }));
43
+
44
+ import { createLibericaAuthCommand } from '../../../../src/commands/liberica/auth/index.js';
45
+
46
+ describe('createLibericaAuthCommand', () => {
47
+ beforeEach(() => {
48
+ vi.clearAllMocks();
49
+ });
50
+
51
+ it('should create command with name "auth"', () => {
52
+ const command = createLibericaAuthCommand();
53
+ expect(command.name()).toBe('auth');
54
+ });
55
+
56
+ it('should have description "Manage Liberica authentication"', () => {
57
+ const command = createLibericaAuthCommand();
58
+ expect(command.description()).toBe('Manage Liberica authentication');
59
+ });
60
+
61
+ describe('login subcommand', () => {
62
+ it('should exist', () => {
63
+ const command = createLibericaAuthCommand();
64
+ const loginCmd = command.commands.find((cmd) => cmd.name() === 'login');
65
+ expect(loginCmd).toBeDefined();
66
+ });
67
+
68
+ it('should have correct description', () => {
69
+ const command = createLibericaAuthCommand();
70
+ const loginCmd = command.commands.find((cmd) => cmd.name() === 'login');
71
+ expect(loginCmd?.description()).toBe('Login to Liberica');
72
+ });
73
+
74
+ it('should have --env option', () => {
75
+ const command = createLibericaAuthCommand();
76
+ const loginCmd = command.commands.find((cmd) => cmd.name() === 'login');
77
+ const envOption = loginCmd?.options.find((opt) => opt.short === '-e' || opt.long === '--env');
78
+ expect(envOption).toBeDefined();
79
+ });
80
+
81
+ it('should have --tenant option', () => {
82
+ const command = createLibericaAuthCommand();
83
+ const loginCmd = command.commands.find((cmd) => cmd.name() === 'login');
84
+ const tenantOption = loginCmd?.options.find((opt) => opt.long === '--tenant');
85
+ expect(tenantOption).toBeDefined();
86
+ });
87
+
88
+ it('should have --username option', () => {
89
+ const command = createLibericaAuthCommand();
90
+ const loginCmd = command.commands.find((cmd) => cmd.name() === 'login');
91
+ const usernameOption = loginCmd?.options.find((opt) => opt.long === '--username');
92
+ expect(usernameOption).toBeDefined();
93
+ });
94
+
95
+ it('should have --password option', () => {
96
+ const command = createLibericaAuthCommand();
97
+ const loginCmd = command.commands.find((cmd) => cmd.name() === 'login');
98
+ const passwordOption = loginCmd?.options.find((opt) => opt.long === '--password');
99
+ expect(passwordOption).toBeDefined();
100
+ });
101
+ });
102
+
103
+ describe('status subcommand', () => {
104
+ it('should exist', () => {
105
+ const command = createLibericaAuthCommand();
106
+ const statusCmd = command.commands.find((cmd) => cmd.name() === 'status');
107
+ expect(statusCmd).toBeDefined();
108
+ });
109
+
110
+ it('should have correct description', () => {
111
+ const command = createLibericaAuthCommand();
112
+ const statusCmd = command.commands.find((cmd) => cmd.name() === 'status');
113
+ expect(statusCmd?.description()).toBe('Check Liberica authentication status');
114
+ });
115
+ });
116
+
117
+ describe('logout subcommand', () => {
118
+ it('should exist', () => {
119
+ const command = createLibericaAuthCommand();
120
+ const logoutCmd = command.commands.find((cmd) => cmd.name() === 'logout');
121
+ expect(logoutCmd).toBeDefined();
122
+ });
123
+
124
+ it('should have correct description', () => {
125
+ const command = createLibericaAuthCommand();
126
+ const logoutCmd = command.commands.find((cmd) => cmd.name() === 'logout');
127
+ expect(logoutCmd?.description()).toBe('Logout from Liberica and clear token');
128
+ });
129
+
130
+ it('should have --env option', () => {
131
+ const command = createLibericaAuthCommand();
132
+ const logoutCmd = command.commands.find((cmd) => cmd.name() === 'logout');
133
+ const envOption = logoutCmd?.options.find((opt) => opt.long === '--env');
134
+ expect(envOption).toBeDefined();
135
+ });
136
+
137
+ it('should have --all option', () => {
138
+ const command = createLibericaAuthCommand();
139
+ const logoutCmd = command.commands.find((cmd) => cmd.name() === 'logout');
140
+ const allOption = logoutCmd?.options.find((opt) => opt.long === '--all');
141
+ expect(allOption).toBeDefined();
142
+ });
143
+ });
144
+ });
145
+
146
+ describe('auth command integration', () => {
147
+ it('should call apiClient.login with correct parameters on login', async () => {
148
+ const { apiClient } = await import('../../../../src/core/api/client.js');
149
+ const { configManager } = await import('../../../../src/core/config/manager.js');
150
+ const { tokenManager } = await import('../../../../src/core/auth/token-manager.js');
151
+
152
+ (apiClient.login as ReturnType<typeof vi.fn>).mockResolvedValue({
153
+ success: true,
154
+ data: { token: 'test-token', expiresAt: '2024-12-31' },
155
+ });
156
+
157
+ (configManager.getCurrentContext as ReturnType<typeof vi.fn>).mockReturnValue({
158
+ environment: 'dev',
159
+ service: 'liberica',
160
+ tenant: 'test-tenant',
161
+ });
162
+
163
+ expect(apiClient.login).toBeDefined();
164
+ });
165
+
166
+ it('should call tokenManager.setToken after successful login', async () => {
167
+ const { tokenManager } = await import('../../../../src/core/auth/token-manager.js');
168
+ expect(tokenManager.setToken).toBeDefined();
169
+ });
170
+
171
+ it('should call configManager.setTenant after successful login', async () => {
172
+ const { configManager } = await import('../../../../src/core/config/manager.js');
173
+ expect(configManager.setTenant).toBeDefined();
174
+ });
175
+ });
@@ -0,0 +1,98 @@
1
+ import { describe, it, expect, beforeEach, vi } from 'vitest';
2
+
3
+ vi.mock('chalk', () => ({
4
+ default: {
5
+ bold: vi.fn((text) => text),
6
+ green: vi.fn((text) => text),
7
+ red: vi.fn((text) => text),
8
+ gray: vi.fn((text) => text),
9
+ },
10
+ }));
11
+
12
+ vi.mock('../../../../src/core/config/manager.js', () => ({
13
+ configManager: {
14
+ getCurrentContext: vi.fn(() => ({
15
+ environment: 'dev' as const,
16
+ service: 'liberica' as const,
17
+ tenant: 'test-tenant',
18
+ })),
19
+ setTenant: vi.fn(),
20
+ },
21
+ }));
22
+
23
+ vi.mock('../../../../src/core/auth/token-manager.js', () => ({
24
+ tokenManager: {
25
+ getToken: vi.fn(),
26
+ setToken: vi.fn(),
27
+ deleteToken: vi.fn(),
28
+ },
29
+ }));
30
+
31
+ import { createLibericaContextCommand } from '../../../../src/commands/liberica/context/index.js';
32
+
33
+ describe('createLibericaContextCommand', () => {
34
+ beforeEach(() => {
35
+ vi.clearAllMocks();
36
+ });
37
+
38
+ it('should create command with name "context"', () => {
39
+ const command = createLibericaContextCommand();
40
+ expect(command.name()).toBe('context');
41
+ });
42
+
43
+ it('should have description "Manage Liberica context (tenant, environment)"', () => {
44
+ const command = createLibericaContextCommand();
45
+ expect(command.description()).toBe('Manage Liberica context (tenant, environment)');
46
+ });
47
+
48
+ describe('show subcommand', () => {
49
+ it('should exist', () => {
50
+ const command = createLibericaContextCommand();
51
+ const showCmd = command.commands.find((cmd) => cmd.name() === 'show');
52
+ expect(showCmd).toBeDefined();
53
+ });
54
+
55
+ it('should have correct description', () => {
56
+ const command = createLibericaContextCommand();
57
+ const showCmd = command.commands.find((cmd) => cmd.name() === 'show');
58
+ expect(showCmd?.description()).toBe('Show current Liberica context');
59
+ });
60
+ });
61
+
62
+ describe('use-enterprise subcommand', () => {
63
+ it('should exist', () => {
64
+ const command = createLibericaContextCommand();
65
+ const useEnterpriseCmd = command.commands.find((cmd) => cmd.name() === 'use-enterprise');
66
+ expect(useEnterpriseCmd).toBeDefined();
67
+ });
68
+
69
+ it('should have correct description', () => {
70
+ const command = createLibericaContextCommand();
71
+ const useEnterpriseCmd = command.commands.find((cmd) => cmd.name() === 'use-enterprise');
72
+ expect(useEnterpriseCmd?.description()).toBe('Switch Liberica tenant (enterprise)');
73
+ });
74
+
75
+ it('should have use-enterprise as a standalone command', () => {
76
+ const command = createLibericaContextCommand();
77
+ const useEnterpriseCmd = command.commands.find((cmd) => cmd.name() === 'use-enterprise');
78
+ expect(useEnterpriseCmd).toBeDefined();
79
+ });
80
+ });
81
+ });
82
+
83
+ describe('context command integration', () => {
84
+ it('should call configManager.getCurrentContext on show', async () => {
85
+ const { configManager } = await import('../../../../src/core/config/manager.js');
86
+ expect(configManager.getCurrentContext).toBeDefined();
87
+ });
88
+
89
+ it('should call tokenManager.getToken on show', async () => {
90
+ const { tokenManager } = await import('../../../../src/core/auth/token-manager.js');
91
+ expect(tokenManager.getToken).toBeDefined();
92
+ });
93
+
94
+ it('should call configManager.setTenant on use-enterprise', async () => {
95
+ const { configManager } = await import('../../../../src/core/config/manager.js');
96
+ expect(configManager.setTenant).toBeDefined();
97
+ });
98
+ });