feat: Add button to empty trash (#6772)

Co-authored-by: Tom Moor <tom.moor@gmail.com>
This commit is contained in:
Hemachandar
2024-04-16 18:34:56 +05:30
committed by GitHub
parent a5d2752122
commit ef0fb74308
11 changed files with 244 additions and 18 deletions

View File

@@ -4345,3 +4345,58 @@ describe("#documents.memberships", () => {
expect(body.data.users[0].id).toEqual(members[1].id);
});
});
describe("#documents.empty_trash", () => {
it("should require authentication", async () => {
const res = await server.post("/api/documents.empty_trash");
const body = await res.json();
expect(res.status).toEqual(401);
expect(body).toMatchSnapshot();
});
it("should allow admin users", async () => {
const user = await buildAdmin();
const res = await server.post("/api/documents.empty_trash", {
body: {
token: user.getJwtToken(),
},
});
const body = await res.json();
expect(res.status).toEqual(200);
expect(body.success).toEqual(true);
});
it("should not allow non-admin users", async () => {
const user = await buildUser();
const res = await server.post("/api/documents.empty_trash", {
body: {
token: user.getJwtToken(),
},
});
const body = await res.json();
expect(res.status).toEqual(403);
expect(body).toMatchSnapshot();
});
it("should permanently delete documents", async () => {
const user = await buildAdmin();
const document = await buildDocument({
userId: user.id,
teamId: user.teamId,
});
await document.delete(user.id);
const res = await server.post("/api/documents.empty_trash", {
body: {
token: user.getJwtToken(),
},
});
const body = await res.json();
expect(res.status).toEqual(200);
expect(body.success).toEqual(true);
const deletedDoc = await Document.findByPk(document.id, {
userId: user.id,
paranoid: false,
});
expect(deletedDoc).toBeNull();
});
});