mirror of
https://github.com/omnivore-app/omnivore.git
synced 2026-03-11 08:54:26 +00:00
Add test case for deleteLabel
This commit is contained in:
parent
0d67d0fb90
commit
a981e13c86
2 changed files with 29 additions and 2 deletions
|
|
@ -286,7 +286,7 @@ export const deleteLabelForHighlights = async (
|
|||
path: 'highlights',
|
||||
query: {
|
||||
nested: {
|
||||
path: 'labels',
|
||||
path: 'highlights.labels',
|
||||
query: {
|
||||
term: {
|
||||
'highlights.labels.name': label,
|
||||
|
|
|
|||
|
|
@ -14,7 +14,10 @@ import { getRepository } from '../../src/entity/utils'
|
|||
import { getPageById } from '../../src/elastic/pages'
|
||||
import { addLabelInPage } from '../../src/elastic/labels'
|
||||
import { createPubSubClient } from '../../src/datalayer/pubsub'
|
||||
import { addHighlightToPage } from '../../src/elastic/highlights'
|
||||
import {
|
||||
addHighlightToPage,
|
||||
getHighlightById,
|
||||
} from '../../src/elastic/highlights'
|
||||
|
||||
describe('Labels API', () => {
|
||||
const username = 'fakeUser'
|
||||
|
|
@ -239,6 +242,30 @@ describe('Labels API', () => {
|
|||
expect(updatedPage?.labels).not.to.include(toDeleteLabel)
|
||||
})
|
||||
})
|
||||
|
||||
context('when a highlight has this label', () => {
|
||||
const highlightId = 'testDeleteLabel'
|
||||
|
||||
before(async () => {
|
||||
const highlight: Highlight = {
|
||||
id: highlightId,
|
||||
patch: 'test patch',
|
||||
quote: 'test quote',
|
||||
shortId: 'test shortId',
|
||||
userId: user.id,
|
||||
createdAt: new Date(),
|
||||
labels: [toDeleteLabel],
|
||||
}
|
||||
await addHighlightToPage(page.id, highlight, ctx)
|
||||
})
|
||||
|
||||
it('should update highlight', async () => {
|
||||
await graphqlRequest(query, authToken).expect(200)
|
||||
const updatedHighlight = await getHighlightById(highlightId)
|
||||
|
||||
expect(updatedHighlight?.labels).not.to.include(toDeleteLabel)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
context('when label not exist', () => {
|
||||
|
|
|
|||
Loading…
Reference in a new issue