Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test(graphql): add negative test cases for invalid inputs and arguments #783

Merged
merged 3 commits into from
Sep 12, 2022

Conversation

sundersc
Copy link
Contributor

@sundersc sundersc commented Sep 7, 2022

Description of changes

Add negative test cases for mutations and queries with invalid inputs and arguments.

  • Invalid data type check
  • Invalid arguments length
  • Invalid filter with 'and' and 'or' conditions

Checklist

  • PR description included
  • yarn test passes
  • Tests are changed or added
  • Relevant documentation is changed or added (and PR referenced)
  • New AWS SDK calls or CloudFormation actions have been added to relevant test and service IAM policies

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@sundersc sundersc requested a review from a team as a code owner September 7, 2022 20:55
alharris-at
alharris-at previously approved these changes Sep 7, 2022
Copy link
Contributor

@alharris-at alharris-at left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Non-blocking comments.

Comment on lines 45 to 46
const createResult = await createTask(input);
expect(false).toBeTruthy();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this become more readable as an `expect(async () => await createTask(input).toThrow(/matcher/)

I'm fine as-is, so treat as a question.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've considered this but we will lose the ability to verify error.errors is defined and error length is greater than 1.

{ or: [ { priority: { between: [1, 2.5] } }, { title: { gt: "test" } } ] }, // Incorrect argument value for between operator with 'or' condition
];

await Promise.all(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you pull this block out to a utlity? Then these tests will just be 'data setup'.test basically.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense. Moved the logic to a separate method.

@codecov-commenter
Copy link

Codecov Report

Merging #783 (db7411a) into main (98c021a) will not change coverage.
The diff coverage is n/a.

@@           Coverage Diff           @@
##             main     #783   +/-   ##
=======================================
  Coverage   63.39%   63.39%           
=======================================
  Files         278      278           
  Lines       18220    18220           
  Branches     4431     4431           
=======================================
  Hits        11550    11550           
  Misses       6074     6074           
  Partials      596      596           

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@sundersc sundersc merged commit c324083 into main Sep 12, 2022
@sundersc sundersc deleted the negative-test-cases branch September 12, 2022 22:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants