From 8684fb14e475304683a86b479b152b240b933314 Mon Sep 17 00:00:00 2001 From: Avior Date: Wed, 3 Jan 2024 23:42:56 +0100 Subject: [PATCH] feat: Add bruno to tests the APIs (#468) --- .bruno/GraphQL API.bru | 33 +++++++++++++++++++++ .bruno/Validate that we can run OPTIONS.bru | 15 ++++++++++ .bruno/bruno.json | 8 +++++ .bruno/cards/get Card list.bru | 27 +++++++++++++++++ .bruno/cards/get one card.bru | 15 ++++++++++ .bruno/environments/Developpement.bru | 3 ++ .bruno/environments/Production.bru | 3 ++ .bruno/fixes/invalid sorting.bru | 22 ++++++++++++++ .bruno/sets/get a set.bru | 15 ++++++++++ .bruno/sets/get list of sets.bru | 23 ++++++++++++++ .bruno/sets/get one card from a set.bru | 15 ++++++++++ 11 files changed, 179 insertions(+) create mode 100644 .bruno/GraphQL API.bru create mode 100644 .bruno/Validate that we can run OPTIONS.bru create mode 100644 .bruno/bruno.json create mode 100644 .bruno/cards/get Card list.bru create mode 100644 .bruno/cards/get one card.bru create mode 100644 .bruno/environments/Developpement.bru create mode 100644 .bruno/environments/Production.bru create mode 100644 .bruno/fixes/invalid sorting.bru create mode 100644 .bruno/sets/get a set.bru create mode 100644 .bruno/sets/get list of sets.bru create mode 100644 .bruno/sets/get one card from a set.bru diff --git a/.bruno/GraphQL API.bru b/.bruno/GraphQL API.bru new file mode 100644 index 000000000..cc1ec38df --- /dev/null +++ b/.bruno/GraphQL API.bru @@ -0,0 +1,33 @@ +meta { + name: GraphQL API + type: graphql + seq: 2 +} + +post { + url: {{BASE_URL}}/v2/graphql + body: graphql + auth: none +} + +body:graphql { + query Pouet { + cards { + id + localId + name + set { + id + name + serie { + id + name + } + } + } + } +} + +assert { + res.status: eq 200 +} diff --git a/.bruno/Validate that we can run OPTIONS.bru b/.bruno/Validate that we can run OPTIONS.bru new file mode 100644 index 000000000..6554c41fa --- /dev/null +++ b/.bruno/Validate that we can run OPTIONS.bru @@ -0,0 +1,15 @@ +meta { + name: Validate that we can run OPTIONS + type: http + seq: 1 +} + +options { + url: {{BASE_URL}}/status + body: none + auth: none +} + +assert { + res.status: eq 200 +} diff --git a/.bruno/bruno.json b/.bruno/bruno.json new file mode 100644 index 000000000..477bb886e --- /dev/null +++ b/.bruno/bruno.json @@ -0,0 +1,8 @@ +{ + "version": "1", + "name": "TCGdex", + "type": "collection", + "presets": { + "requestType": "http" + } +} diff --git a/.bruno/cards/get Card list.bru b/.bruno/cards/get Card list.bru new file mode 100644 index 000000000..a441b7ea8 --- /dev/null +++ b/.bruno/cards/get Card list.bru @@ -0,0 +1,27 @@ +meta { + name: get Card list + type: http + seq: 1 +} + +get { + url: {{BASE_URL}}/v2/en/cards?sort:field=name&sort:order=DESC&pagination:page=1&pagination:itemsPerPage=4 + body: none + auth: none +} + +query { + sort:field: name + sort:order: DESC + pagination:page: 1 + pagination:itemsPerPage: 4 + ~name: furret +} + +docs { + Fully describe the card list request, it also has every parameters it can +} + +assert { + res.status: eq 200 +} diff --git a/.bruno/cards/get one card.bru b/.bruno/cards/get one card.bru new file mode 100644 index 000000000..d7bf56429 --- /dev/null +++ b/.bruno/cards/get one card.bru @@ -0,0 +1,15 @@ +meta { + name: get one card + type: http + seq: 2 +} + +get { + url: {{BASE_URL}}/v2/en/cards/swsh3-136 + body: none + auth: none +} + +assert { + res.status: eq 200 +} diff --git a/.bruno/environments/Developpement.bru b/.bruno/environments/Developpement.bru new file mode 100644 index 000000000..fa6654ac8 --- /dev/null +++ b/.bruno/environments/Developpement.bru @@ -0,0 +1,3 @@ +vars { + BASE_URL: http://localhost:3000 +} diff --git a/.bruno/environments/Production.bru b/.bruno/environments/Production.bru new file mode 100644 index 000000000..ad781db5e --- /dev/null +++ b/.bruno/environments/Production.bru @@ -0,0 +1,3 @@ +vars { + BASE_URL: https://api.tcgdex.net +} diff --git a/.bruno/fixes/invalid sorting.bru b/.bruno/fixes/invalid sorting.bru new file mode 100644 index 000000000..0fc593d7c --- /dev/null +++ b/.bruno/fixes/invalid sorting.bru @@ -0,0 +1,22 @@ +meta { + name: invalid sorting + type: http + seq: 1 +} + +get { + url: {{BASE_URL}}/v2/en/sets/swsh8/53 + body: none + auth: none +} + +assert { + res.body.id: eq swsh8-53 + res.status: eq 200 +} + +docs { + Validate the issue seen in + + https://github.com/tcgdex/cards-database/issues/466 +} diff --git a/.bruno/sets/get a set.bru b/.bruno/sets/get a set.bru new file mode 100644 index 000000000..5f3200b37 --- /dev/null +++ b/.bruno/sets/get a set.bru @@ -0,0 +1,15 @@ +meta { + name: get a set + type: http + seq: 2 +} + +get { + url: {{BASE_URL}}/v2/en/sets/swsh3 + body: none + auth: none +} + +assert { + res.status: eq 200 +} diff --git a/.bruno/sets/get list of sets.bru b/.bruno/sets/get list of sets.bru new file mode 100644 index 000000000..da9b7823f --- /dev/null +++ b/.bruno/sets/get list of sets.bru @@ -0,0 +1,23 @@ +meta { + name: get list of sets + type: http + seq: 3 +} + +get { + url: {{BASE_URL}}/v2/en/sets?sort:field=name&sort:order=DESC&pagination:page=1&pagination:itemsPerPage=1&name=Dark + body: none + auth: none +} + +query { + sort:field: name + sort:order: DESC + pagination:page: 1 + pagination:itemsPerPage: 1 + name: Dark +} + +assert { + res.status: eq 200 +} diff --git a/.bruno/sets/get one card from a set.bru b/.bruno/sets/get one card from a set.bru new file mode 100644 index 000000000..c1169d1cd --- /dev/null +++ b/.bruno/sets/get one card from a set.bru @@ -0,0 +1,15 @@ +meta { + name: get one card from a set + type: http + seq: 1 +} + +get { + url: {{BASE_URL}}/v2/en/cards/swsh3 + body: none + auth: none +} + +assert { + res.status: eq 200 +}