From 4afff9ada2c07bf8e5d25c0388632b3e8562bfdd Mon Sep 17 00:00:00 2001 From: Arvin <17693119+vindard@users.noreply.github.com> Date: Tue, 9 Jan 2024 09:27:36 -0400 Subject: [PATCH] test(core): move invoices bats tests (#3800) --- .../test/bats => bats/core/api}/invoices.bats | 35 ++++++------------- bats/gql/invoices-by-wallet.gql | 27 ++++++++++++++ bats/gql/invoices.gql | 25 +++++++++++++ 3 files changed, 62 insertions(+), 25 deletions(-) rename {core/api/test/bats => bats/core/api}/invoices.bats (77%) create mode 100644 bats/gql/invoices-by-wallet.gql create mode 100644 bats/gql/invoices.gql diff --git a/core/api/test/bats/invoices.bats b/bats/core/api/invoices.bats similarity index 77% rename from core/api/test/bats/invoices.bats rename to bats/core/api/invoices.bats index 5d39f56343..8e5dd2a7c5 100644 --- a/core/api/test/bats/invoices.bats +++ b/bats/core/api/invoices.bats @@ -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)" \ @@ -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}' @@ -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=$( @@ -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 -} diff --git a/bats/gql/invoices-by-wallet.gql b/bats/gql/invoices-by-wallet.gql new file mode 100644 index 0000000000..7deb404b5d --- /dev/null +++ b/bats/gql/invoices-by-wallet.gql @@ -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 + } + } +} diff --git a/bats/gql/invoices.gql b/bats/gql/invoices.gql new file mode 100644 index 0000000000..9086c64ce2 --- /dev/null +++ b/bats/gql/invoices.gql @@ -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 + } + } +}