mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-22 12:36:24 +08:00
@@ -59,6 +59,7 @@ test('should update workspace', async t => {
|
||||
const data = {
|
||||
public: true,
|
||||
enableAi: true,
|
||||
enableSharing: false,
|
||||
enableUrlPreview: true,
|
||||
enableDocEmbedding: false,
|
||||
};
|
||||
|
||||
@@ -85,6 +85,26 @@ export async function updateWorkspace(
|
||||
return res.updateWorkspace.public;
|
||||
}
|
||||
|
||||
export async function setWorkspaceSharing(
|
||||
app: TestingApp,
|
||||
workspaceId: string,
|
||||
enableSharing: boolean
|
||||
) {
|
||||
const res = await app.gql(
|
||||
`
|
||||
mutation {
|
||||
updateWorkspace(
|
||||
input: { id: "${workspaceId}", enableSharing: ${enableSharing} }
|
||||
) {
|
||||
enableSharing
|
||||
}
|
||||
}
|
||||
`
|
||||
);
|
||||
|
||||
return res.updateWorkspace.enableSharing as boolean;
|
||||
}
|
||||
|
||||
export async function deleteWorkspace(
|
||||
app: TestingApp,
|
||||
workspaceId: string
|
||||
|
||||
@@ -10,6 +10,7 @@ import {
|
||||
inviteUser,
|
||||
publishDoc,
|
||||
revokePublicDoc,
|
||||
setWorkspaceSharing,
|
||||
TestingApp,
|
||||
updateWorkspace,
|
||||
} from './utils';
|
||||
@@ -180,4 +181,17 @@ test('should be able to get public workspace doc', async t => {
|
||||
.type('application/octet-stream');
|
||||
|
||||
t.deepEqual(res.body, Buffer.from([0, 0]), 'failed to get public doc');
|
||||
|
||||
const disabled = await setWorkspaceSharing(app, workspace.id, false);
|
||||
t.false(disabled, 'failed to disable workspace sharing');
|
||||
|
||||
// owner should still be able to access
|
||||
await app
|
||||
.GET(`/api/workspaces/${workspace.id}/docs/${workspace.id}`)
|
||||
.expect(200);
|
||||
|
||||
await app.logout();
|
||||
await app
|
||||
.GET(`/api/workspaces/${workspace.id}/docs/${workspace.id}`)
|
||||
.expect(403);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user