|
| 1 | +import { randomBytes } from 'node:crypto'; |
| 2 | + |
| 3 | +import { runCli } from '../../__helpers__/run-cli.js'; |
| 4 | + |
| 5 | +describe('[e2e][api] actors info', () => { |
| 6 | + let authEnv: Record<string, string>; |
| 7 | + |
| 8 | + beforeAll(async () => { |
| 9 | + const token = process.env.TEST_USER_TOKEN; |
| 10 | + if (!token) throw new Error('TEST_USER_TOKEN env var is required for actors info tests'); |
| 11 | + |
| 12 | + const authPath = `e2e-actors-info-${randomBytes(6).toString('hex')}`; |
| 13 | + authEnv = { __APIFY_INTERNAL_TEST_AUTH_PATH__: authPath }; |
| 14 | + |
| 15 | + const loginResult = await runCli('apify', ['login', '--token', token], { env: authEnv }); |
| 16 | + if (loginResult.exitCode !== 0) { |
| 17 | + throw new Error(`Failed to login:\n${loginResult.stderr}`); |
| 18 | + } |
| 19 | + }); |
| 20 | + |
| 21 | + it('shows info for a public actor (--json)', async () => { |
| 22 | + const result = await runCli('apify', ['actors', 'info', 'apify/web-scraper', '--json'], { env: authEnv }); |
| 23 | + |
| 24 | + expect(result.exitCode, `stderr: ${result.stderr}`).toBe(0); |
| 25 | + const data = JSON.parse(result.stdout); |
| 26 | + expect(data.name).toBe('web-scraper'); |
| 27 | + }); |
| 28 | + |
| 29 | + it('shows README with --readme flag', async () => { |
| 30 | + const result = await runCli('apify', ['actors', 'info', 'apify/web-scraper', '--readme'], { env: authEnv }); |
| 31 | + |
| 32 | + expect(result.exitCode, `stderr: ${result.stderr}`).toBe(0); |
| 33 | + expect(result.stdout.length).toBeGreaterThan(0); |
| 34 | + }); |
| 35 | + |
| 36 | + it('shows input schema with --input flag', async () => { |
| 37 | + const result = await runCli('apify', ['actors', 'info', 'apify/rag-web-browser', '--input'], { env: authEnv }); |
| 38 | + |
| 39 | + expect(result.exitCode, `stderr: ${result.stderr}`).toBe(0); |
| 40 | + expect(() => JSON.parse(result.stdout)).not.toThrow(); |
| 41 | + }); |
| 42 | + |
| 43 | + it('fails with invalid actor ID', async () => { |
| 44 | + const result = await runCli('apify', ['actors', 'info', 'nonexistent/actor-xyz'], { env: authEnv }); |
| 45 | + |
| 46 | + expect(result.stdout).toContain('was not found'); |
| 47 | + }); |
| 48 | +}); |
0 commit comments