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

chore: add missing unit tests for Coder plugin #83

Merged
merged 85 commits into from
Mar 28, 2024
Merged

Conversation

Parkreiner
Copy link
Collaborator

@Parkreiner Parkreiner commented Mar 23, 2024

Resolves one of the to-do items in #8

Changes made

  • Added test file for CoderAuthWrapper
  • Added test files for all CoderWorkspacesCard sub-components
  • Deleted all the test helpers for working with components (which hadn't been used up until now), and made a new one
  • Made various changes while writing out the tests
    • Made of the error messages for CoderAuthWrapper more user-friendly
    • Updated how the IDs were bound for MUI in CoderAuthInputForm
    • Updated our parsing logic for grabbing the name of a repo (helps us support GitLab and Bitbucket better)
  • Rewrote some of the comments to be more clear

Notes

  • This still isn't all the tests, but to keep things manageable, I decided that I'll handle the main integration test in a separate PR

@Parkreiner Parkreiner changed the title chore: add missing tests for Coder plugin chore: add missing unit tests for Coder plugin Mar 27, 2024
@Parkreiner Parkreiner marked this pull request as ready for review March 27, 2024 03:23
@@ -138,76 +141,6 @@ export const CoderProviderWithMockAuth = ({
);
};

type ChildProps = EntityProviderProps;
Copy link
Collaborator Author

@Parkreiner Parkreiner Mar 27, 2024

Choose a reason for hiding this comment

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

You can ignore this entire red section – these were bad test helpers that didn't do what they were supposed to. They're just deleted and aren't moved anywhere – I added a new test helper towards the bottom of the file

</TestApiProvider>
);

return wrapInTestApp(mainMarkup) as unknown as typeof mainMarkup;
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

There are some strange type mismatches in Backstage. wrapInTestApp is supposed to give you back a React component, which you should be able to plug into RTL's functions

But the type is slightly off, so even though things won't break at runtime, the compiler will complain

Copy link
Member

@code-asher code-asher left a comment

Choose a reason for hiding this comment

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

Wunderbar!

expect(unlinkCoderAccount).toHaveBeenCalled();
});

it('Lets users trigger actions entirely through the keyboard', async () => {
Copy link
Member

Choose a reason for hiding this comment

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

😍

Base automatically changed from mes/template-name-update to main March 28, 2024 21:48
@Parkreiner Parkreiner merged commit 343c866 into main Mar 28, 2024
2 checks passed
@Parkreiner Parkreiner deleted the mes/workspace-tests branch March 28, 2024 21:55
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.

2 participants