MCPcopy
hub / github.com/IgnisDa/ryot / registerTestUser

Function registerTestUser

tests/src/utils.ts:33–75  ·  view source on GitHub ↗
(baseUrl: string)

Source from the content-addressed store, hash-verified

31};
32
33export async function registerTestUser(baseUrl: string) {
34 const client = getGraphqlClient(baseUrl);
35 const username = faker.internet.username();
36 const password = faker.internet.password();
37 console.log(
38 `[Test Utils] Registering user with username: ${username}, password: ${password}`,
39 );
40
41 try {
42 const { registerUser } = await client.request(RegisterUserDocument, {
43 input: { data: { password: { username, password } } },
44 });
45
46 if (registerUser.__typename === "RegisterError") {
47 throw new Error(`Failed to register test user: ${registerUser.error}`);
48 }
49
50 console.log(
51 `[Test Utils] Test user '${username}' registered successfully with ID: ${registerUser.id}`,
52 );
53
54 const { loginUser } = await client.request(LoginUserDocument, {
55 input: { password: { username, password } },
56 });
57
58 if (loginUser.__typename === "LoginError") {
59 throw new Error(`Failed to login test user: ${loginUser.error}`);
60 }
61
62 if (loginUser.__typename !== "ApiKeyResponse") {
63 throw new Error(
64 `Expected ApiKeyResponse but got ${loginUser.__typename}`,
65 );
66 }
67
68 console.log(`[Test Utils] Test user '${username}' logged in`);
69
70 return [loginUser.apiKey, registerUser.id] as const;
71 } catch (err) {
72 console.error("[Test Utils] Error registering test user:", err);
73 throw err;
74 }
75}
76
77export async function getUserCollectionsList(
78 baseUrl: string,

Callers 4

user.test.tsFile · 0.90
cache.test.tsFile · 0.90
registerAdminUserFunction · 0.85

Calls 3

getGraphqlClientFunction · 0.85
logMethod · 0.80
errorMethod · 0.80

Tested by

no test coverage detected