fix tests

This commit is contained in:
Hongbo Wu
2024-05-10 16:40:55 +08:00
parent 6e7a436cea
commit 8034e18825
5 changed files with 23 additions and 6 deletions

View File

@ -92,6 +92,7 @@ export const articleSavingRequestResolver = authorized<
'author',
'createdAt',
'updatedAt',
'savedAt',
],
relations: {
user: true,

View File

@ -64,7 +64,7 @@ export function contentRouter() {
// generate signed url for each library item
const data = await Promise.all(
libraryItems.map(async (libraryItem) => {
const filePath = `${userId}/${
const filePath = `content/${userId}/${
libraryItem.id
}.${libraryItem.updatedAt.getTime()}.${format}`

View File

@ -11,7 +11,9 @@ export const saveContentDisplayReport = async (
uid: string,
input: ReportItemInput
): Promise<boolean> => {
const item = await findLibraryItemById(input.pageId, uid)
const item = await findLibraryItemById(input.pageId, uid, {
select: ['id', 'readableContent', 'originalContent', 'originalUrl'],
})
if (!item) {
logger.info('unable to submit report, item not found', input)
return false
@ -53,7 +55,9 @@ export const saveAbuseReport = async (
uid: string,
input: ReportItemInput
): Promise<boolean> => {
const item = await findLibraryItemById(input.pageId, uid)
const item = await findLibraryItemById(input.pageId, uid, {
select: ['id'],
})
if (!item) {
logger.info('unable to submit report, item not found', input)
return false

View File

@ -2345,7 +2345,11 @@ describe('Article API', () => {
authToken
).expect(200)
const item = await findLibraryItemById(articleId, user.id)
const item = await findLibraryItemById(articleId, user.id, {
relations: {
labels: true,
},
})
expect(item?.labels?.map((l) => l.name)).to.eql(['Favorites'])
})
})

View File

@ -293,7 +293,11 @@ describe('Labels API', () => {
labelId,
}).expect(200)
const updatedItem = await findLibraryItemById(item.id, user.id)
const updatedItem = await findLibraryItemById(item.id, user.id, {
relations: {
labels: true,
},
})
expect(updatedItem?.labels).not.deep.include(toDeleteLabel)
})
})
@ -545,7 +549,11 @@ describe('Labels API', () => {
it('should update the item with the label', async () => {
await graphqlRequest(query, authToken).expect(200)
const updatedItem = await findLibraryItemById(item.id, user.id)
const updatedItem = await findLibraryItemById(item.id, user.id, {
relations: {
labels: true,
},
})
const updatedLabel = updatedItem?.labels?.filter(
(l) => l.id === labelId
)?.[0]