Skip to content

Commit

Permalink
test: stateful notifications without bulletin
Browse files Browse the repository at this point in the history
  • Loading branch information
sandipndev committed May 10, 2024
1 parent 98ae394 commit d859ac6
Show file tree
Hide file tree
Showing 2 changed files with 81 additions and 0 deletions.
62 changes: 62 additions & 0 deletions bats/core/notifications/notifications.bats
Original file line number Diff line number Diff line change
Expand Up @@ -180,3 +180,65 @@ setup_file() {
[[ "${first_id}" != "${second_id}" ]] || exit 1
[[ "$next_page" = "false" ]] || exit 1
}

@test "notifications: list stateful notifications without bulletin enabled" {
local n_notifications
exec_graphql 'alice' 'list-stateful-notifications-without-bulletin-enabled'
n_notifications=$(graphql_output '.data.me.listStatefulNotificationsWithoutBulletinEnabled.nodes | length')
[[ $n_bulletins -eq 0 ]] || exit 1

admin_token="$(read_value 'admin.token')"

variables=$(
jq -n \
'{
input: {
localizedNotificationContents: [
{
language: "en",
title: "Test title",
body: "test body"
}
],
shouldSendPush: false,
shouldAddToHistory: true,
shouldAddToBulletin: false,
}
}'
)

# trigger two marketing notification
exec_admin_graphql "$admin_token" 'marketing-notification-trigger' "$variables"
exec_admin_graphql "$admin_token" 'marketing-notification-trigger' "$variables"

for i in {1..10}; do
exec_graphql 'alice' 'list-stateful-notifications-without-bulletin-enabled'
n_notifications=$(graphql_output '.data.me.listStatefulNotificationsWithoutBulletinEnabled.nodes | length')
[[ $n_notifications -eq 2 ]] && break;
sleep 1
done
[[ $n_notifications -eq 2 ]] || exit 1;
}

@test "notifications: list stateful notifications without bulletin enabled paginated with cursor" {
exec_graphql 'alice' 'list-stateful-notifications-without-bulletin-enabled' '{"first": 1}'
n_notifications=$(graphql_output '.data.me.listStatefulNotificationsWithoutBulletinEnabled.nodes | length')
first_id=$(graphql_output '.data.me.listStatefulNotificationsWithoutBulletinEnabled.nodes[0].id')
cursor=$(graphql_output '.data.me.listStatefulNotificationsWithoutBulletinEnabled.pageInfo.endCursor')
next_page=$(graphql_output '.data.me.listStatefulNotificationsWithoutBulletinEnabled.pageInfo.hasNextPage')
[[ $n_notifications -eq 1 ]] || exit 1
[[ "$next_page" = "true" ]] || exit 1

variables=$(
jq -n \
--arg after "${cursor}" \
'{first: 1, after: $after}'
)
exec_graphql 'alice' 'list-stateful-notifications-without-bulletin-enabled' "$variables"
n_notifications=$(graphql_output '.data.me.listStatefulNotificationsWithoutBulletinEnabled.nodes | length')
second_id=$(graphql_output '.data.me.listStatefulNotificationsWithoutBulletinEnabled.nodes[0].id')
next_page=$(graphql_output '.data.me.listStatefulNotificationsWithoutBulletinEnabled.pageInfo.hasNextPage')
[[ $n_notifications -eq 1 ]] || exit 1
[[ "${first_id}" != "${second_id}" ]] || exit 1
[[ "$next_page" = "false" ]] || exit 1
}
19 changes: 19 additions & 0 deletions bats/gql/list-stateful-notifications-without-bulletin-enabled.gql
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
query listStatefulNotificationsWithoutBulletinEnabled($first: Int = 2, $after: String = null) {
me {
id
statefulNotifications(first: $first, after: $after) {
pageInfo {
endCursor
hasNextPage
}
nodes {
id
body
title
deepLink
acknowledgedAt
createdAt
}
}
}
}

0 comments on commit d859ac6

Please sign in to comment.