mirror of
https://github.com/omnivore-app/omnivore.git
synced 2026-03-11 08:54:26 +00:00
Merge pull request #2704 from omnivore-app/fix/api-subscriptions-query
Fix typo with RSS typed subscription queries
This commit is contained in:
commit
df7ee53e5b
2 changed files with 83 additions and 1 deletions
|
|
@ -83,7 +83,7 @@ export const subscriptionsResolver = authorized<
|
|||
status: SubscriptionStatus.Active,
|
||||
})
|
||||
} else if (type && type == SubscriptionType.Rss) {
|
||||
queryBuilder.where({
|
||||
queryBuilder.andWhere({
|
||||
type,
|
||||
})
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -185,6 +185,88 @@ describe('Subscriptions API', () => {
|
|||
}
|
||||
})
|
||||
|
||||
it('should not return other users subscriptions when type is set to RSS', async () => {
|
||||
query = `
|
||||
query {
|
||||
subscriptions(type: RSS) {
|
||||
... on SubscriptionsSuccess {
|
||||
subscriptions {
|
||||
id
|
||||
name
|
||||
}
|
||||
}
|
||||
... on SubscriptionsError {
|
||||
errorCodes
|
||||
}
|
||||
}
|
||||
}
|
||||
`
|
||||
const user2 = await createTestUser('fakeUser2')
|
||||
try {
|
||||
await createTestSubscription(
|
||||
user2,
|
||||
'sub_other',
|
||||
undefined,
|
||||
SubscriptionStatus.Unsubscribed,
|
||||
undefined,
|
||||
SubscriptionType.Rss
|
||||
)
|
||||
const rssItems = subscriptions.filter(
|
||||
(s) => s.type == SubscriptionType.Rss
|
||||
)
|
||||
const res = await graphqlRequest(query, authToken).expect(200)
|
||||
expect(res.body.data.subscriptions.subscriptions).to.eql(
|
||||
rssItems.map((sub) => ({
|
||||
id: sub.id,
|
||||
name: sub.name,
|
||||
}))
|
||||
)
|
||||
} finally {
|
||||
deleteTestUser(user2.id)
|
||||
}
|
||||
})
|
||||
|
||||
it('should not return other users subscriptions when type is set to NEWSLETTER', async () => {
|
||||
query = `
|
||||
query {
|
||||
subscriptions(type: NEWSLETTER) {
|
||||
... on SubscriptionsSuccess {
|
||||
subscriptions {
|
||||
id
|
||||
name
|
||||
}
|
||||
}
|
||||
... on SubscriptionsError {
|
||||
errorCodes
|
||||
}
|
||||
}
|
||||
}
|
||||
`
|
||||
const user2 = await createTestUser('fakeUser2')
|
||||
try {
|
||||
await createTestSubscription(
|
||||
user2,
|
||||
'sub_other',
|
||||
undefined,
|
||||
SubscriptionStatus.Unsubscribed,
|
||||
undefined,
|
||||
SubscriptionType.Rss
|
||||
)
|
||||
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,
|
||||
}))
|
||||
)
|
||||
} finally {
|
||||
deleteTestUser(user2.id)
|
||||
}
|
||||
})
|
||||
|
||||
it('responds status code 400 when invalid query', async () => {
|
||||
const invalidQuery = `
|
||||
query {
|
||||
|
|
|
|||
Loading…
Reference in a new issue