Skip to content

Commit e480810

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

File tree

2 files changed

+94
-1
lines changed

2 files changed

+94
-1
lines changed

.github/workflows/e2e-cli.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ on:
99
push:
1010
branches: [main]
1111
pull_request:
12-
branches: [main]
12+
branches: [*]
1313
workflow_dispatch:
1414

1515
jobs:
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
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+
// Act
24+
const { stdout, exitCode } = await executeCLI(['list-applications']);
25+
26+
expect(exitCode).toBe(0);
27+
28+
// Parse the applications from the output
29+
const output = String(stdout);
30+
const applicationsMatch = output.match(/Applications: (\[.*\])/s);
31+
expect(applicationsMatch).toBeTruthy();
32+
33+
const applications = JSON.parse(applicationsMatch![1]) as Array<Application>;
34+
expect(Array.isArray(applications)).toBe(true);
35+
});
36+
});
37+
38+
describe('SWR-TSSDK-2.2: Application Details', () => {
39+
it('should provide application identification, description, and regulatory compliance information', async () => {
40+
// Act
41+
const { stdout, exitCode } = await executeCLI(['list-applications']);
42+
43+
expect(exitCode).toBe(0);
44+
45+
// Parse the applications from the output
46+
const output = String(stdout);
47+
const applicationsMatch = output.match(/Applications: (\[.*\])/s);
48+
expect(applicationsMatch).toBeTruthy();
49+
50+
const applications = JSON.parse(applicationsMatch![1]) as Array<Application>;
51+
expect(Array.isArray(applications)).toBe(true);
52+
53+
// Find test-app in the list
54+
const testApp = applications.find(app => app.application_id === 'test-app');
55+
expect(testApp).toBeDefined();
56+
57+
// Assert test-app properties
58+
expect(testApp).toMatchObject({
59+
application_id: 'test-app',
60+
name: 'test-app',
61+
regulatory_classes: expect.arrayContaining([expect.any(String)]),
62+
description: expect.any(String),
63+
});
64+
});
65+
});
66+
67+
describe('SWR-TSSDK-2.3: Version List Retrieval', () => {
68+
it('should retrieve all versions for a specified application', async () => {
69+
// Act - Assuming there's a command to list versions for an application
70+
const { stdout, exitCode } = await executeCLI(['list-application-versions', 'test-app']);
71+
72+
expect(exitCode).toBe(0);
73+
74+
// Parse the versions from the output
75+
const output = String(stdout);
76+
const versionsMatch = output.match(/Application versions for test-app: (\[.*\])/s);
77+
expect(versionsMatch).toBeTruthy();
78+
79+
const versions = JSON.parse(versionsMatch![1]) as Array<ApplicationVersion>;
80+
expect(Array.isArray(versions)).toBe(true);
81+
expect(versions.length).toBeGreaterThan(0);
82+
83+
// Verify each version has required properties
84+
versions.forEach(version => {
85+
expect(version).toHaveProperty('number');
86+
expect(version).toHaveProperty('released_at');
87+
expect(version.number).toMatch(/\d+\.\d+\.\d+/);
88+
expect(version.released_at).toMatch(
89+
/^\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$/
90+
);
91+
});
92+
});
93+
});

0 commit comments

Comments
 (0)