Skip to content

Commit

Permalink
test(core): move invoices bats tests (#3800)
Browse files Browse the repository at this point in the history
  • Loading branch information
vindard authored Jan 9, 2024
1 parent 4232a5b commit 4afff9a
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 25 deletions.
35 changes: 10 additions & 25 deletions core/api/test/bats/invoices.bats → bats/core/api/invoices.bats
Original file line number Diff line number Diff line change
@@ -1,25 +1,22 @@
#!/usr/bin/env bats

load "helpers/setup-and-teardown"
load "helpers/ln"
load "../../helpers/_common.bash"
load "../../helpers/user.bash"

setup_file() {
clear_cache

bitcoind_init
start_trigger
start_server
start_ws_server
start_exporter
create_user 'alice'
seed_invoices
}

lnds_init
login_user "$ALICE_TOKEN_NAME" "$ALICE_PHONE" "$CODE"
seed_invoices() {
token_name='alice'

token_name="$ALICE_TOKEN_NAME"
# Generate btc invoice
btc_wallet_name="$token_name.btc_wallet_id"
btc_amount="1000"

# Generate btc invoice
variables=$(
jq -n \
--arg wallet_id "$(read_value $btc_wallet_name)" \
Expand All @@ -43,7 +40,7 @@ setup_file() {
}

@test "invoices: get invoices for account" {
token_name="$ALICE_TOKEN_NAME"
token_name='alice'

exec_graphql "$token_name" 'invoices' '{"first": 3}'

Expand All @@ -52,7 +49,7 @@ setup_file() {
}

@test "invoices: get invoices for wallet" {
token_name="$ALICE_TOKEN_NAME"
token_name='alice'
btc_wallet_name="$token_name.btc_wallet_id"

variables=$(
Expand All @@ -65,15 +62,3 @@ setup_file() {
invoice_count="$(graphql_output '.data.me.defaultAccount.walletById.invoices.edges | length')"
[[ "$invoice_count" -eq "2" ]] || exit 1
}


teardown_file() {
stop_trigger
stop_server
stop_ws_server
stop_exporter
}

setup() {
reset_redis
}
27 changes: 27 additions & 0 deletions bats/gql/invoices-by-wallet.gql
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
query invoicesForWallet($walletId: WalletId!, $first: Int, $after: String) {
me {
defaultAccount {
id
displayCurrency
walletById(walletId: $walletId) {
id
invoices(first: $first, after: $after) {
...InvoiceList
}
}
}
}
}

fragment InvoiceList on InvoiceConnection {
pageInfo {
hasNextPage
}
edges {
cursor
node {
__typename
paymentHash
}
}
}
25 changes: 25 additions & 0 deletions bats/gql/invoices.gql
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
query invoices($walletIds: [WalletId], $first: Int, $after: String) {
me {
defaultAccount {
defaultWallet {
id
}
invoices(walletIds: $walletIds, first: $first, after: $after) {
...InvoiceList
}
}
}
}

fragment InvoiceList on InvoiceConnection {
pageInfo {
hasNextPage
}
edges {
cursor
node {
__typename
paymentHash
}
}
}

0 comments on commit 4afff9a

Please sign in to comment.