MCPcopy Create free account
hub / github.com/hashintel/hash / createTestUser

Function createTestUser

tests/hash-backend-integration/src/tests/util.ts:103–139  ·  view source on GitHub ↗
(
  context: ImpureGraphContext<false, true>,
  shortNamePrefix: string,
  logger: Logger,
)

Source from the content-addressed store, hash-verified

101 `${prefix ?? ""}${randomStringSuffix()}`;
102
103export const createTestUser = async (
104 context: ImpureGraphContext<false, true>,
105 shortNamePrefix: string,
106 logger: Logger,
107) => {
108 const shortname = generateRandomShortname(shortNamePrefix);
109
110 const identity = await createKratosIdentity({
111 traits: {
112 emails: [`${shortname}@example.com`],
113 },
114 verifyEmails: true,
115 }).catch((err) => {
116 logger.error(
117 `Error when creating Kratos Identity, ${shortname}: ${
118 (err as Error).message
119 }`,
120 );
121 throw err;
122 });
123
124 const kratosIdentityId = identity.id;
125
126 return createUser(
127 context,
128 { actorId: systemAccountId },
129 {
130 emails: [`${shortname}@example.com`],
131 kratosIdentityId,
132 shortname,
133 displayName: shortname,
134 },
135 ).catch((err) => {
136 logger.error(`Error making UserModel for ${shortname}`);
137 throw err;
138 });
139};
140
141export const createTestOrg = async (
142 context: ImpureGraphContext<false, true>,

Calls 3

createKratosIdentityFunction · 0.90
createUserFunction · 0.90
generateRandomShortnameFunction · 0.85

Tested by

no test coverage detected