From 251bdc9f36d69d2aa3d3085a9d7cea9873dd397b Mon Sep 17 00:00:00 2001 From: Rachel Dauns Date: Tue, 12 Dec 2023 09:28:41 -0500 Subject: [PATCH] dashboard clean-up --- .../server/routes/dashboard.js | 1 + .../server/routes/dashboard.test.js | 19 +++---------------- 2 files changed, 4 insertions(+), 16 deletions(-) diff --git a/packages/app/obojobo-repository/server/routes/dashboard.js b/packages/app/obojobo-repository/server/routes/dashboard.js index 33f21f5e0..76794c22b 100644 --- a/packages/app/obojobo-repository/server/routes/dashboard.js +++ b/packages/app/obojobo-repository/server/routes/dashboard.js @@ -54,6 +54,7 @@ const renderDashboard = (req, res, options) => { }) .then(collections => { myCollections = collections + switch (options.mode) { case MODE_COLLECTION: pageTitle = 'View Collection' diff --git a/packages/app/obojobo-repository/server/routes/dashboard.test.js b/packages/app/obojobo-repository/server/routes/dashboard.test.js index 0ac421dce..aa865d5bf 100644 --- a/packages/app/obojobo-repository/server/routes/dashboard.test.js +++ b/packages/app/obojobo-repository/server/routes/dashboard.test.js @@ -130,7 +130,6 @@ describe('repository dashboard route', () => { hasPermission: perm => perm === 'canPreviewDrafts' } mockNotifications = [] - //getNotifications = require('obojobo-express/server/express_current_user').getNotifications CollectionSummary = require('../models/collection_summary') DraftSummary = require('../models/draft_summary') CountServices = require('../services/count') @@ -161,6 +160,8 @@ describe('repository dashboard route', () => { } test('get /dashboard sends the correct props to the Dashboard component', () => { + expect.hasAssertions() + CountServices.getUserModuleCount.mockResolvedValueOnce(5) CollectionSummary.fetchByUserId = jest.fn() @@ -189,6 +190,7 @@ describe('repository dashboard route', () => { expect(DraftSummary.fetchAllInCollection).not.toHaveBeenCalled() expect(DraftSummary.fetchByUserId).not.toHaveBeenCalled() expect(DraftSummary.fetchDeletedByUserId).not.toHaveBeenCalled() + expect(mockDashboardComponent).toHaveBeenCalledTimes(1) expect(mockDashboardComponentConstructor).toHaveBeenCalledWith({ title: 'Dashboard', @@ -313,11 +315,6 @@ describe('repository dashboard route', () => { test('get /collections/:nameOrId sends the correct props to the Dashboard component with cookies set and the collection exists and the user owns the collection', () => { expect.hasAssertions() - /*const req = { - getNotifications: jest.fn().mockResolvedValue(mockNotifications), - currentUser: mockCurrentUser, // Assuming you have a mockCurrentUser defined - }*/ - const mockShortToUUID = jest.fn() mockShortToUUID.mockReturnValue('mockCollectionLongId') short.mockReturnValue({ @@ -444,10 +441,6 @@ describe('repository dashboard route', () => { test('get /collections/:nameOrId sends the correct response when the user owns the collection but a database error occurs', () => { expect.hasAssertions() - /*const req = { - getNotifications: jest.fn().mockResolvedValue(mockNotifications), - currentUser: mockCurrentUser, // Assuming you have a mockCurrentUser defined - }*/ const mockShortToUUID = jest.fn() mockShortToUUID.mockReturnValue('mockCollectionLongId') @@ -473,7 +466,6 @@ describe('repository dashboard route', () => { .get(path) .set('cookie', ['']) .then(response => { - //expect(req.getNotifications).toHaveBeenCalledTimes(1) expect(mockShortToUUID).toHaveBeenCalledTimes(1) expect(mockShortToUUID).toHaveBeenCalledWith('mockCollectionShortId') @@ -502,10 +494,6 @@ describe('repository dashboard route', () => { test('get /dashboard/deleted sends the correct props to the Dashboard component with cookies set', () => { expect.hasAssertions() - /*const req = { - getNotifications: jest.fn().mockResolvedValue(mockNotifications), - currentUser: mockCurrentUser, - } */ CountServices.getUserModuleCount.mockResolvedValueOnce(5) @@ -521,7 +509,6 @@ describe('repository dashboard route', () => { .get('/dashboard/deleted') .set('cookie', [generateCookie('module', 'dashboard/deleted', 'last updated')]) .then(response => { - //expect(req.getNotifications).toHaveBeenCalledTimes(1) expect(CountServices.getUserModuleCount).toHaveBeenCalledTimes(1) expect(CountServices.getUserModuleCount).toHaveBeenCalledWith(mockCurrentUser.id)