From 4724c21cb408d100b00a6750b6fce5684063c409 Mon Sep 17 00:00:00 2001 From: Alf Eaton Date: Mon, 15 Nov 2021 15:44:06 +0000 Subject: [PATCH] Merge pull request #5709 from overleaf/ae-fail-prop-types-tests Format error messages for test failure GitOrigin-RevId: 74da66d9da31939755162a91f5adf4f8122f06f6 --- .../components/toolbar-header.test.js | 3 +++ .../features/outline/components/outline-pane.test.js | 8 +++++++- services/web/test/frontend/prop-types.test.js | 8 ++++++-- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/services/web/test/frontend/features/editor-navigation-toolbar/components/toolbar-header.test.js b/services/web/test/frontend/features/editor-navigation-toolbar/components/toolbar-header.test.js index ca612d1cf3..69decc31c8 100644 --- a/services/web/test/frontend/features/editor-navigation-toolbar/components/toolbar-header.test.js +++ b/services/web/test/frontend/features/editor-navigation-toolbar/components/toolbar-header.test.js @@ -18,6 +18,9 @@ describe('', function () { togglePdfView: () => {}, hasPublishPermissions: true, trackChangesVisible: true, + handleChangeLayout: () => {}, + pdfLayout: '', + view: '', } describe('cobranding logo', function () { diff --git a/services/web/test/frontend/features/outline/components/outline-pane.test.js b/services/web/test/frontend/features/outline/components/outline-pane.test.js index 47189e37f3..42faa99e7d 100644 --- a/services/web/test/frontend/features/outline/components/outline-pane.test.js +++ b/services/web/test/frontend/features/outline/components/outline-pane.test.js @@ -76,7 +76,13 @@ describe('', function () { }) it('expand outline and use local storage', function () { - global.localStorage.getItem.returns(false) + global.localStorage.getItem.callsFake(key => { + if (key.startsWith('file_outline.expanded.')) { + return false + } + return null + }) + const outline = [ { title: 'Section', diff --git a/services/web/test/frontend/prop-types.test.js b/services/web/test/frontend/prop-types.test.js index 8e4b148410..78f382961b 100644 --- a/services/web/test/frontend/prop-types.test.js +++ b/services/web/test/frontend/prop-types.test.js @@ -1,3 +1,5 @@ +import { format } from 'util' + /** * Make tests fail when prop-types are incorrect. * @@ -14,10 +16,12 @@ before(function () { // Ensure we still log the error originalConsoleError(message, ...args) + const formattedMessage = format(message, ...args) + // Check if the error is from prop-types - if (/Failed (prop|data) type/.test(message)) { + if (/Failed (prop|data) type/.test(formattedMessage)) { // Throw an error, causing the test to fail - throw new Error(message) + throw new Error(formattedMessage) } } })