Skip to content

Commit 5f422c1

Browse files
committed
add e2e tests for SHR TSSDK-2 - Application Discovery
1 parent 2a833f3 commit 5f422c1

File tree

2 files changed

+92
-2
lines changed

2 files changed

+92
-2
lines changed

.github/workflows/e2e-cli.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ on:
77
# run every day at 7:00 AM UTC
88
- cron: '0 7 * * *'
99
push:
10-
branches: [main]
10+
branches: ['**']
1111
pull_request:
12-
branches: [main]
12+
branches: ['**']
1313
workflow_dispatch:
1414

1515
jobs:
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
2+
import { describe, it, expect } from 'vitest';
3+
import { executeCLI } from '../utils/command.js';
4+
5+
type Application = {
6+
application_id: string;
7+
name: string;
8+
regulatory_classes: string[];
9+
description: string;
10+
latest_version: {
11+
number: string;
12+
released_at: string;
13+
};
14+
};
15+
16+
type ApplicationVersion = {
17+
number: string;
18+
released_at: string;
19+
};
20+
21+
describe('SWR-TSSDK-2.1: Application List Retrieval', () => {
22+
it('should retrieve all available applications for authenticated user', async () => {
23+
const { stdout, exitCode } = await executeCLI(['list-applications']);
24+
25+
expect(exitCode).toBe(0);
26+
27+
// Parse the applications from the output
28+
const output = String(stdout);
29+
const applicationsMatch = output.match(/Applications: (\[.*\])/s);
30+
expect(applicationsMatch).toBeTruthy();
31+
32+
const applications = JSON.parse(applicationsMatch![1]) as Array<Application>;
33+
expect(Array.isArray(applications)).toBe(true);
34+
});
35+
});
36+
37+
describe('SWR-TSSDK-2.2: Application Details', () => {
38+
it('should provide application identification, description, and regulatory compliance information', async () => {
39+
const { stdout, exitCode } = await executeCLI(['list-applications']);
40+
41+
expect(exitCode).toBe(0);
42+
43+
// Parse the applications from the output
44+
const output = String(stdout);
45+
const applicationsMatch = output.match(/Applications: (\[.*\])/s);
46+
expect(applicationsMatch).toBeTruthy();
47+
48+
const applications = JSON.parse(applicationsMatch![1]) as Array<Application>;
49+
expect(Array.isArray(applications)).toBe(true);
50+
51+
// Find test-app in the list
52+
const testApp = applications.find(app => app.application_id === 'test-app');
53+
expect(testApp).toBeDefined();
54+
55+
// Assert test-app properties
56+
expect(testApp).toMatchObject({
57+
application_id: 'test-app',
58+
name: 'test-app',
59+
regulatory_classes: expect.arrayContaining([expect.any(String)]),
60+
description: expect.any(String),
61+
});
62+
});
63+
});
64+
65+
describe('SWR-TSSDK-2.3: Version List Retrieval', () => {
66+
it('should retrieve all versions for a specified application', async () => {
67+
const { stdout, exitCode } = await executeCLI(['list-application-versions', 'test-app']);
68+
69+
expect(exitCode).toBe(0);
70+
71+
// Parse the versions from the output
72+
const output = String(stdout);
73+
const versionsMatch = output.match(/Application versions for test-app: (\[.*\])/s);
74+
expect(versionsMatch).toBeTruthy();
75+
76+
const versions = JSON.parse(versionsMatch![1]) as Array<ApplicationVersion>;
77+
expect(Array.isArray(versions)).toBe(true);
78+
expect(versions.length).toBeGreaterThan(0);
79+
80+
// Verify each version has required properties
81+
versions.forEach(version => {
82+
expect(version).toHaveProperty('number');
83+
expect(version).toHaveProperty('released_at');
84+
expect(version.number).toMatch(/\d+\.\d+\.\d+/);
85+
expect(version.released_at).toMatch(
86+
/^\d{4}-(0[1-9]|1[0-2])-(0[1-9]|[12]\d|3[01])T([01]\d|2[0-3]):[0-5]\d:[0-5]\d(?:\.\d+)?Z$/
87+
);
88+
});
89+
});
90+
});

0 commit comments

Comments
 (0)