Skip to content

Commit

Permalink
more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jouliet committed Jul 17, 2023
1 parent cad70f4 commit 053686e
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 0 deletions.
33 changes: 33 additions & 0 deletions tdrive/backend/node/test/e2e/documents/documents.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
e2e_createDocumentFile,
e2e_createVersion,
e2e_deleteDocument,
e2e_downloadFile,
e2e_getDocument,
e2e_searchDocument,
e2e_updateDocument,
Expand Down Expand Up @@ -220,6 +221,38 @@ describe("the Drive feature", () => {
expect(child.name === "file2" || copiedItemResult.name === "file3").toBe(true);
}
});
it("did copy a single file and able to download it",async () => {
const createItemResult = await createItem();
const copiedItemResult = await copyItem(createItemResult, 'root');

const download = await e2e_downloadFile(platform, copiedItemResult.id);

expect(copiedItemResult).toBeDefined();
expect(download).toHaveReturned();
});
it("did copy a single file and able to search it",async () => {
const createItemResult = await createItem();
const copiedItemResult = await copyItem(createItemResult, 'root');

expect(copiedItemResult).toBeDefined();

await e2e_getDocument(platform, "root");
await e2e_getDocument(platform, copiedItemResult.id);

await new Promise(resolve => setTimeout(resolve, 3000));

const searchPayload = {
search: "test",
};

const searchResponse = await e2e_searchDocument(platform, searchPayload);
const searchResult = deserialize<SearchResultMockClass>(
SearchResultMockClass,
searchResponse.body,
);

expect(searchResult.entities.length).toBeGreaterThanOrEqual(1);
});

it("did search for an item", async () => {
jest.setTimeout(10000);
Expand Down
12 changes: 12 additions & 0 deletions tdrive/backend/node/test/e2e/documents/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,3 +134,15 @@ export const e2e_createDocumentFile = async (platform: TestPlatform) => {
...form,
});
};

export const e2e_downloadFile = async (platform: TestPlatform, id: string) => {
const token = await platform.auth.getJWTToken();

return await platform.app.inject({
method: "GET",
url: `${url}/companies/${platform.workspace.company_id}/item/${id}/download`,
headers: {
authorization: `Bearer ${token}`,
},
})
}

0 comments on commit 053686e

Please sign in to comment.