From: Ruben Beltran del Rio Date: Sun, 2 May 2021 11:37:11 +0000 (+0200) Subject: Add getForum pact, normalize stores X-Git-Url: https://git.r.bdr.sh/rbdr/forum/commitdiff_plain/fcbbc49687afeeecdc9388b367b1d7f2d0c76214?ds=inline Add getForum pact, normalize stores --- diff --git a/pacts/forumsstore-forumapiserver.json b/pacts/forumsstore-forumapiserver.json index 26a2810..c3d2c0d 100644 --- a/pacts/forumsstore-forumapiserver.json +++ b/pacts/forumsstore-forumapiserver.json @@ -65,6 +65,85 @@ } } } + }, + { + "description": "a request to get a single forum", + "request": { + "method": "POST", + "path": "/graphql", + "headers": { + "content-type": "application/json" + }, + "body": { + "operationName": "GetForum", + "query": "query GetForum($id: ID!) {\n forum(id: $id) {\n id\n glyph\n label\n position\n topics {\n id\n title\n updated_at\n ttl\n __typename\n }\n __typename\n }\n }", + "variables": { + "id": "freezer" + } + }, + "matchingRules": { + "$.body.query": { + "match": "regex", + "regex": "query\\s*GetForum\\(\\$id:\\s*ID!\\)\\s*\\{\\s*forum\\(id:\\s*\\$id\\)\\s*\\{\\s*id\\s*glyph\\s*label\\s*position\\s*topics\\s*\\{\\s*id\\s*title\\s*updated_at\\s*ttl\\s*__typename\\s*\\}\\s*__typename\\s*\\}\\s*\\}" + } + } + }, + "response": { + "status": 200, + "headers": { + "Content-Type": "application/json; charset=utf-8" + }, + "body": { + "data": { + "forum": { + "id": "freezer", + "glyph": "✭", + "label": "test_forums.freezer", + "position": 3, + "topics": [ + { + "id": "629de02c-151a-4db7-bb86-43b2add8a15a", + "title": "Very pacty topic", + "updated_at": 1619954611616, + "ttl": 3601 + } + ] + } + } + }, + "matchingRules": { + "$.body.data.forum": { + "match": "type" + }, + "$.body.data.forum.glyph": { + "match": "type" + }, + "$.body.data.forum.label": { + "match": "type" + }, + "$.body.data.forum.position": { + "match": "type" + }, + "$.body.data.forum.topics": { + "min": 1 + }, + "$.body.data.forum.topics[*].*": { + "match": "type" + }, + "$.body.data.forum.topics[*].id": { + "match": "type" + }, + "$.body.data.forum.topics[*].title": { + "match": "type" + }, + "$.body.data.forum.topics[*].updated_at": { + "match": "type" + }, + "$.body.data.forum.topics[*].ttl": { + "match": "type" + } + } + } } ], "metadata": { diff --git a/src/routes/f/[id].svelte b/src/routes/f/[id].svelte index 83afc8a..a92862f 100644 --- a/src/routes/f/[id].svelte +++ b/src/routes/f/[id].svelte @@ -14,7 +14,7 @@ export let id; - import { getForum } from '$/stores/forum'; + import { getForum } from '$/stores/forums'; $: store = getForum(id); $: forum = $store.data; diff --git a/src/routes/g/[id].svelte b/src/routes/g/[id].svelte index 023fbd8..d6a83cd 100644 --- a/src/routes/g/[id].svelte +++ b/src/routes/g/[id].svelte @@ -8,7 +8,7 @@