Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated to Drive API v3 #1854

Draft
wants to merge 5 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions __tests__/backend/listFolders.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ test("listFolders works correctly", () => {
}

const rawResponse = {
items: [
{ id: "ID1", title: "FOLDER1" },
{ id: "ID2", title: "FOLDER2" },
files: [
{ id: "ID1", name: "FOLDER1" },
{ id: "ID2", name: "FOLDER2" },
],
nextPageToken: undefined,
};
Expand Down Expand Up @@ -72,16 +72,16 @@ test("listFolders works correctly with shortcuts", () => {
}

const rawResponse = {
items: [
files: [
{
id: "ID1",
mimeType: "application/vnd.google-apps.shortcut",
name: "FOLDER1",
shortcutDetails: {
targetId: "TRUE_ID1",
},
title: "FOLDER1",
},
{ id: "ID2", title: "FOLDER2" },
{ id: "ID2", name: "FOLDER2" },
],
nextPageToken: undefined,
};
Expand Down
2 changes: 1 addition & 1 deletion __tests__/backend/listSharedDrives.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ test("listSharedDrives works correctly", () => {
{ id: "ID2", name: "DRIVE2" },
];
const rawResponse = {
items: response,
drives: response,
};
const driveServiceMock = mockedSafeDriveService();
driveServiceMock.Drives.list.mockReturnValueOnce(rawResponse);
Expand Down
74 changes: 37 additions & 37 deletions __tests__/backend/move/copyFileComments.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,34 +11,34 @@ test("copyFileComments works correctly", () => {
}

const rawResponse = {
items: [
comments: [
{
author: { displayName: "COM1_AUTH", isAuthenticatedUser: false },
commentId: "SRC_COM1_ID",
author: { displayName: "COM1_AUTH", me: false },
content: "COM1_CONTENT",
id: "SRC_COM1_ID",
replies: [],
},
{
author: { displayName: "COM2_AUTH", isAuthenticatedUser: true },
commentId: "SRC_COM2_ID",
author: { displayName: "COM2_AUTH", me: true },
content: "COM2_CONTENT",
id: "SRC_COM2_ID",
replies: [],
},
],
nextPageToken: undefined,
};
const driveServiceMock = mockedSafeDriveService();
driveServiceMock.Comments.insert
driveServiceMock.Comments.create
.mockReturnValueOnce({
author: { displayName: "COM2_AUTH", isAuthenticatedUser: true },
commentId: "DEST_COM1_ID",
author: { displayName: "COM2_AUTH", me: true },
content: "*COM1_AUTH:*\nCOM1_CONTENT",
id: "DEST_COM1_ID",
replies: [],
})
.mockReturnValueOnce({
author: { displayName: "COM2_AUTH", isAuthenticatedUser: true },
commentId: "DEST_COM2_ID",
author: { displayName: "COM2_AUTH", me: true },
content: "COM2_CONTENT",
id: "DEST_COM2_ID",
replies: [],
});
driveServiceMock.Comments.list.mockReturnValueOnce(rawResponse);
Expand All @@ -63,23 +63,23 @@ test("copyFileComments works correctly", () => {
?.split(",")
.map((s) => s.trim()),
).toContain("nextPageToken");
expect(driveServiceMock.Comments.insert.mock.calls).toHaveLength(2);
expect(driveServiceMock.Comments.insert.mock.calls[0][0].content).toBe(
expect(driveServiceMock.Comments.create.mock.calls).toHaveLength(2);
expect(driveServiceMock.Comments.create.mock.calls[0][0].content).toBe(
"*COM1_AUTH:*\nCOM1_CONTENT",
);
expect(
driveServiceMock.Comments.insert.mock.calls[0][0].replies,
driveServiceMock.Comments.create.mock.calls[0][0].replies,
).toStrictEqual([]);
expect(driveServiceMock.Comments.insert.mock.calls[0][1]).toBe(
expect(driveServiceMock.Comments.create.mock.calls[0][1]).toBe(
"DEST_FILE_ID",
);
expect(driveServiceMock.Comments.insert.mock.calls[1][0].content).toBe(
expect(driveServiceMock.Comments.create.mock.calls[1][0].content).toBe(
"COM2_CONTENT",
);
expect(
driveServiceMock.Comments.insert.mock.calls[1][0].replies,
driveServiceMock.Comments.create.mock.calls[1][0].replies,
).toStrictEqual([]);
expect(driveServiceMock.Comments.insert.mock.calls[1][1]).toBe(
expect(driveServiceMock.Comments.create.mock.calls[1][1]).toBe(
"DEST_FILE_ID",
);
});
Expand All @@ -92,18 +92,18 @@ test("copyFileComments works correctly with replies", () => {
}

const rawResponse = {
items: [
comments: [
{
author: { displayName: "COM_AUTH", isAuthenticatedUser: true },
commentId: "SRC_COM_ID",
author: { displayName: "COM_AUTH", me: true },
content: "COM_CONTENT",
id: "SRC_COM_ID",
replies: [
{
author: { displayName: "REPLY1_AUTH", isAuthenticatedUser: false },
author: { displayName: "REPLY1_AUTH", me: false },
content: "REPLY1_CONTENT",
},
{
author: { displayName: "REPLY2_AUTH", isAuthenticatedUser: true },
author: { displayName: "REPLY2_AUTH", me: true },
content: "REPLY2_CONTENT",
},
],
Expand All @@ -112,14 +112,14 @@ test("copyFileComments works correctly with replies", () => {
nextPageToken: undefined,
};
const driveServiceMock = mockedSafeDriveService();
driveServiceMock.Comments.insert.mockReturnValueOnce({
author: { displayName: "COM_AUTH", isAuthenticatedUser: true },
commentId: "DEST_COM_ID",
driveServiceMock.Comments.create.mockReturnValueOnce({
author: { displayName: "COM_AUTH", me: true },
content: "COM_CONTENT",
id: "DEST_COM_ID",
replies: [],
});
driveServiceMock.Comments.list.mockReturnValueOnce(rawResponse);
driveServiceMock.Replies.insert.mockReturnValueOnce({});
driveServiceMock.Replies.create.mockReturnValueOnce({});

copyFileComments_("SRC_FILE_ID", "DEST_FILE_ID", driveServiceMock);

Expand All @@ -141,25 +141,25 @@ test("copyFileComments works correctly with replies", () => {
?.split(",")
.map((s) => s.trim()),
).toContain("nextPageToken");
expect(driveServiceMock.Comments.insert.mock.calls).toHaveLength(1);
expect(driveServiceMock.Comments.insert.mock.calls[0][0].content).toBe(
expect(driveServiceMock.Comments.create.mock.calls).toHaveLength(1);
expect(driveServiceMock.Comments.create.mock.calls[0][0].content).toBe(
"COM_CONTENT",
);
expect(
driveServiceMock.Comments.insert.mock.calls[0][0].replies,
driveServiceMock.Comments.create.mock.calls[0][0].replies,
).toStrictEqual([]);
expect(driveServiceMock.Comments.insert.mock.calls[0][1]).toBe(
expect(driveServiceMock.Comments.create.mock.calls[0][1]).toBe(
"DEST_FILE_ID",
);
expect(driveServiceMock.Replies.insert.mock.calls).toHaveLength(2);
expect(driveServiceMock.Replies.insert.mock.calls[0][0].content).toBe(
expect(driveServiceMock.Replies.create.mock.calls).toHaveLength(2);
expect(driveServiceMock.Replies.create.mock.calls[0][0].content).toBe(
"*REPLY1_AUTH:*\nREPLY1_CONTENT",
);
expect(driveServiceMock.Replies.insert.mock.calls[0][1]).toBe("DEST_FILE_ID");
expect(driveServiceMock.Replies.insert.mock.calls[0][2]).toBe("DEST_COM_ID");
expect(driveServiceMock.Replies.insert.mock.calls[1][0].content).toBe(
expect(driveServiceMock.Replies.create.mock.calls[0][1]).toBe("DEST_FILE_ID");
expect(driveServiceMock.Replies.create.mock.calls[0][2]).toBe("DEST_COM_ID");
expect(driveServiceMock.Replies.create.mock.calls[1][0].content).toBe(
"REPLY2_CONTENT",
);
expect(driveServiceMock.Replies.insert.mock.calls[1][1]).toBe("DEST_FILE_ID");
expect(driveServiceMock.Replies.insert.mock.calls[1][2]).toBe("DEST_COM_ID");
expect(driveServiceMock.Replies.create.mock.calls[1][1]).toBe("DEST_FILE_ID");
expect(driveServiceMock.Replies.create.mock.calls[1][2]).toBe("DEST_COM_ID");
});
Loading
Loading