fix tests

This commit is contained in:
Hongbo Wu 2024-04-16 12:24:20 +08:00
parent 6ce95194ee
commit 8e31ac4fea
2 changed files with 7 additions and 7 deletions

View file

@ -81,7 +81,7 @@ export const mergeHighlightResolver = authorized<
MergeHighlightSuccess,
MergeHighlightError,
MutationMergeHighlightArgs
>(async (_, { input }, { log, pubsub, uid }) => {
>(async (_, { input }, { authTrx, log, pubsub, uid }) => {
const { overlapHighlightIdList, ...newHighlightInput } = input
/* Compute merged annotation form the order of highlights appearing on page */
@ -90,9 +90,10 @@ export const mergeHighlightResolver = authorized<
const mergedColors: string[] = []
try {
const existingHighlights = await highlightRepository.findByLibraryItemId(
input.articleId,
uid
const existingHighlights = await authTrx((tx) =>
tx
.withRepository(highlightRepository)
.findByLibraryItemId(input.articleId, uid)
)
existingHighlights.forEach((highlight) => {

View file

@ -1,10 +1,9 @@
/* eslint-disable @typescript-eslint/restrict-template-expressions */
import * as chai from 'chai'
import { expect } from 'chai'
import chaiString from 'chai-string'
import 'mocha'
import { Highlight } from '../../src/entity/highlight'
import { User } from '../../src/entity/user'
import { getRepository } from '../../src/repository'
import {
createHighlight,
deleteHighlightById,
@ -157,7 +156,7 @@ describe('Highlights API', () => {
.post('/local/debug/fake-user-login')
.send({ fakeEmail: user.email })
authToken = res.body.authToken
authToken = res.body.authToken as string
itemId = (await createTestLibraryItem(user.id)).id
})