Skip to content

Commit

Permalink
fix: ci
Browse files Browse the repository at this point in the history
  • Loading branch information
darkskygit committed Dec 11, 2024
1 parent 348259e commit 0b08ae6
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 9 deletions.
30 changes: 23 additions & 7 deletions packages/backend/server/tests/team.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import ava from 'ava';

import { AppModule } from '../src/app.module';
import { AuthService } from '../src/core/auth';
import { DocContentService } from '../src/core/doc-renderer';
import { Permission, PermissionService } from '../src/core/permission';
import {
QuotaManagementService,
Expand All @@ -15,11 +16,11 @@ import {
} from '../src/core/quota';
import {
acceptInviteById,
createInviteLink,
createTestingApp,
createWorkspace,
getInviteInfo,
grantMember,
inviteLink,
inviteUser,
inviteUsers,
leaveWorkspace,
Expand All @@ -40,6 +41,16 @@ const test = ava as TestFn<{
test.beforeEach(async t => {
const { app } = await createTestingApp({
imports: [AppModule],
tapModule: module => {
module.overrideProvider(DocContentService).useValue({
getWorkspaceContent() {
return {
name: 'test',
avatarKey: null,
};
},
});
},
});

const quota = app.get(QuotaService);
Expand Down Expand Up @@ -94,8 +105,14 @@ const init = async (app: INestApplication, memberLimit = 10) => {
return [members, invites] as const;
};

const createInviteLink = async () => {
const inviteId = await inviteLink(app, owner.token.token, ws.id, 'OneDay');
const getCreateInviteLinkFetcher = async () => {
const inviteLink = await createInviteLink(
app,
owner.token.token,
ws.id,
'OneDay'
);
const inviteId = inviteLink.split('/').pop()!;
return [
inviteId,
async (email: string): Promise<UserAuthedType> => {
Expand All @@ -113,7 +130,7 @@ const init = async (app: INestApplication, memberLimit = 10) => {
return {
invite,
inviteBatch,
createInviteLink,
createInviteLink: getCreateInviteLinkFetcher,
owner,
ws,
admin,
Expand Down Expand Up @@ -169,7 +186,7 @@ test('should be able to check seat limit', async t => {
ws.id,
(await members1)[0][0].id
),
WorkspaceMemberStatus.Accepted,
WorkspaceMemberStatus.Pending,
'should become accepted after refresh'
);
t.is(
Expand Down Expand Up @@ -239,8 +256,7 @@ test('should be able to leave workspace', async t => {
);
});

// enabled in next PR
test.skip('should be able to invite by link', async t => {
test('should be able to invite by link', async t => {
const { app, permissions, quotaManager } = t.context;
const { createInviteLink, owner, ws } = await init(app, 4);
const [inviteId, invite] = await createInviteLink();
Expand Down
4 changes: 2 additions & 2 deletions packages/backend/server/tests/utils/invite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export async function inviteUsers(
return res.body.data.inviteBatch;
}

export async function inviteLink(
export async function createInviteLink(
app: INestApplication,
token: string,
workspaceId: string,
Expand Down Expand Up @@ -127,7 +127,7 @@ export async function leaveWorkspace(
.send({
query: `
mutation {
leaveWorkspace(workspaceId: "${workspaceId}", workspaceName: "test workspace", sendLeaveMail: ${sendLeaveMail})
leaveWorkspace(workspaceId: "${workspaceId}", sendLeaveMail: ${sendLeaveMail})
}
`,
})
Expand Down

0 comments on commit 0b08ae6

Please sign in to comment.