add test for when in:trash is:unread is in the query

This commit is contained in:
Hongbo Wu 2023-09-20 16:01:45 +08:00
parent c57ead3583
commit f3db9345ae

View file

@ -1136,58 +1136,104 @@ describe('Article API', () => {
})
})
context(
'when rss:feed in:archive is in the query',
() => {
let items: LibraryItem[] = []
context('when rss:feed in:archive is in the query', () => {
let items: LibraryItem[] = []
before(async () => {
keyword = 'rss:feed in:archive'
// Create some test items
items = await createLibraryItems(
[
{
user,
title: 'test title 1',
readableContent: '<p>test 1</p>',
slug: 'test slug 1',
originalUrl: `${url}/test1`,
archivedAt: new Date(),
subscription: 'feed',
},
{
user,
title: 'test title 2',
readableContent: '<p>test 2</p>',
slug: 'test slug 2',
originalUrl: `${url}/test2`,
subscription: 'feed',
},
{
user,
title: 'test title 3',
readableContent: '<p>test 3</p>',
slug: 'test slug 3',
originalUrl: `${url}/test3`,
archivedAt: new Date(),
},
],
user.id
)
})
before(async () => {
keyword = 'rss:feed in:archive'
// Create some test items
items = await createLibraryItems(
[
{
user,
title: 'test title 1',
readableContent: '<p>test 1</p>',
slug: 'test slug 1',
originalUrl: `${url}/test1`,
archivedAt: new Date(),
subscription: 'feed',
},
{
user,
title: 'test title 2',
readableContent: '<p>test 2</p>',
slug: 'test slug 2',
originalUrl: `${url}/test2`,
subscription: 'feed',
},
{
user,
title: 'test title 3',
readableContent: '<p>test 3</p>',
slug: 'test slug 3',
originalUrl: `${url}/test3`,
archivedAt: new Date(),
},
],
user.id
)
})
after(async () => {
await deleteLibraryItems(items, user.id)
})
after(async () => {
await deleteLibraryItems(items, user.id)
})
it('returns archived feed items', async () => {
const res = await graphqlRequest(query, authToken).expect(200)
it('returns archived feed items', async () => {
const res = await graphqlRequest(query, authToken).expect(200)
expect(res.body.data.search.pageInfo.totalCount).to.eq(1)
expect(res.body.data.search.edges[0].node.id).to.eq(items[0].id)
})
}
)
expect(res.body.data.search.pageInfo.totalCount).to.eq(1)
expect(res.body.data.search.edges[0].node.id).to.eq(items[0].id)
})
})
context('when in:trash is:unread is in the query', () => {
let items: LibraryItem[] = []
before(async () => {
keyword = 'in:trash is:unread'
// Create some test items
items = await createLibraryItems(
[
{
user,
title: 'test title 1',
readableContent: '<p>test 1</p>',
slug: 'test slug 1',
originalUrl: `${url}/test1`,
deletedAt: new Date(),
},
{
user,
title: 'test title 2',
readableContent: '<p>test 2</p>',
slug: 'test slug 2',
originalUrl: `${url}/test2`,
deletedAt: new Date(),
readingProgressTopPercent: 100,
},
{
user,
title: 'test title 3',
readableContent: '<p>test 3</p>',
slug: 'test slug 3',
originalUrl: `${url}/test3`,
},
],
user.id
)
})
after(async () => {
await deleteLibraryItems(items, user.id)
})
it('returns unfinished deleted items', async () => {
const res = await graphqlRequest(query, authToken).expect(200)
expect(res.body.data.search.pageInfo.totalCount).to.eq(1)
expect(res.body.data.search.edges[0].node.id).to.eq(items[0].id)
})
})
})
describe('TypeaheadSearch API', () => {