diff --git a/test/integration/4_schema_usage_graphql_queries.feature b/test/integration/4_schema_usage_graphql_queries.feature index 96638403..1cb2e1e5 100644 --- a/test/integration/4_schema_usage_graphql_queries.feature +++ b/test/integration/4_schema_usage_graphql_queries.feature @@ -41,7 +41,7 @@ Feature: As a customer Then the response contains no errors And the response contains JSON from file "getOperationUsageTrackLastHour.json" - Scenario: I request the usage of an operation with no usage record + Scenario: I request the usage of an operation with no usage record in the last month Given the database is imported from 'schema_usage' When I execute the graphQL query in file "getOperationUsageTrack.graphql" with variables: """ @@ -63,7 +63,7 @@ Feature: As a customer | s_66_h45h2_1653653100 | 100 | And the redis has the key 'o_12_h45h1' with value as in file 'o_12_h45h1-content.json' And the redis has the key 'o_66_h45h2' with value as in file 'o_66_h45h2-content.json' - When I execute the graphQL query in file "getFieldUsageTrack.graphql" with variables: + When I execute the graphQL query in file "getEntityUsageTrack.graphql" with variables: """ { "id": 99, @@ -72,14 +72,47 @@ Feature: As a customer } """ Then the response contains no errors + And the response contains JSON from file "getEntityUsageTrack.json" + + Scenario: I request the usage of an object with no usage record in the last month + Given the database is imported from 'schema_usage' + When I execute the graphQL query in file "getEntityUsageTrack.graphql" with variables: + """ + { + "id": 99, + "startDate": "2022-05-01T00:00:00Z", + "endDate": "2022-05-31T23:59:59Z" + } + """ + Then the response contains no errors + And the response contains JSON from file "getEntityUsageTrackEmpty.json" + + Scenario: I request the usage of a field in the last month + Given the database is imported from 'schema_usage' + And the redis contains the keys: + | e_12_h45h1_1653652800 | 100 | + | s_12_h45h1_1653652900 | 400 | + | e_66_h45h2_1653653000 | 50 | + | s_66_h45h2_1653653100 | 100 | + And the redis has the key 'o_12_h45h1' with value as in file 'o_12_h45h1-content.json' + And the redis has the key 'o_66_h45h2' with value as in file 'o_66_h45h2-content.json' + When I execute the graphQL query in file "getFieldUsageTrack.graphql" with variables: + """ + { + "id": 198, + "startDate": "2022-05-01T00:00:00Z", + "endDate": "2022-05-31T23:59:59Z" + } + """ + Then the response contains no errors And the response contains JSON from file "getFieldUsageTrack.json" - Scenario: I request the usage of an object with no usage record + Scenario: I request the usage of a field with no usage record in the last month Given the database is imported from 'schema_usage' When I execute the graphQL query in file "getFieldUsageTrack.graphql" with variables: """ { - "id": 99, + "id": 198, "startDate": "2022-05-01T00:00:00Z", "endDate": "2022-05-31T23:59:59Z" } diff --git a/test/integration/data/request/getEntityUsageTrack.graphql b/test/integration/data/request/getEntityUsageTrack.graphql new file mode 100644 index 00000000..a34e9ded --- /dev/null +++ b/test/integration/data/request/getEntityUsageTrack.graphql @@ -0,0 +1,10 @@ +query getEntityUsageTrack($id: Int!, $startDate: Date!, $endDate: Date!) { + getEntityUsageTrack(id: $id, startDate: $startDate, endDate: $endDate) { + id + executions { + success + error + total + } + } +} diff --git a/test/integration/data/request/getFieldUsageTrack.graphql b/test/integration/data/request/getFieldUsageTrack.graphql index 30a5850e..87e1653f 100644 --- a/test/integration/data/request/getFieldUsageTrack.graphql +++ b/test/integration/data/request/getFieldUsageTrack.graphql @@ -1,10 +1,15 @@ query getFieldUsageTrack($id: Int!, $startDate: Date!, $endDate: Date!) { - getEntityUsageTrack(id: $id, startDate: $startDate, endDate: $endDate) { - id - executions { - success - error - total - } - } -} + getFieldUsageTrack(id: $id, startDate: $startDate, endDate: $endDate) { + client { + name + versions { + id + execution { + success + error + total + } + } + } + } +} \ No newline at end of file diff --git a/test/integration/data/response/getEntityUsageTrack.json b/test/integration/data/response/getEntityUsageTrack.json new file mode 100644 index 00000000..7c2152fc --- /dev/null +++ b/test/integration/data/response/getEntityUsageTrack.json @@ -0,0 +1,22 @@ +{ + "data": { + "getEntityUsageTrack": [ + { + "id": 198, + "executions": { + "success": 500, + "error": 150, + "total": 650 + } + }, + { + "id": 202, + "executions": { + "success": 400, + "error": 100, + "total": 500 + } + } + ] + } +} diff --git a/test/integration/data/response/getEntityUsageTrackEmpty.json b/test/integration/data/response/getEntityUsageTrackEmpty.json new file mode 100644 index 00000000..3aa84b52 --- /dev/null +++ b/test/integration/data/response/getEntityUsageTrackEmpty.json @@ -0,0 +1,5 @@ +{ + "data": { + "getEntityUsageTrack": [] + } +} diff --git a/test/integration/data/response/getFieldUsageTrack.json b/test/integration/data/response/getFieldUsageTrack.json index 7c2152fc..9c110356 100644 --- a/test/integration/data/response/getFieldUsageTrack.json +++ b/test/integration/data/response/getFieldUsageTrack.json @@ -1,20 +1,27 @@ { "data": { - "getEntityUsageTrack": [ + "getFieldUsageTrack": [ { - "id": 198, - "executions": { - "success": 500, - "error": 150, - "total": 650 - } - }, - { - "id": 202, - "executions": { - "success": 400, - "error": 100, - "total": 500 + "client": { + "name": "local-test-microservice", + "versions": [ + { + "id": "1.3.0", + "execution": { + "success": 100, + "error": 50, + "total": 150 + } + }, + { + "id": "1.2.3", + "execution": { + "success": 400, + "error": 100, + "total": 500 + } + } + ] } } ] diff --git a/test/integration/data/response/getFieldUsageTrackEmpty.json b/test/integration/data/response/getFieldUsageTrackEmpty.json index 3aa84b52..a7c04021 100644 --- a/test/integration/data/response/getFieldUsageTrackEmpty.json +++ b/test/integration/data/response/getFieldUsageTrackEmpty.json @@ -1,5 +1,5 @@ { "data": { - "getEntityUsageTrack": [] + "getFieldUsageTrack": [] } } diff --git a/test/integration/steps/redis.steps.ts b/test/integration/steps/redis.steps.ts index 1fd39777..bbbb6e01 100644 --- a/test/integration/steps/redis.steps.ts +++ b/test/integration/steps/redis.steps.ts @@ -4,7 +4,6 @@ import { readFileSync } from 'fs'; import { resolve } from 'path'; import { redisDataPath } from '../config/config'; import { getTimestamp } from '../../../src/redis/utils'; -import { parseInputDate } from '../../../src/graphql/resolvers/getOperationUsageTrack'; let redisWrapper;