Skip to content

Commit

Permalink
modified the tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jouliet committed Jul 18, 2023
1 parent 053686e commit 07fe5e9
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 59 deletions.
86 changes: 37 additions & 49 deletions tdrive/backend/node/test/e2e/documents/documents.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -174,70 +174,58 @@ describe("the Drive feature", () => {
return deserialize<DriveFileMockClass>(DriveFileMockClass, response.body);
};
it("did copy a single file",async () => {
const createItemResult = await createItem();
const folder = await createItem2("folder", "root", true);
const myDriveId = "user_" + currentUser.user.id;
const sourceFile = await currentUser.uploadFileAndCreateDocument("test-file", myDriveId);
const folder = await currentUser.createDirectory(myDriveId);

const copiedItemResult = await copyItem(createItemResult, folder.id);
const copiedFile = await copyItem(sourceFile, folder.id);

expect(copiedItemResult).toBeDefined();
expect(copiedItemResult.name).toEqual("new test file");
expect(copiedItemResult.parent_id).toEqual(folder.id);
expect(copiedItemResult.added).toBeDefined();
expect(copiedFile).toBeDefined();
expect(copiedFile.name).toEqual("test-file");
expect(copiedFile.parent_id).toEqual(folder.id);
});
it("did copy a folder",async () => {
const folder = await createItem2("folder", "root", true);
const file1 = await createItem2("file1", folder.id, false);
const subfolder = await createItem2("subfolder", folder.id, true);
const file2 = await createItem2("file2", subfolder.id, false);
const file3 = await createItem2("file3", subfolder.id, false);

const copiedItemResult = await copyItem(folder, "root");

expect(copiedItemResult).toBeDefined();
expect(copiedItemResult.name).toMatch(/^folder.+/);
expect(copiedItemResult.parent_id).toEqual(folder.id);
expect(copiedItemResult.added).toBeDefined();

const fetchItemResponse = await e2e_getDocument(platform, copiedItemResult.id);
const info = deserialize<DriveItemDetailsMockClass>(
DriveItemDetailsMockClass,
fetchItemResponse.body,
);
expect(info.children).toHaveLength(2);
for (const child of info.children) {
expect(child).toBeDefined();
expect(child.name === "file1" || copiedItemResult.name === "subfolder").toBe(true);
}

const fetchItemResponse2 = await e2e_getDocument(platform, copiedItemResult.id);
const info2 = deserialize<DriveItemDetailsMockClass>(
DriveItemDetailsMockClass,
fetchItemResponse2.body,
);
expect(info2.children).toHaveLength(2);
expect(info2.children).toHaveLength(2);
for (const child of info.children) {
expect(child).toBeDefined();
expect(child.name === "file2" || copiedItemResult.name === "file3").toBe(true);
const myDriveId = "user_" + currentUser.user.id;
const folder = await currentUser.createDirectory(myDriveId);
await currentUser.uploadAllFilesOneByOne(folder.id);
const subfolder = await currentUser.createDirectory(folder.id);
await currentUser.uploadFileAndCreateDocument("subfolder-file", subfolder.id);

const copiedFolder = await copyItem(folder, myDriveId);

expect(copiedFolder).toBeDefined();
expect(copiedFolder.name).toMatch(/Test Folder Name+/);
const docs = await currentUser.browseDocuments(copiedFolder.id, {});
expect(docs).toBeDefined();
expect(docs.children).toBeDefined();
expect(docs.children.length).toEqual(TestHelpers.ALL_FILES.length + 1);
for (const child of docs.children) {
const info = await currentUser.browseDocuments(child.id, {});
if (info.children) {
expect(info.children.length).toEqual(1);
}
}
});
it("did copy a single file and able to download it",async () => {
const createItemResult = await createItem();
const copiedItemResult = await copyItem(createItemResult, 'root');
const myDriveId = "user_" + currentUser.user.id;
const sourceFile = await currentUser.uploadFileAndCreateDocument("test-file", myDriveId);

const download = await e2e_downloadFile(platform, copiedItemResult.id);
const copiedFile = await copyItem(sourceFile, myDriveId);
const download = await e2e_downloadFile(platform, copiedFile.id);

expect(copiedItemResult).toBeDefined();
expect(copiedFile).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');
const myDriveId = "user_" + currentUser.user.id;
const sourceFile = await currentUser.uploadFileAndCreateDocument("test-file", myDriveId);

const copiedFile = await copyItem(sourceFile, myDriveId);

expect(copiedItemResult).toBeDefined();
expect(copiedFile).toBeDefined();

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

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

Expand Down
15 changes: 5 additions & 10 deletions tdrive/backend/node/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -396,11 +396,6 @@
readable-stream "^3.4.0"
send "^0.17.1"

"@ffprobe-installer/[email protected]":
version "5.0.1"
resolved "https://registry.npmjs.org/@ffprobe-installer/darwin-arm64/-/darwin-arm64-5.0.1.tgz"
integrity sha512-vwNCNjokH8hfkbl6m95zICHwkSzhEvDC3GVBcUp5HX8+4wsX10SP3B+bGur7XUzTIZ4cQpgJmEIAx6TUwRepMg==

"@ffprobe-installer/ffprobe@^1.4.1":
version "1.4.1"
resolved "https://registry.npmjs.org/@ffprobe-installer/ffprobe/-/ffprobe-1.4.1.tgz"
Expand All @@ -415,6 +410,11 @@
"@ffprobe-installer/win32-ia32" "5.0.0"
"@ffprobe-installer/win32-x64" "5.0.0"

"@ffprobe-installer/[email protected]":
version "5.0.0"
resolved "https://registry.npmjs.org/@ffprobe-installer/win32-x64/-/win32-x64-5.0.0.tgz"
integrity sha512-P4ZMRFxVMnfMsOyTfBM/+nkTodLeOUfXNPo+X1bKEWBiZxRErqX/IHS5sLA0yAH8XmtKZcL7Cu6M26ztGcQYxw==

"@humanwhocodes/config-array@^0.11.10":
version "0.11.10"
resolved "https://registry.npmjs.org/@humanwhocodes/config-array/-/config-array-0.11.10.tgz"
Expand Down Expand Up @@ -3542,11 +3542,6 @@ fs.realpath@^1.0.0:
resolved "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz"
integrity sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==

fsevents@^2.3.2, fsevents@~2.3.2:
version "2.3.2"
resolved "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz"
integrity sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==

function-bind@^1.1.1:
version "1.1.1"
resolved "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz"
Expand Down

0 comments on commit 07fe5e9

Please sign in to comment.