-
Notifications
You must be signed in to change notification settings - Fork 881
feat: condition Audit log on licensing #3685
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
@@ -33,7 +33,7 @@ | |||
"@material-ui/lab": "4.0.0-alpha.42", | |||
"@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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What was the testing issue this fixed?
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.
The getSnapshot
warning/crash and the shallowEqual
util for avoiding it. https://newreleases.io/project/github/statelyai/xstate/release/@xstate%[email protected]
@@ -14,3 +14,9 @@ export interface ReconnectingPTYRequest { | |||
export type WorkspaceBuildTransition = "start" | "stop" | "delete" | |||
|
|||
export type Message = { message: string } | |||
|
|||
// Keep up to date with coder/codersdk/features.go |
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.
Is this something that can be autogenerated?
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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would PropsWithChildren
help here? reference
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.
I tried using it here and got a TS error, not sure why!
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.
Up to you though: just a suggestion
@@ -51,6 +51,10 @@ export function assignableRole(role: TypesGen.Role, assignable: boolean): TypesG | |||
} | |||
} | |||
|
|||
export const MockMemberPermissions = { |
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.
Might be helpful to convey permissions in name i.e. MockMemberWithoutAuditLogPermissions
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.
I added comments, does that help?
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.
Yes, it does! Thank you!
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.
Nice work!
Closes #3219
RequirePermissions
wrapper component to makeAppRouter
more readable (currently doing the XState stuff inAppRouter
instead 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.