From 0a8a30e5666f4e86445fde79c83275e5a2866983 Mon Sep 17 00:00:00 2001 From: Joe Hernandez Date: Wed, 16 Nov 2022 15:06:37 -0600 Subject: [PATCH] Return file's media_entry_id in response fixes MAT-959 flag=none Test Plan 1: Backwards compatibility - Get the changes in this commit locally in your RCS - In your local canvas, run a recent version of master - In canvas, go to an RCE - From tools menu: Insert > Document > Course documents - In the dropdown that says "Document", change to "All" - Select a file from either "Course files" or "My files" VERIFY: - file is properly embedded in the RCE. Test Plan 2: Together with corresponding changes in the canvas-lms repo - https://gerrit.instructure.com/c/canvas-lms/+/305518 - follow the test plan outlined in that commit Change-Id: I4aeaf098c8192d9664f7ef89cfa89466d328a5c0 Reviewed-on: https://gerrit.instructure.com/c/canvas-rce-api/+/305519 Tested-by: Service Cloud Jenkins Reviewed-by: Ed Schiebel QA-Review: Ed Schiebel Product-Review: Joe Hernandez --- app/api/files.js | 3 ++- test/service/api/files.test.js | 10 +++++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/app/api/files.js b/app/api/files.js index c7a810b..6a5a21c 100644 --- a/app/api/files.js +++ b/app/api/files.js @@ -38,7 +38,8 @@ function canvasResponseHandler(request, response, canvasResponse) { folderId: file.folder_id, iframeUrl: file.embedded_iframe_url, thumbnailUrl: file.thumbnail_url || file.url, - category: file.category + category: file.category, + mediaEntryId: file.media_entry_id }; }), bookmark: packageBookmark(request, canvasResponse.bookmark) diff --git a/test/service/api/files.test.js b/test/service/api/files.test.js index d117ce0..632fed0 100644 --- a/test/service/api/files.test.js +++ b/test/service/api/files.test.js @@ -115,7 +115,8 @@ describe("Files API", () => { folder_id: 1, embedded_iframe_url: "https://canvas.com/foo/bar", thumbnail_url: "https://canvas.com/foo/bar/thumbnail", - category: "foo" + category: "foo", + media_entry_id: "bar" }; }); @@ -139,7 +140,8 @@ describe("Files API", () => { folderId: 1, iframeUrl: "https://canvas.com/foo/bar", thumbnailUrl: "someurl", - category: "foo" + category: "foo", + mediaEntryId: "bar" }); }); }); @@ -156,6 +158,7 @@ describe("Files API", () => { }); it("files have correctly tranformed properties", () => { + file.media_entry_id = null; canvasResponse.body = [file]; canvasResponse.statusCode = 200; canvasResponseHandler(request, response, canvasResponse); @@ -170,7 +173,8 @@ describe("Files API", () => { folderId: 1, iframeUrl: "https://canvas.com/foo/bar", thumbnailUrl: "https://canvas.com/foo/bar/thumbnail", - category: "foo" + category: "foo", + mediaEntryId: null }); });