-
Notifications
You must be signed in to change notification settings - Fork 5
chore: add all missing tests for backstage-plugin-coder #101
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
Conversation
<h3 hidden id={formHeaderId}> | ||
Authenticate with Coder | ||
</h3> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was missing from the component before – has two purposes:
- Increasing accessibility for the overall form
- Providing another way to hook into the component during testing
it('Will not show any workspaces at all when the query text is empty', async () => { | ||
await renderWorkspacesCard({ readEntityData: true }); | ||
|
||
const user = userEvent.setup(); | ||
const inputField = await screen.findByRole('searchbox', { | ||
name: /Search your Coder workspaces/i, | ||
}); | ||
|
||
await user.tripleClick(inputField); | ||
await user.keyboard('[Backspace]'); | ||
|
||
const emptyState = await screen.findByText( | ||
/Use the search bar to find matching Coder workspaces/, | ||
); | ||
|
||
expect(emptyState).toBeInTheDocument(); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hoping we can get rid of this test pretty quickly, but while this behavior is in the codebase, it felt better to assure that it was working reliably
await waitFor(() => expect(result.current.status).toBe('success')); | ||
expect(result.current.data?.length).toBe(2); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With the updated test helpers, I don't think the old comment applies anymore
Closes #8
Changes made
CoderWorkspacesCard
useCoderWorkspacesQuery
Notes
There is one more behavior that could use a test, but I'm not sure if it's worth it. Basic steps are:
I was running into this when I was logged into the Full-stack challenge account, but had a token loaded for my personal Coder account. I think there is a way to simulate this at least, but: