Skip to content

test: make GraphQL server test more reliable #7758

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

Merged
merged 1 commit into from
Jan 2, 2022
Merged

test: make GraphQL server test more reliable #7758

merged 1 commit into from
Jan 2, 2022

Conversation

cbaker6
Copy link
Contributor

@cbaker6 cbaker6 commented Jan 2, 2022

New Pull Request Checklist

Issue Description

This test randomly fails and has a comment attached to it mentioning the relevant issue.

Related issue: #7180

Approach

Instead of removing the test, adapt to functions current behavior to ensure it passes, but ensures the code it's testing always behaves the way it currently behaves. The modification will still detect if an added feature breaks.

I attempted to remove the random failure in the graph tests by changing:

// NOTE: Here @davimacedo tried to test RelayID order, but the test is wrong since
// "objectId1" < "objectId2" do not always keep the order when objectId is transformed
// to base64 by Relay
// "SecondaryObject:bBRgmzIRRM" < "SecondaryObject:nTMcuVbATY" true
// base64("SecondaryObject:bBRgmzIRRM"") < base64(""SecondaryObject:nTMcuVbATY"") false
// "U2Vjb25kYXJ5T2JqZWN0OmJCUmdteklSUk0=" < "U2Vjb25kYXJ5T2JqZWN0Om5UTWN1VmJBVFk=" false
expect(
findSecondaryObjectsResult.data.secondaryObjects.edges[0].node.objectId
).toBeLessThan(
findSecondaryObjectsResult.data.secondaryObjects.edges[1].node.objectId
);

to:

// NOTE: Here @davimacedo tried to test RelayID order, but the test is wrong since
// "objectId1" < "objectId2" do not always keep the order when objectId is transformed
// to base64 by Relay
// "SecondaryObject:bBRgmzIRRM" < "SecondaryObject:nTMcuVbATY" true
// base64("SecondaryObject:bBRgmzIRRM"") < base64(""SecondaryObject:nTMcuVbATY"") false
// "U2Vjb25kYXJ5T2JqZWN0OmJCUmdteklSUk0=" < "U2Vjb25kYXJ5T2JqZWN0Om5UTWN1VmJBVFk=" false
 const originalIds = [getSecondaryObjectsResult.data.secondaryObject2.objectId,
      getSecondaryObjectsResult.data.secondaryObject4.objectId];
 expect(
                findSecondaryObjectsResult.data.secondaryObjects.edges[0].node.objectId
 ).not.toBe(
                findSecondaryObjectsResult.data.secondaryObjects.edges[1].node.objectId
 );
 expect(
                originalIds.includes(findSecondaryObjectsResult.data.secondaryObjects.edges[0].node.objectId)
 ).toBeTrue();
 expect(
                originalIds.includes(findSecondaryObjectsResult.data.secondaryObjects.edges[1].node.objectId)
 ).toBeTrue();

The change doesn't check for order, but it seems from your comment that's something you want to fix in the future.

TODOs before merging

  • Add tests
  • A changelog entry is created automatically using the pull request title (do not manually add a changelog entry)

@parse-github-assistant
Copy link

parse-github-assistant bot commented Jan 2, 2022

Thanks for opening this pull request!

  • 🎉 We are excited about your hands-on contribution!

@codecov
Copy link

codecov bot commented Jan 2, 2022

Codecov Report

Merging #7758 (7d10dce) into alpha (b106ffc) will increase coverage by 0.00%.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##            alpha    #7758   +/-   ##
=======================================
  Coverage   93.95%   93.96%           
=======================================
  Files         183      183           
  Lines       13640    13640           
=======================================
+ Hits        12816    12817    +1     
+ Misses        824      823    -1     
Impacted Files Coverage Δ
src/batch.js 93.10% <0.00%> (+1.72%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update b106ffc...7d10dce. Read the comment docs.

@mtrezza
Copy link
Member

mtrezza commented Jan 2, 2022

@cbaker6 Thanks for taking the time to split into individual PRs. I don't want to merge anything prematurely, so whenever a PR is ready please feel free to request a review from parse-community/server-review.

@mtrezza mtrezza changed the title refactor: make GraphQL server test more reliable test: make GraphQL server test more reliable Jan 2, 2022
@mtrezza
Copy link
Member

mtrezza commented Jan 2, 2022

Changed commit type to test in PR title because this PR only touches tests and does not touch any product code.

@cbaker6
Copy link
Contributor Author

cbaker6 commented Jan 2, 2022

@mtrezza i don’t have privileges to request a review on this repo, but it’s ready for review. I can only request a review after someone has been assigned or started a review already.

@mtrezza
Copy link
Member

mtrezza commented Jan 2, 2022

Yes, we should look into how we can make requesting reviews more accessible. That's an ongoing issue due to the inflexible GitHub permission concept. Maybe you can just mention @parse-community/server-review in a comment meanwhile.

Copy link
Member

@mtrezza mtrezza left a comment

Choose a reason for hiding this comment

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

Looks good!

@mtrezza mtrezza merged commit 912edac into parse-community:alpha Jan 2, 2022
@parseplatformorg
Copy link
Contributor

🎉 This change has been released in version 5.0.0-alpha.15

@parseplatformorg parseplatformorg added the state:released-alpha Released as alpha version label Jan 2, 2022
@cbaker6 cbaker6 deleted the graph branch January 2, 2022 18:27
@parseplatformorg
Copy link
Contributor

🎉 This change has been released in version 5.0.0-beta.10

@parseplatformorg parseplatformorg added the state:released-beta Released as beta version label Mar 15, 2022
@parseplatformorg
Copy link
Contributor

🎉 This change has been released in version 5.1.0

@parseplatformorg parseplatformorg added the state:released Released as stable version label Mar 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
state:released Released as stable version state:released-alpha Released as alpha version state:released-beta Released as beta version
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants