Skip to content

Commit ae59017

Browse files
committed
chore(e2e): adding e2e tests for the licensed-users-info internal backend plugin.
fixes: RHIDP-7768 Signed-off-by: Lucas Holmquist <[email protected]>
1 parent ba92b96 commit ae59017

File tree

1 file changed

+101
-0
lines changed

1 file changed

+101
-0
lines changed
Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
import { CatalogUsersPO } from "../../../support/pageObjects/catalog/catalog-users-obj";
2+
import { RhdhAuthUiHack } from "../../../support/api/rhdh-auth-hack";
3+
import { Common } from "../../../utils/common";
4+
import { test, expect } from "@playwright/test";
5+
6+
test.describe("Test licensed users info backend plugin", async () => {
7+
let common: Common;
8+
let apiToken: string;
9+
10+
const baseRHDHURL: string = process.env.BASE_URL;
11+
const pluginAPIURL: string = 'api/licensed-users-info';
12+
13+
test.beforeEach(async ({ page }) => {
14+
common = new Common(page);
15+
await common.loginAsGuest();
16+
await CatalogUsersPO.visitBaseURL(page);
17+
18+
// Get the api token
19+
const hacker: RhdhAuthUiHack = RhdhAuthUiHack.getInstance();
20+
apiToken = await hacker.getApiToken(page);
21+
});
22+
23+
test("Test plugin health check endpoint", async () => {
24+
const response = await fetch(`${baseRHDHURL}/${pluginAPIURL}/health`);
25+
const result = await response.json();
26+
27+
/*
28+
{ status: 'ok' }
29+
*/
30+
31+
expect(result).toHaveProperty('status');
32+
expect(result.status).toBe("ok");
33+
});
34+
35+
test("Test plugin user quantity url", async () => {
36+
const response = await fetch(`${baseRHDHURL}/${pluginAPIURL}/users/quantity`, {
37+
headers: {
38+
Authorization: apiToken
39+
}
40+
});
41+
const result = await response.json();
42+
43+
/*
44+
{ quantity: '1' }
45+
*/
46+
47+
expect(result).toHaveProperty('quantity');
48+
expect(result.quantity).toBe("1");
49+
});
50+
51+
test("Test plugin users url", async () => {
52+
const response = await fetch(`${baseRHDHURL}/${pluginAPIURL}/users`, {
53+
headers: {
54+
Authorization: apiToken
55+
}
56+
});
57+
const result = await response.json();
58+
59+
/*
60+
[
61+
{
62+
userEntityRef: 'user:development/guest',
63+
lastAuthTime: 'Thu, 17 Jul 2025 17:53:51 GMT'
64+
}
65+
]
66+
*/
67+
68+
expect(Array.isArray(result)).toBe(true);
69+
expect(result.length).toBeGreaterThan(0);
70+
expect(result[0]).toHaveProperty('userEntityRef');
71+
expect(result[0]).toHaveProperty('lastAuthTime');
72+
expect(result[0].userEntityRef).toBe('user:development/guest');
73+
});
74+
75+
test("Test plugin users as a csv url", async () => {
76+
const response = await fetch(`${baseRHDHURL}/${pluginAPIURL}/users`, {
77+
headers: {
78+
Authorization: apiToken,
79+
'Content-Type': 'text/csv'
80+
}
81+
});
82+
83+
// 'content-type': 'text/csv; charset=utf-8',
84+
expect(response.headers.get("content-type")).toContain('text/csv');
85+
86+
// 'content-disposition': 'attachment; filename="data.csv"',
87+
expect(response.headers.get("content-disposition")).toBe("attachment; filename=\"data.csv\"");
88+
89+
const result = await response.text();
90+
/*
91+
userEntityRef,displayName,email,lastAuthTime
92+
user:development/guest,undefined,undefined,"Fri, 18 Jul 2025 12:41:47 GMT"
93+
*/
94+
const splitText = result.split('\n');
95+
const csvHeaders = splitText[0];
96+
const csvData = splitText[1];
97+
98+
expect(csvHeaders).toContain("userEntityRef,displayName,email,lastAuthTime");
99+
expect(csvData).toContain("user:development/guest");
100+
});
101+
});

0 commit comments

Comments
 (0)