Skip to content

Commit

Permalink
test: get e2e tests working
Browse files Browse the repository at this point in the history
  • Loading branch information
UncleSamtoshi committed Sep 19, 2023
1 parent deb5cb9 commit 337cffe
Show file tree
Hide file tree
Showing 8 changed files with 122 additions and 55 deletions.
17 changes: 8 additions & 9 deletions src/services/mongoose/accounts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -227,15 +227,14 @@ const translateToAccount = (result: AccountRecord): Account => ({
),
withdrawFee: result.withdrawFee as Satoshis,
isEditor: result.role === "editor",
notificationSettings:
result.notificationSettings ||
({
push: {
enabled: true,
disabledCategories: [],
},
} as NotificationSettings),

notificationSettings: {
push: {
enabled: result.notificationSettings
? result.notificationSettings.push.enabled
: true,
disabledCategories: result.notificationSettings?.push?.disabledCategories || [],
},
},
// TODO: remove
quizQuestions:
result.earn?.map(
Expand Down
15 changes: 15 additions & 0 deletions test/bats/gql/account-disable-notification-category.gql
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
mutation accountDisableNotificationCategory($input: AccountDisableNotificationCategoryInput!) {
accountDisableNotificationCategory(input: $input) {
errors {
message
}
account {
notificationSettings {
push {
enabled
disabledCategories
}
}
}
}
}
15 changes: 15 additions & 0 deletions test/bats/gql/account-disable-notification-channel.gql
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
mutation accountDisableNotificationChannel($input: AccountDisableNotificationChannelInput!) {
accountDisableNotificationChannel(input: $input) {
errors {
message
}
account {
notificationSettings {
push {
enabled
disabledCategories
}
}
}
}
}
15 changes: 15 additions & 0 deletions test/bats/gql/account-enable-notification-category.gql
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
mutation accountEnableNotificationCategory($input: AccountEnableNotificationCategoryInput!) {
accountEnableNotificationCategory(input: $input) {
errors {
message
}
account {
notificationSettings {
push {
enabled
disabledCategories
}
}
}
}
}
15 changes: 15 additions & 0 deletions test/bats/gql/account-enable-notification-channel.gql
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
mutation accountEnableNotificationChannel($input: AccountEnableNotificationChannelInput!) {
accountEnableNotificationChannel(input: $input) {
errors {
message
}
account {
notificationSettings {
push {
enabled
disabledCategories
}
}
}
}
}
13 changes: 0 additions & 13 deletions test/bats/gql/account-update-push-notification-settings.gql

This file was deleted.

54 changes: 54 additions & 0 deletions test/bats/notification-settings.bats
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#!/usr/bin/env bats

load "helpers/setup-and-teardown"

setup_file() {
clear_cache
reset_redis

bitcoind_init
start_trigger
start_server

initialize_user_from_onchain "$ALICE_TOKEN_NAME" "$ALICE_PHONE" "$CODE"
}

teardown_file() {
stop_trigger
stop_server
}


@test "notification-settings: disable/enable notification channel" {
token_name="$ALICE_TOKEN_NAME"

variables=$(
jq -n \
'{input: { channel: "PUSH" }}')

exec_graphql "$token_name" 'account-disable-notification-channel' "$variables"
channel_enabled="$(graphql_output '.data.accountDisableNotificationChannel.account.notificationSettings.push.enabled')"
[[ "$channel_enabled" == "false" ]] || exit 1

exec_graphql "$token_name" 'account-enable-notification-channel' "$variables"

channel_enabled="$(graphql_output '.data.accountEnableNotificationChannel.account.notificationSettings.push.enabled')"
[[ "$channel_enabled" == "true" ]] || exit 1
}

@test "notification-settings: disable/enable notification category" {
token_name="$ALICE_TOKEN_NAME"

variables=$(
jq -n \
'{input: { channel: "PUSH", category: "Circles" }}')

exec_graphql "$token_name" 'account-disable-notification-category' "$variables"
disabled_category="$(graphql_output '.data.accountDisableNotificationCategory.account.notificationSettings.push.disabledCategories[0]')"
[[ "$disabled_category" == "Circles" ]] || exit 1

exec_graphql "$token_name" 'account-enable-notification-category' "$variables"

disabled_length="$(graphql_output '.data.accountEnableNotificationCategory.account.notificationSettings.push.disabledCategories | length')"
[[ "$disabled_length" == "0" ]] || exit 1
}
33 changes: 0 additions & 33 deletions test/bats/push-notification-settings.bats

This file was deleted.

0 comments on commit 337cffe

Please sign in to comment.