Skip to content

Commit

Permalink
tests(notifs + page): fixed failing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
seaerchin committed Apr 5, 2023
1 parent 215f46c commit 42be4e6
Show file tree
Hide file tree
Showing 3 changed files with 109 additions and 5 deletions.
62 changes: 61 additions & 1 deletion src/integration/NotificationOnEditHandler.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,17 @@ import {
mockIsomerUserId,
mockSiteName,
} from "@fixtures/sessionData"
import { BaseDirectoryService } from "@root/services/directoryServices/BaseDirectoryService"
import { ResourceRoomDirectoryService } from "@root/services/directoryServices/ResourceRoomDirectoryService"
import { CollectionPageService } from "@root/services/fileServices/MdPageServices/CollectionPageService"
import { ContactUsPageService } from "@root/services/fileServices/MdPageServices/ContactUsPageService"
import { HomepagePageService } from "@root/services/fileServices/MdPageServices/HomepagePageService"
import { PageService } from "@root/services/fileServices/MdPageServices/PageService"
import { ResourcePageService } from "@root/services/fileServices/MdPageServices/ResourcePageService"
import { SubcollectionPageService } from "@root/services/fileServices/MdPageServices/SubcollectionPageService"
import { UnlinkedPageService } from "@root/services/fileServices/MdPageServices/UnlinkedPageService"
import { CollectionYmlService } from "@root/services/fileServices/YmlFileServices/CollectionYmlService"
import { FooterYmlService } from "@root/services/fileServices/YmlFileServices/FooterYmlService"
import { GitHubService } from "@services/db/GitHubService"
import * as ReviewApi from "@services/db/review"
import { ConfigYmlService } from "@services/fileServices/YmlFileServices/ConfigYmlService"
Expand All @@ -41,13 +52,62 @@ const mockGithubService = {
getComments: jest.fn(),
}
const usersService = getUsersService(sequelize)
const footerYmlService = new FooterYmlService({
gitHubService: mockGithubService,
})
const collectionYmlService = new CollectionYmlService({
gitHubService: mockGithubService,
})
const baseDirectoryService = new BaseDirectoryService({
gitHubService: mockGithubService,
})

const contactUsService = new ContactUsPageService({
gitHubService: mockGithubService,
footerYmlService,
})
const collectionPageService = new CollectionPageService({
gitHubService: mockGithubService,
collectionYmlService,
})
const subCollectionPageService = new SubcollectionPageService({
gitHubService: mockGithubService,
collectionYmlService,
})
const homepageService = new HomepagePageService({
gitHubService: mockGithubService,
})
const resourcePageService = new ResourcePageService({
gitHubService: mockGithubService,
})
const unlinkedPageService = new UnlinkedPageService({
gitHubService: mockGithubService,
})
const configYmlService = new ConfigYmlService({
gitHubService: mockGithubService,
})
const resourceRoomDirectoryService = new ResourceRoomDirectoryService({
baseDirectoryService,
configYmlService,
gitHubService: mockGithubService,
})
const pageService = new PageService({
collectionPageService,
contactUsService,
subCollectionPageService,
homepageService,
resourcePageService,
unlinkedPageService,
resourceRoomDirectoryService,
})
const reviewRequestService = new ReviewRequestService(
(mockGithubService as unknown) as typeof ReviewApi,
User,
ReviewRequest,
Reviewer,
ReviewMeta,
ReviewRequestView
ReviewRequestView,
pageService
)
const sitesService = new SitesService({
siteRepository: Site,
Expand Down
50 changes: 47 additions & 3 deletions src/integration/Notifications.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,8 @@ import {
User,
Whitelist,
} from "@database/models"
import { generateRouter, generateRouterForUserWithSite } from "@fixtures/app"
import { generateRouterForUserWithSite } from "@fixtures/app"
import UserSessionData from "@root/classes/UserSessionData"
import UserWithSiteSessionData from "@root/classes/UserWithSiteSessionData"
import {
formatNotification,
highPriorityOldReadNotification,
Expand All @@ -35,7 +34,18 @@ import { NotificationsRouter as _NotificationsRouter } from "@root/routes/v2/aut
import { SitesRouter as _SitesRouter } from "@root/routes/v2/authenticated/sites"
import { genericGitHubAxiosInstance } from "@root/services/api/AxiosInstance"
import { GitHubService } from "@root/services/db/GitHubService"
import { BaseDirectoryService } from "@root/services/directoryServices/BaseDirectoryService"
import { ResourceRoomDirectoryService } from "@root/services/directoryServices/ResourceRoomDirectoryService"
import { CollectionPageService } from "@root/services/fileServices/MdPageServices/CollectionPageService"
import { ContactUsPageService } from "@root/services/fileServices/MdPageServices/ContactUsPageService"
import { HomepagePageService } from "@root/services/fileServices/MdPageServices/HomepagePageService"
import { PageService } from "@root/services/fileServices/MdPageServices/PageService"
import { ResourcePageService } from "@root/services/fileServices/MdPageServices/ResourcePageService"
import { SubcollectionPageService } from "@root/services/fileServices/MdPageServices/SubcollectionPageService"
import { UnlinkedPageService } from "@root/services/fileServices/MdPageServices/UnlinkedPageService"
import { CollectionYmlService } from "@root/services/fileServices/YmlFileServices/CollectionYmlService"
import { ConfigYmlService } from "@root/services/fileServices/YmlFileServices/ConfigYmlService"
import { FooterYmlService } from "@root/services/fileServices/YmlFileServices/FooterYmlService"
import CollaboratorsService from "@root/services/identity/CollaboratorsService"
import SitesService from "@root/services/identity/SitesService"
import ReviewRequestService from "@root/services/review/ReviewRequestService"
Expand All @@ -58,13 +68,47 @@ const gitHubService = new GitHubService({
const identityAuthService = getIdentityAuthService(gitHubService)
const usersService = getUsersService(sequelize)
const configYmlService = new ConfigYmlService({ gitHubService })
const footerYmlService = new FooterYmlService({ gitHubService })
const collectionYmlService = new CollectionYmlService({ gitHubService })
const baseDirectoryService = new BaseDirectoryService({ gitHubService })

const contactUsService = new ContactUsPageService({
gitHubService,
footerYmlService,
})
const collectionPageService = new CollectionPageService({
gitHubService,
collectionYmlService,
})
const subCollectionPageService = new SubcollectionPageService({
gitHubService,
collectionYmlService,
})
const homepageService = new HomepagePageService({ gitHubService })
const resourcePageService = new ResourcePageService({ gitHubService })
const unlinkedPageService = new UnlinkedPageService({ gitHubService })
const resourceRoomDirectoryService = new ResourceRoomDirectoryService({
baseDirectoryService,
configYmlService,
gitHubService,
})
const pageService = new PageService({
collectionPageService,
contactUsService,
subCollectionPageService,
homepageService,
resourcePageService,
unlinkedPageService,
resourceRoomDirectoryService,
})
const reviewRequestService = new ReviewRequestService(
(gitHubService as unknown) as typeof ReviewApi,
User,
ReviewRequest,
Reviewer,
ReviewMeta,
ReviewRequestView
ReviewRequestView,
pageService
)
const sitesService = new SitesService({
siteRepository: Site,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ const createMockFrontMatter = (mockPageName: string) => ({
frontMatter: {
permalink: `/${mockPageName}`,
},
pageBody: {},
pageBody: "",
},
sha: "",
})
Expand Down

0 comments on commit 42be4e6

Please sign in to comment.