add mark as seen to the bulk action
This commit is contained in:
@ -279,6 +279,7 @@ export enum BulkActionType {
|
||||
Archive = 'ARCHIVE',
|
||||
Delete = 'DELETE',
|
||||
MarkAsRead = 'MARK_AS_READ',
|
||||
MarkAsSeen = 'MARK_AS_SEEN',
|
||||
MoveToFolder = 'MOVE_TO_FOLDER'
|
||||
}
|
||||
|
||||
|
||||
@ -241,6 +241,7 @@ enum BulkActionType {
|
||||
ARCHIVE
|
||||
DELETE
|
||||
MARK_AS_READ
|
||||
MARK_AS_SEEN
|
||||
MOVE_TO_FOLDER
|
||||
}
|
||||
|
||||
|
||||
@ -2595,6 +2595,7 @@ const schema = gql`
|
||||
MARK_AS_READ
|
||||
ADD_LABELS
|
||||
MOVE_TO_FOLDER
|
||||
MARK_AS_SEEN
|
||||
}
|
||||
|
||||
union BulkActionResult = BulkActionSuccess | BulkActionError
|
||||
|
||||
@ -1303,6 +1303,11 @@ export const batchUpdateLibraryItems = async (
|
||||
savedAt: now,
|
||||
}
|
||||
|
||||
break
|
||||
case BulkActionType.MarkAsSeen:
|
||||
values = {
|
||||
seenAt: now,
|
||||
}
|
||||
break
|
||||
default:
|
||||
throw new Error('Invalid bulk action')
|
||||
|
||||
@ -2322,6 +2322,51 @@ describe('Article API', () => {
|
||||
expect(response.body.data.search.pageInfo.totalCount).to.eql(0)
|
||||
})
|
||||
})
|
||||
|
||||
context(
|
||||
'when action is MarkAsSeen and query contains a list of item id',
|
||||
() => {
|
||||
const items: LibraryItem[] = []
|
||||
|
||||
before(async () => {
|
||||
// Create some test items
|
||||
for (let i = 0; i < 5; i++) {
|
||||
const item = await createOrUpdateLibraryItem(
|
||||
{
|
||||
user,
|
||||
title: 'test item',
|
||||
slug: '',
|
||||
originalUrl: `https://blog.omnivore.app/p/bulk-action-${i}`,
|
||||
},
|
||||
user.id
|
||||
)
|
||||
|
||||
items.push(item)
|
||||
}
|
||||
})
|
||||
|
||||
after(async () => {
|
||||
// Delete all items
|
||||
await deleteLibraryItemsByUserId(user.id)
|
||||
})
|
||||
|
||||
it('marks items as seen', async () => {
|
||||
const query = `includes:${items.map((i) => i.id).join(',')}`
|
||||
|
||||
const res = await graphqlRequest(
|
||||
bulkActionQuery(BulkActionType.MarkAsSeen, query),
|
||||
authToken
|
||||
).expect(200)
|
||||
expect(res.body.data.bulkAction.success).to.be.true
|
||||
|
||||
const response = await graphqlRequest(
|
||||
searchQuery('is:seen'),
|
||||
authToken
|
||||
).expect(200)
|
||||
expect(response.body.data.search.pageInfo.totalCount).to.eql(5)
|
||||
})
|
||||
}
|
||||
)
|
||||
})
|
||||
|
||||
describe('SetFavoriteArticle API', () => {
|
||||
|
||||
Reference in New Issue
Block a user