Skip to content

Commit

Permalink
dashboard clean-up
Browse files Browse the repository at this point in the history
  • Loading branch information
RachelDau committed Dec 12, 2023
1 parent b298b88 commit 251bdc9
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 16 deletions.
1 change: 1 addition & 0 deletions packages/app/obojobo-repository/server/routes/dashboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ const renderDashboard = (req, res, options) => {
})
.then(collections => {
myCollections = collections

switch (options.mode) {
case MODE_COLLECTION:
pageTitle = 'View Collection'
Expand Down
19 changes: 3 additions & 16 deletions packages/app/obojobo-repository/server/routes/dashboard.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -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({
Expand Down Expand Up @@ -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')
Expand All @@ -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')

Expand Down Expand Up @@ -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)

Expand All @@ -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)

Expand Down

0 comments on commit 251bdc9

Please sign in to comment.