-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added feature scenarios as living documentation
Increased integration test coverage
- Loading branch information
bashj79
committed
Mar 9, 2021
1 parent
42c070f
commit dc865bf
Showing
18 changed files
with
3,039 additions
and
946 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"extends": "../.eslintrc", | ||
"rules": { | ||
"import/no-extraneous-dependencies": "off" | ||
} | ||
} |
240 changes: 240 additions & 0 deletions
240
features/queryImposterCreatedFromGraphQLSchemaEndpoint.feature
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,240 @@ | ||
Feature: Create imposter from Schema Endpoint | ||
Allow querying of GraphQL imposter having a remote schema definition | ||
|
||
Scenario: Query imposter with endpoint with accessible introspection query | ||
Given a GraphQL server exists at "http://localhost:3000" with the following schema definition: | ||
""" | ||
type Thing { | ||
alpha: Int | ||
beta: String | ||
} | ||
input ThingInput { | ||
alpha: Int! | ||
beta: String! | ||
} | ||
type Query { | ||
dummyQuery: String | ||
} | ||
type Mutation { | ||
myMutation(data: ThingInput!): Thing | ||
} | ||
""" | ||
And a GraphQL imposter exists on port 4000 configured with the "http://localhost:3000" schema endpoint | ||
And the imposter's single stub has the following predicates: | ||
""" | ||
[ | ||
{ | ||
"equals": { | ||
"mutation": "myMutation" | ||
} | ||
}, | ||
{ | ||
"equals": { | ||
"args": { | ||
"data": { | ||
"alpha": 42, | ||
"beta": "abcdef" | ||
} | ||
} | ||
} | ||
} | ||
] | ||
""" | ||
And the imposter's single stub has the following responses: | ||
""" | ||
[ | ||
{ | ||
"is": { | ||
"data": { | ||
"alpha": 24, | ||
"beta": "fedcba" | ||
} | ||
} | ||
} | ||
] | ||
""" | ||
When Brandon attempts to execute the following GraphQL query: | ||
""" | ||
mutation { | ||
myMutation(data: { | ||
alpha: 42 | ||
beta: "abcdef" | ||
}) { | ||
beta | ||
alpha | ||
} | ||
} | ||
""" | ||
Then the query will be successful and the response will be: | ||
""" | ||
{ | ||
"data": { | ||
"myMutation": { | ||
"beta": "fedcba", | ||
"alpha": 24 | ||
} | ||
} | ||
} | ||
""" | ||
|
||
Scenario: Query imposter with endpoint with accessible introspection query requiring authentication | ||
Given a secure GraphQL server requiring the "my.access.token" bearer token exists at "http://localhost:3001" with the following schema definition: | ||
""" | ||
type Thing { | ||
alpha: Int | ||
beta: String | ||
} | ||
input ThingInput { | ||
alpha: Int! | ||
beta: String! | ||
} | ||
type Query { | ||
dummyQuery: String | ||
} | ||
type Mutation { | ||
mySecureMutation(data: ThingInput!): Thing | ||
} | ||
""" | ||
And a GraphQL imposter exists on port 4000 configured with the "http://localhost:3001" schema endpoint and the following schema endpoint headers: | ||
| Authorization | Bearer my.access.token | | ||
And the imposter's single stub has the following predicates: | ||
""" | ||
[ | ||
{ | ||
"equals": { | ||
"mutation": "mySecureMutation" | ||
} | ||
}, | ||
{ | ||
"equals": { | ||
"args": { | ||
"data": { | ||
"alpha": 42, | ||
"beta": "abcdef" | ||
} | ||
} | ||
} | ||
} | ||
] | ||
""" | ||
And the imposter's single stub has the following responses: | ||
""" | ||
[ | ||
{ | ||
"is": { | ||
"data": { | ||
"alpha": 24, | ||
"beta": "fedcba" | ||
} | ||
} | ||
} | ||
] | ||
""" | ||
When Ivan attempts to execute the following GraphQL query: | ||
""" | ||
mutation { | ||
mySecureMutation(data: { | ||
alpha: 42 | ||
beta: "abcdef" | ||
}) { | ||
beta | ||
alpha | ||
} | ||
} | ||
""" | ||
Then the query will be successful and the response will be: | ||
""" | ||
{ | ||
"data": { | ||
"mySecureMutation": { | ||
"beta": "fedcba", | ||
"alpha": 24 | ||
} | ||
} | ||
} | ||
""" | ||
|
||
Scenario: Query imposter with remotely hosted schema definition | ||
Given a following schema definition exists at the "http://localhost:8080/schema.graphql" URL: | ||
""" | ||
type OtherThing { | ||
alpha: Int | ||
beta: String | ||
} | ||
input OtherThingInput { | ||
alpha: Int! | ||
beta: String! | ||
} | ||
type Query { | ||
dummyQuery: String | ||
} | ||
type Mutation { | ||
myOtherMutation(data: OtherThingInput!): OtherThing | ||
} | ||
""" | ||
And a GraphQL imposter exists on port 4000 configured with the "http://localhost:8080/schema.graphql" schema endpoint | ||
And the imposter's single stub has the following predicates: | ||
""" | ||
[ | ||
{ | ||
"equals": { | ||
"mutation": "myOtherMutation" | ||
} | ||
}, | ||
{ | ||
"equals": { | ||
"args": { | ||
"data": { | ||
"alpha": 123, | ||
"beta": "abc" | ||
} | ||
} | ||
} | ||
} | ||
] | ||
""" | ||
And the imposter's single stub has the following responses: | ||
""" | ||
[ | ||
{ | ||
"is": { | ||
"data": { | ||
"alpha": 456, | ||
"beta": "def" | ||
} | ||
} | ||
} | ||
] | ||
""" | ||
When Lee attempts to execute the following GraphQL query: | ||
""" | ||
mutation { | ||
myOtherMutation(data: { | ||
alpha: 123 | ||
beta: "abc" | ||
}) { | ||
beta | ||
alpha | ||
} | ||
} | ||
""" | ||
Then the query will be successful and the response will be: | ||
""" | ||
{ | ||
"data": { | ||
"myOtherMutation": { | ||
"beta": "def", | ||
"alpha": 456 | ||
} | ||
} | ||
} | ||
""" |
82 changes: 82 additions & 0 deletions
82
features/queryImposterCreatedFromInlineGraphQLSchema.feature
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
Feature: Create imposter from Inline Schema | ||
Allow querying of GraphQL imposter having an inline schema definition | ||
|
||
Background: | ||
Given a GraphQL imposter exists on port 4000 with the following inline schema definition: | ||
""" | ||
type Thing { | ||
alpha: Int | ||
beta: String | ||
} | ||
type Query { | ||
myQuery(myFirstArg: Int, mySecondArg: Int): Thing | ||
} | ||
""" | ||
And the imposter's single stub has the following predicates: | ||
""" | ||
[ | ||
{ | ||
"equals": { | ||
"query": "myQuery" | ||
} | ||
}, | ||
{ | ||
"equals": { | ||
"args": { | ||
"myFirstArg": 123 | ||
} | ||
} | ||
} | ||
] | ||
""" | ||
And the imposter's single stub has the following responses: | ||
""" | ||
[ | ||
{ | ||
"is": { | ||
"data": { | ||
"alpha": 42, | ||
"beta": "abcdef" | ||
} | ||
} | ||
} | ||
] | ||
""" | ||
|
||
Scenario: Query imposter with exact predicate match | ||
When Brandon attempts to execute the following GraphQL query: | ||
""" | ||
query { | ||
myQuery(myFirstArg: 123) { | ||
alpha | ||
beta | ||
} | ||
} | ||
""" | ||
Then the query will be successful and the response will be: | ||
""" | ||
{ | ||
"data": { | ||
"myQuery": { | ||
"alpha": 42, | ||
"beta": "abcdef" | ||
} | ||
} | ||
} | ||
""" | ||
|
||
Scenario: Query imposter with incomplete predicate match | ||
When Ivan attempts to execute the following GraphQL query: | ||
""" | ||
query { | ||
myQuery(myFirstArg: 456) { | ||
alpha | ||
beta | ||
} | ||
} | ||
""" | ||
Then the query will be successful and the response will match: | ||
| JSON Path | Value Type | | ||
| data.myQuery.alpha | Number | | ||
| data.myQuery.beta | String | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
/* eslint-disable no-console */ | ||
export default (message) => { | ||
console.log(message); | ||
}; |
Oops, something went wrong.