Skip to content

Commit

Permalink
fix(core): share page show 404 (#9083)
Browse files Browse the repository at this point in the history
  • Loading branch information
EYHN committed Dec 10, 2024
1 parent ffad115 commit 18d65df
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ export class ShareReaderStore extends Store {
const docResponse = await this.rawFetch.fetch(
`/api/workspaces/${workspaceId}/docs/${docId}`
);
if (docResponse.status !== 200) {
throw new Error('Failed to fetch workspace');
}
const publishMode = docResponse.headers.get(
'publish-mode'
) as DocMode | null;
Expand All @@ -26,6 +29,9 @@ export class ShareReaderStore extends Store {
const workspaceResponse = await this.rawFetch.fetch(
`/api/workspaces/${workspaceId}/docs/${workspaceId}`
);
if (workspaceResponse.status !== 200) {
throw new Error('Failed to fetch workspace');
}
const workspaceBinary = await workspaceResponse.arrayBuffer();

return {
Expand Down
10 changes: 10 additions & 0 deletions tests/affine-cloud/e2e/share-page.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -340,3 +340,13 @@ test('The reference links in the shared page should be accessible normally and c
);
}
});

test('Should show no permission page when the share page is not found', async ({
page,
}) => {
await page.goto('http://localhost:8080/workspace/abc/123');

await expect(
page.getByText('You do not have access or this content does not exist.')
).toBeVisible();
});

0 comments on commit 18d65df

Please sign in to comment.