Skip to content

Commit

Permalink
chore(notifications): initial e2e workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
bodymindarts committed Jan 11, 2024
1 parent 863b854 commit 4909e41
Show file tree
Hide file tree
Showing 7 changed files with 101 additions and 16 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/bats.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ jobs:
- name: Buck2 build
run: |
nix develop -c buck2 build //core/api //core/api-ws-server \
//core/api-keys //apps/dashboard //apps/consent //apps/pay
//core/api-keys //apps/dashboard //apps/consent //apps/pay \
//core/notifications
- name: Run bats tests
run: |
nix develop -c bats --setup-suite-file bats/ci_setup_suite.bash -t bats/core/**
Expand Down
22 changes: 22 additions & 0 deletions bats/core/notifications/notifications.bats
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/usr/bin/env bats

load "../../helpers/_common.bash"
load "../../helpers/user.bash"

setup_file() {
clear_cache

create_user 'alice'
}

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

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

exec_graphql "$token_name" 'account-disable-notification-channel-alt' "$variables"
channel_enabled="$(graphql_output '.data.accountDisableNotificationChannelAlt.notificationSettings.push.enabled')"
[[ "$channel_enabled" == "false" ]] || exit 1
}
10 changes: 10 additions & 0 deletions bats/gql/account-disable-notification-channel-alt.gql
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
mutation accountDisableNotificationChannel($input: AccountDisableNotificationChannelInputAlt!) {
accountDisableNotificationChannelAlt(input: $input) {
notificationSettings {
push {
enabled
disabledCategories
}
}
}
}
24 changes: 16 additions & 8 deletions core/notifications/src/graphql/schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,22 +24,23 @@ struct ConsumerAccount {
#[graphql(external)]
id: ID,
}
#[ComplexObject]
impl ConsumerAccount {}

#[derive(SimpleObject)]
pub struct AccountUpdateNotificationSettingsPayloadAlt {
dummy: String,
notification_settings: NotificationSettingsAlt,
}

#[derive(SimpleObject)]
pub struct NotificationSettingsAlt {
hello: String,
push: NotificationChannelSettingsAlt,
}

#[ComplexObject]
impl ConsumerAccount {
async fn notification_settings_alt(&self) -> NotificationSettingsAlt {
unimplemented!()
}
#[derive(SimpleObject)]
pub struct NotificationChannelSettingsAlt {
enabled: bool,
disabled_categories: Vec<String>,
}

#[derive(InputObject)]
Expand All @@ -61,6 +62,13 @@ impl Mutation {
if subject.read_only {
return Err("Permission denied".into());
}
unimplemented!()
Ok(AccountUpdateNotificationSettingsPayloadAlt {
notification_settings: NotificationSettingsAlt {
push: NotificationChannelSettingsAlt {
enabled: false,
disabled_categories: vec![],
},
},
})
}
}
23 changes: 20 additions & 3 deletions core/notifications/subgraph/schema.graphql
Original file line number Diff line number Diff line change
@@ -1,13 +1,30 @@
input AccountDisableNotificationChannelInputAlt {
channel: String!
}

type AccountUpdateNotificationSettingsPayloadAlt {
notificationSettings: NotificationSettingsAlt!
}


extend type ConsumerAccount @key(fields: "id") {
id: ID! @external
notificationSettings: NotificationSettings!
}




type NotificationSettings {
hello: String!
type Mutation {
accountDisableNotificationChannelAlt(input: AccountDisableNotificationChannelInputAlt!): AccountUpdateNotificationSettingsPayloadAlt!
}

type NotificationChannelSettingsAlt {
enabled: Boolean!
disabledCategories: [String!]!
}

type NotificationSettingsAlt {
push: NotificationChannelSettingsAlt!
}


Expand Down
21 changes: 21 additions & 0 deletions dev/Tiltfile
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,25 @@ local_resource(
]
)

notifications_target = "//core/notifications:notifications"
local_resource(
"notifications",
labels = ["core"],
cmd = "buck2 build {}".format(notifications_target),
serve_cmd = "buck2 run {}".format(notifications_target),
serve_env = {
"PG_CON": "postgres://user:password@localhost:5433/pg",
"NOTIFICATIONS_CONFIG": "../core/notifications/notifications.yml",
"OTEL_EXPORTER_OTLP_ENDPOINT": "http://localhost:4317",
},
deps = _buck2_dep_inputs(notifications_target),
allow_parallel = True,
resource_deps = [
"api",
"notifications-pg"
]
)

local_resource(
name='init-onchain',
labels = ['bitcoin'],
Expand Down Expand Up @@ -427,6 +446,8 @@ docker_groups = {
"core": [
"apollo-router",
"mongodb",
"notifications-pg",
"oathkeeper",
"redis",
"stablesats",
"svix-pg",
Expand Down
14 changes: 10 additions & 4 deletions dev/config/apollo-federation/supergraph.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ type AccountUpdateNotificationSettingsPayload
type AccountUpdateNotificationSettingsPayloadAlt
@join__type(graph: NOTIFICATIONS)
{
dummy: String!
notificationSettings: NotificationSettingsAlt!
}

type ApiKey
Expand Down Expand Up @@ -384,7 +384,6 @@ type ConsumerAccount implements Account
@join__type(graph: PUBLIC)
{
id: ID!
notificationSettingsAlt: NotificationSettingsAlt! @join__field(graph: NOTIFICATIONS)
callbackEndpoints: [CallbackEndpoint!]! @join__field(graph: PUBLIC)

"""
Expand Down Expand Up @@ -717,7 +716,7 @@ scalar join__FieldSet

enum join__Graph {
API_KEYS @join__graph(name: "api_keys", url: "http://bats-tests:5397/graphql")
NOTIFICATIONS @join__graph(name: "notifications", url: "http://bats-tests:5399/graphql")
NOTIFICATIONS @join__graph(name: "notifications", url: "http://bats-tests:6684/graphql")
PUBLIC @join__graph(name: "public", url: "http://bats-tests:4012/graphql")
}

Expand Down Expand Up @@ -1237,6 +1236,13 @@ type NotificationChannelSettings
enabled: Boolean!
}

type NotificationChannelSettingsAlt
@join__type(graph: NOTIFICATIONS)
{
enabled: Boolean!
disabledCategories: [String!]!
}

type NotificationSettings
@join__type(graph: PUBLIC)
{
Expand All @@ -1246,7 +1252,7 @@ type NotificationSettings
type NotificationSettingsAlt
@join__type(graph: NOTIFICATIONS)
{
hello: String!
push: NotificationChannelSettingsAlt!
}

"""An address for an on-chain bitcoin destination"""
Expand Down

0 comments on commit 4909e41

Please sign in to comment.