mirror of
https://github.com/omnivore-app/omnivore.git
synced 2026-03-11 08:54:26 +00:00
Only filter inactive newsletters out from the subscriptions response
This commit is contained in:
parent
3925a7bfeb
commit
89c17fd0ab
2 changed files with 38 additions and 5 deletions
|
|
@ -74,8 +74,17 @@ export const subscriptionsResolver = authorized<
|
|||
.leftJoinAndSelect('subscription.newsletterEmail', 'newsletterEmail')
|
||||
.where({
|
||||
user: { id: uid },
|
||||
})
|
||||
|
||||
// Show all RSS, but only active newsletters
|
||||
queryBuilder
|
||||
.where({
|
||||
type: SubscriptionType.Newsletter,
|
||||
status: SubscriptionStatus.Active,
|
||||
})
|
||||
.orWhere({
|
||||
type: SubscriptionType.Rss,
|
||||
})
|
||||
|
||||
if (type) {
|
||||
queryBuilder.andWhere({
|
||||
|
|
|
|||
|
|
@ -88,11 +88,6 @@ describe('Subscriptions API', () => {
|
|||
|
||||
it('should return subscriptions', async () => {
|
||||
const res = await graphqlRequest(query, authToken).expect(200)
|
||||
console.log(
|
||||
'test subscriptions: ',
|
||||
res.body.data.subscriptions.subscriptions
|
||||
)
|
||||
|
||||
expect(res.body.data.subscriptions.subscriptions).to.eql(
|
||||
subscriptions.map((sub) => ({
|
||||
id: sub.id,
|
||||
|
|
@ -101,6 +96,35 @@ describe('Subscriptions API', () => {
|
|||
)
|
||||
})
|
||||
|
||||
it('should return only newsletters when type newsletter supplied', async () => {
|
||||
query = `
|
||||
query {
|
||||
subscriptions(type: NEWSLETTER) {
|
||||
... on SubscriptionsSuccess {
|
||||
subscriptions {
|
||||
id
|
||||
name
|
||||
}
|
||||
}
|
||||
... on SubscriptionsError {
|
||||
errorCodes
|
||||
}
|
||||
}
|
||||
}
|
||||
`
|
||||
const newsletters = subscriptions.filter(
|
||||
(s) => s.type == SubscriptionType.Newsletter
|
||||
)
|
||||
const res = await graphqlRequest(query, authToken).expect(200)
|
||||
|
||||
expect(res.body.data.subscriptions.subscriptions).to.eql(
|
||||
newsletters.map((sub) => ({
|
||||
id: sub.id,
|
||||
name: sub.name,
|
||||
}))
|
||||
)
|
||||
})
|
||||
|
||||
it('responds status code 400 when invalid query', async () => {
|
||||
const invalidQuery = `
|
||||
query {
|
||||
|
|
|
|||
Loading…
Reference in a new issue