test: align board-channels and wiki-sync mocks with current source
board-channels: source renamed getSlackServiceNoVetting → getSlackAdminService. wiki-sync: syncWikiArticles now also calls fetchCollections; URLs starting with / are normalized to https://wiki.ghostguild.org.
This commit is contained in:
parent
e96d493024
commit
5fb2f18cab
2 changed files with 19 additions and 18 deletions
|
|
@ -1,5 +1,13 @@
|
|||
import { describe, it, expect, vi, beforeEach } from 'vitest'
|
||||
|
||||
import WikiArticle from '../../../server/models/wikiArticle.js'
|
||||
import { fetchAllDocuments, extractSummary } from '../../../server/utils/outline.js'
|
||||
import syncHandler from '../../../server/api/admin/wiki/sync.post.js'
|
||||
import { createMockEvent } from '../helpers/createMockEvent.js'
|
||||
|
||||
// Also test extractSummary directly (unmocked)
|
||||
import { extractSummary as realExtractSummary } from '../../../server/utils/outline.js'
|
||||
|
||||
// Mock dependencies before imports
|
||||
vi.mock('../../../server/models/wikiArticle.js', () => ({
|
||||
default: {
|
||||
|
|
@ -10,17 +18,10 @@ vi.mock('../../../server/models/wikiArticle.js', () => ({
|
|||
vi.mock('../../../server/utils/mongoose.js', () => ({ connectDB: vi.fn() }))
|
||||
vi.mock('../../../server/utils/outline.js', () => ({
|
||||
fetchAllDocuments: vi.fn(),
|
||||
fetchCollections: vi.fn(() => new Map()),
|
||||
extractSummary: vi.fn((text) => text || '')
|
||||
}))
|
||||
|
||||
import WikiArticle from '../../../server/models/wikiArticle.js'
|
||||
import { fetchAllDocuments, extractSummary } from '../../../server/utils/outline.js'
|
||||
import syncHandler from '../../../server/api/admin/wiki/sync.post.js'
|
||||
import { createMockEvent } from '../helpers/createMockEvent.js'
|
||||
|
||||
// Also test extractSummary directly (unmocked)
|
||||
import { extractSummary as realExtractSummary } from '../../../server/utils/outline.js'
|
||||
|
||||
function makeOutlineDoc(overrides = {}) {
|
||||
return {
|
||||
id: 'doc-1',
|
||||
|
|
@ -120,7 +121,7 @@ describe('wiki sync endpoint', () => {
|
|||
expect.objectContaining({
|
||||
$set: expect.objectContaining({
|
||||
title: 'Updated Title',
|
||||
url: '/doc/new-url'
|
||||
url: 'https://wiki.ghostguild.org/doc/new-url'
|
||||
})
|
||||
}),
|
||||
{ upsert: true, new: true, rawResult: true }
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue