Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(notifications): finish migrating gql functionality #3821

Merged
merged 5 commits into from
Jan 12, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 31 additions & 2 deletions bats/core/notifications/notifications.bats
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,36 @@ setup_file() {
jq -n \
'{input: { channel: "PUSH" }}')

exec_graphql "$token_name" 'account-disable-notification-channel-alt' "$variables"
channel_enabled="$(graphql_output '.data.accountDisableNotificationChannelAlt.notificationSettings.push.enabled')"
exec_graphql "$token_name" 'user-disable-notification-channel' "$variables"
channel_enabled="$(graphql_output '.data.userDisableNotificationChannel.notificationSettings.push.enabled')"

[[ "$channel_enabled" == "false" ]] || exit 1

# Ensure notification settings exist on user
exec_graphql "$token_name" 'user-notification-settings'
user_channel_enabled="$(graphql_output '.data.me.notificationSettings.push.enabled')"

[[ "$user_channel_enabled" == "false" ]] || exit 1


exec_graphql "$token_name" 'user-enable-notification-channel' "$variables"
channel_enabled="$(graphql_output '.data.userEnableNotificationChannel.notificationSettings.push.enabled')"
[[ "$channel_enabled" == "true" ]] || exit 1
}

@test "notifications: disable/enable notification category" {
token_name='alice'

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

exec_graphql "$token_name" 'user-disable-notification-category' "$variables"
disabled_category="$(graphql_output '.data.userDisableNotificationCategory.notificationSettings.push.disabledCategories[0]')"

[[ "$disabled_category" == "CIRCLES" ]] || exit 1

exec_graphql "$token_name" 'user-enable-notification-category' "$variables"
disabled_length="$(graphql_output '.data.userEnableNotificationCategory.notificationSettings.push.disabledCategories | length')"
[[ "$disabled_length" == "0" ]] || exit 1
}
10 changes: 0 additions & 10 deletions bats/gql/account-disable-notification-channel-alt.gql

This file was deleted.

12 changes: 12 additions & 0 deletions bats/gql/user-disable-notification-category.gql
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
mutation userDisableNotificationCategory(
$input: UserDisableNotificationCategoryInput!
) {
userDisableNotificationCategory(input: $input) {
notificationSettings {
push {
enabled
disabledCategories
}
}
}
}
12 changes: 12 additions & 0 deletions bats/gql/user-disable-notification-channel.gql
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
mutation userDisableNotificationChannel(
$input: UserDisableNotificationChannelInput!
) {
userDisableNotificationChannel(input: $input) {
notificationSettings {
push {
enabled
disabledCategories
}
}
}
}
12 changes: 12 additions & 0 deletions bats/gql/user-enable-notification-category.gql
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
mutation userEnableNotificationCategory(
$input: UserEnableNotificationCategoryInput!
) {
userEnableNotificationCategory(input: $input) {
notificationSettings {
push {
enabled
disabledCategories
}
}
}
}
12 changes: 12 additions & 0 deletions bats/gql/user-enable-notification-channel.gql
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
mutation userEnableNotificationChannel(
$input: UserEnableNotificationChannelInput!
) {
userEnableNotificationChannel(input: $input) {
notificationSettings {
push {
enabled
disabledCategories
}
}
}
}
10 changes: 10 additions & 0 deletions bats/gql/user-notification-settings.gql
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
query userNotificationSettings {
me {
id
notificationSettings {
push {
enabled
}
}
}
}

This file was deleted.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
CREATE TABLE account_notification_settings (
CREATE TABLE user_notification_settings (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
galoy_account_id VARCHAR UNIQUE NOT NULL,
galoy_user_id VARCHAR UNIQUE NOT NULL,
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW()
);

CREATE TABLE account_notification_settings_events (
id UUID REFERENCES account_notification_settings(id) NOT NULL,
CREATE TABLE user_notification_settings_events (
id UUID REFERENCES user_notification_settings(id) NOT NULL,
sequence INT NOT NULL,
event_type VARCHAR NOT NULL,
event JSONB NOT NULL,
Expand Down
Loading
Loading