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

🐛 Address required status bug #1843

Merged
merged 3 commits into from
Apr 15, 2024

Conversation

ibolton336
Copy link
Member

Resolves https://issues.redhat.com/browse/MTA-2505

  • Adds additional unit test coverage

@ibolton336 ibolton336 force-pushed the address-status-issue branch from 07f865f to fc6c538 Compare April 12, 2024 15:56
@ibolton336 ibolton336 added the cherry-pick/release-0.3 This PR should be cherry-picked to release-0.3 branch. label Apr 12, 2024
@ibolton336 ibolton336 force-pushed the address-status-issue branch from 7c2888d to 8c94ee8 Compare April 12, 2024 18:20
@rszwajko rszwajko requested review from rszwajko and sjd78 April 12, 2024 20:21
Copy link
Member

@sjd78 sjd78 left a comment

Choose a reason for hiding this comment

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

Change looks good, and I like the unit test!

I think the unit test could be rearranged to keep a single server.use() in place.

Comment on lines +94 to +115
rest.get("/hub/assessments", (req, res, ctx) => {
return res(
ctx.json([
createMockAssessment({
id: 1,
application: { id: 1, name: "app1" },
questionnaire: { id: 1, name: "questionnaire1" },
status: "started",
required: false,
sections: [],
}),
createMockAssessment({
id: 2,
application: { id: 1, name: "app1" },
questionnaire: { id: 2, name: "questionnaire2" },
status: "complete",
required: false,
sections: [],
}),
])
);
})
Copy link
Member

Choose a reason for hiding this comment

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

Having the second set of handlers is a bit confusing.

I suggest just doing a use once kind of setup so it is more obvious that the data will change on the second request.

This may work (not tested):

    rest.get("/hub/assessments", (req, res, ctx) => {
        return res.once(
          // first json
        );
      })
    rest.get("/hub/assessments", (req, res, ctx) => {
        return res(
          // json for the rest of the time
        );
      })

See: https://v1.mswjs.io/docs/api/setup-server/use#one-time-override

Copy link
Member

Choose a reason for hiding this comment

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

Or I just found you can use a generator function in this case -- way cooler:
mswjs/msw#1117 (reply in thread)

It points at this bit of code for more examples: https://github.com/mswjs/msw/blob/6990c3a57a1f515fe977c2eaa7741005b885b8af/test/rest-api/generator.mocks.ts#L4

//cc @rszwajko

@sjd78 sjd78 added this to the v0.3.2 milestone Apr 15, 2024
@ibolton336 ibolton336 merged commit c5265bd into konveyor:main Apr 15, 2024
7 checks passed
github-actions bot pushed a commit that referenced this pull request Apr 15, 2024
Resolves https://issues.redhat.com/browse/MTA-2505
- Adds additional unit test coverage

Signed-off-by: Ian Bolton <[email protected]>
Signed-off-by: Cherry Picker <[email protected]>
sjd78 pushed a commit that referenced this pull request Apr 15, 2024
Resolves https://issues.redhat.com/browse/MTA-2505
- Adds additional unit test coverage

Backport-of: #1843
Signed-off-by: Ian Bolton <[email protected]>
Signed-off-by: Cherry Picker <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cherry-pick/release-0.3 This PR should be cherry-picked to release-0.3 branch.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants