Repository navigation
feat: condition Audit log on licensing - #3685
Conversation
| "@testing-library/react-hooks": "8.0.1", | ||
| "@xstate/inspect": "0.6.5", | ||
| "@xstate/react": "3.0.0", | ||
| "@xstate/react": "3.0.1", |
There was a problem hiding this comment.
What was the testing issue this fixed?
There was a problem hiding this comment.
The getSnapshot warning/crash and the shallowEqual util for avoiding it. https://newreleases.io/project/github/statelyai/xstate/release/@xstate%2Freact@3.0.1
|
|
||
| export type Message = { message: string } | ||
|
|
||
| // Keep up to date with coder/codersdk/features.go |
There was a problem hiding this comment.
Is this something that can be autogenerated?
There was a problem hiding this comment.
My understanding is there's some reason why we can't get enums in our generated types.
| }) | ||
| }) | ||
|
|
||
| it("does not show Audit Log link when not entitled", async () => { |
There was a problem hiding this comment.
Reading this code, how does one know Audit Log link is not entitled? Is it due to the lack of the mocked request or something?
There was a problem hiding this comment.
Yes, the default handler in handlers.ts returns empty license data, as if you're an OSS user.
| }) | ||
| }) | ||
|
|
||
| it("does not show Audit Log link when not permitted via role", async () => { |
There was a problem hiding this comment.
Same with this test. How does one know that a member is not permitted? I see MockMemberPermissions but hard to tell from code what role is being given or why they don't have permission.
There was a problem hiding this comment.
The Member role does not have auditing permissions.
| import { Navigate } from "react-router" | ||
|
|
||
| export interface RequirePermissionProps { | ||
| children: JSX.Element |
There was a problem hiding this comment.
I tried using it here and got a TS error, not sure why!
There was a problem hiding this comment.
Up to you though: just a suggestion
| } | ||
| } | ||
|
|
||
| export const MockMemberPermissions = { |
There was a problem hiding this comment.
Might be helpful to convey permissions in name i.e. MockMemberWithoutAuditLogPermissions
There was a problem hiding this comment.
I added comments, does that help?
Closes #3219
RequirePermissionswrapper component to makeAppRoutermore readable (currently doing the XState stuff inAppRouterinstead of the wrapper, either way is workable though)In the past, we've punted on some component tests thinking that e2e tests would work better for cases that need to include the whole component tree. But e2e tests are difficult - they require setup instead of mocks and can be flaky. So I tried doing a component test while rendering
App. I think it's a good way forward for such cases.Click SHOW_MOCK_BANNER and HIDE_MOCK_BANNER in the XState inspector to see/hide the Audit link in the navbar - they change the stored license data to trigger both the warning banner and enabling the Audit Log.
Remaining issue:
A test that passes in my workspace fails on CI, I'm investigating.