Skip to content

Commit dbe7fee

Browse files
committed
Expand auth e2e tests and update invitation schema
Added comprehensive end-to-end tests for authentication and organization flows, including session management, organization listing, updating, invitations, and sign-out. Updated invitation.object.yml to include a teamId field. Updated tsconfig.json to exclude test files from compilation.
1 parent 2f598e8 commit dbe7fee

File tree

6 files changed

+158
-0
lines changed

6 files changed

+158
-0
lines changed

packages/api/test/auth.test.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export {};

packages/api/test/auth.test.js

Lines changed: 73 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/api/test/auth.test.js.map

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/api/test/auth.test.ts

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,4 +82,83 @@ describe('AuthController (e2e)', () => {
8282
expect(response.body).toHaveProperty('id');
8383
expect(response.body.name).toBe('Dev Team');
8484
});
85+
86+
it('should get current session', async () => {
87+
const response = await agent
88+
.get('/api/v6/auth/get-session')
89+
.expect(200);
90+
91+
expect(response.body).toHaveProperty('session');
92+
expect(response.body).toHaveProperty('user');
93+
expect(response.body.user.email).toBe(email);
94+
});
95+
96+
it('should list organizations', async () => {
97+
const response = await agent
98+
.get('/api/v6/auth/organization/list')
99+
.expect(200);
100+
101+
expect(Array.isArray(response.body)).toBe(true);
102+
expect(response.body.length).toBeGreaterThan(0);
103+
const org = response.body.find((o: any) => o.id === organizationId);
104+
expect(org).toBeDefined();
105+
expect(org.name).toBe(orgName);
106+
});
107+
108+
it('should set active organization', async () => {
109+
const response = await agent
110+
.post('/api/v6/auth/organization/set-active')
111+
.send({
112+
organizationId
113+
})
114+
.expect(200);
115+
116+
// Verify session has active org
117+
const sessionResponse = await agent.get('/api/v6/auth/get-session');
118+
expect(sessionResponse.body.session.activeOrganizationId).toBe(organizationId);
119+
});
120+
121+
it('should update organization', async () => {
122+
const newName = `${orgName} Updated`;
123+
const response = await agent
124+
.post('/api/v6/auth/organization/update')
125+
.send({
126+
organizationId,
127+
data: {
128+
name: newName
129+
}
130+
})
131+
.expect(200);
132+
133+
expect(response.body.name).toBe(newName);
134+
});
135+
136+
it('should create invitation', async () => {
137+
const inviteEmail = `invitee.${uniqueId}@example.com`;
138+
const response = await agent
139+
.post('/api/v6/auth/organization/invite-member')
140+
.send({
141+
organizationId,
142+
email: inviteEmail,
143+
role: 'member'
144+
})
145+
.expect(200);
146+
147+
expect(response.body).toHaveProperty('id');
148+
expect(response.body.email).toBe(inviteEmail);
149+
expect(response.body.status).toBe('pending');
150+
});
151+
152+
it('should sign out', async () => {
153+
await agent
154+
.post('/api/v6/auth/sign-out')
155+
.send({}) // Must send empty body to set Content-Type: application/json
156+
.expect(200);
157+
158+
const response = await agent
159+
.get('/api/v6/auth/get-session')
160+
.expect(200);
161+
162+
expect(response.body).toBe(null);
163+
});
85164
});

packages/api/tsconfig.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
"strictBindCallApply": false,
2020
"noFallthroughCasesInSwitch": false
2121
},
22+
"exclude": ["node_modules", "test", "dist", "**/*.spec.ts", "**/*.test.ts"],
2223
"references": [
2324
{ "path": "../core" },
2425
{ "path": "../driver-mongo" },

packages/platform/src/invitation.object.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ fields:
1010
type: string
1111
description: Email of the invitee
1212
required: true
13+
teamId:
14+
type: string
15+
description: ID of the team
1316
role:
1417
type: string
1518
description: Role to be assigned

0 commit comments

Comments
 (0)