-
Notifications
You must be signed in to change notification settings - Fork 13k
chore: Header tags for ABAC rooms #37126
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
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
7e6735c
feat: create header tag for ABAC rooms
MartinSchoeler a63a4fa
chore: Adjust minimum header tag size
MartinSchoeler b7c1f7d
Create slow-trees-eat.md
MartinSchoeler f1da675
chore: move to chore
MartinSchoeler 4a3d5f5
fix: missing translations
MartinSchoeler 1de331c
test: add more tests & snapshots updates
MartinSchoeler 61d26f5
Merge branch 'develop' into feat/ABAC-header-tag
kodiakhq[bot] File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,62 @@ | ||
| import type { IRoom } from '@rocket.chat/apps-engine/definition/rooms'; | ||
| import { mockAppRoot } from '@rocket.chat/mock-providers'; | ||
| import { render, screen } from '@testing-library/react'; | ||
| import { axe } from 'jest-axe'; | ||
|
|
||
| import ABACHeaderTag from './ABACHeaderTag'; | ||
|
|
||
| const appRoot = mockAppRoot() | ||
| .withTranslations('en', 'core', { | ||
| ABAC_header_tag_title: 'Only compliant users have access to attribute-based access controlled rooms.', | ||
| ABAC_header_tag: 'ABAC', | ||
| }) | ||
| .build(); | ||
|
|
||
| const createMockRoom = (overrides: Partial<IRoom> = {}) => ({ | ||
| _id: 'room-id', | ||
| t: 'c' as const, | ||
| name: 'test-room', | ||
| msgs: 0, | ||
| u: { _id: 'user-id', username: 'testuser' }, | ||
| usersCount: 1, | ||
| _updatedAt: new Date(), | ||
| ...overrides, | ||
| }); | ||
|
|
||
| describe('ABACHeaderTag', () => { | ||
| it('should render the ABAC tag when room has ABAC attributes', () => { | ||
| const room = createMockRoom({ | ||
| // @ts-expect-error to be implemented | ||
| abacAttributes: { someAttribute: 'value' }, | ||
| }); | ||
|
|
||
| const { baseElement } = render(<ABACHeaderTag room={room} />, { wrapper: appRoot }); | ||
| expect(baseElement).toMatchSnapshot(); | ||
| }); | ||
|
|
||
| it('should not render when room has no ABAC attributes', () => { | ||
| const room = createMockRoom(); | ||
|
|
||
| render(<ABACHeaderTag room={room} />, { wrapper: appRoot }); | ||
| expect(screen.queryByText('ABAC')).not.toBeInTheDocument(); | ||
| }); | ||
|
|
||
| it('should have no accessibility violations when rendered', async () => { | ||
| const room = createMockRoom({ | ||
| // @ts-expect-error to be implemented | ||
| abacAttributes: { someAttribute: 'value' }, | ||
| }); | ||
|
|
||
| const { container } = render(<ABACHeaderTag room={room} />, { wrapper: appRoot }); | ||
| const results = await axe(container); | ||
| expect(results).toHaveNoViolations(); | ||
| }); | ||
|
|
||
| it('should have no accessibility violations when not rendered', async () => { | ||
| const room = createMockRoom(); | ||
|
|
||
| const { container } = render(<ABACHeaderTag room={room} />, { wrapper: appRoot }); | ||
| const results = await axe(container); | ||
| expect(results).toHaveNoViolations(); | ||
| }); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| import type { IRoom } from '@rocket.chat/core-typings'; | ||
| import { Box, Palette } from '@rocket.chat/fuselage'; | ||
| import { useTranslation } from 'react-i18next'; | ||
|
|
||
| import { HeaderTag } from '../Header'; | ||
|
|
||
| type ABACHeaderTagProps = { | ||
| room: IRoom; | ||
| }; | ||
|
|
||
| const ABACHeaderTag = ({ room }: ABACHeaderTagProps) => { | ||
| const { t } = useTranslation(); | ||
|
|
||
| // @ts-expect-error to be implemented | ||
| if (!room.abacAttributes) { | ||
| return null; | ||
| } | ||
|
|
||
| return ( | ||
| <HeaderTag title={t('ABAC_header_tag_title')}> | ||
| <Box color={Palette.statusColor['status-font-on-warning'].toString()} fontWeight='700'> | ||
| {t('ABAC_header_tag')} | ||
| </Box> | ||
| </HeaderTag> | ||
| ); | ||
| }; | ||
|
|
||
| export default ABACHeaderTag; | ||
26 changes: 26 additions & 0 deletions
26
apps/meteor/client/components/ABAC/__snapshots__/ABACHeaderTag.spec.tsx.snap
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| // Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing | ||
|
|
||
| exports[`ABACHeaderTag should render the ABAC tag when room has ABAC attributes 1`] = ` | ||
| <body> | ||
| <div> | ||
| <div | ||
| class="rcx-box rcx-box--full rcx-css-1kopyx3" | ||
| > | ||
| <span | ||
| class="rcx-box rcx-box--full rcx-tag rcx-tag--medium" | ||
| title="Only compliant users have access to attribute-based access controlled rooms." | ||
| > | ||
| <span | ||
| class="rcx-tag__inner" | ||
| > | ||
| <div | ||
| class="rcx-box rcx-box--full rcx-css-12a8uky" | ||
| > | ||
| ABAC | ||
| </div> | ||
| </span> | ||
| </span> | ||
| </div> | ||
| </div> | ||
| </body> | ||
| `; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
packages/ui-client/src/components/HeaderV2/HeaderTag/HeaderTag.spec.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| import { render } from '@testing-library/react'; | ||
|
|
||
| import HeaderTag from './HeaderTag'; | ||
|
|
||
| it('should match snapshot', () => { | ||
| const { baseElement } = render(<HeaderTag>Test Tag</HeaderTag>); | ||
| expect(baseElement).toMatchSnapshot(); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
packages/ui-client/src/components/HeaderV2/HeaderTag/__snapshots__/HeaderTag.spec.tsx.snap
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| // Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing | ||
|
|
||
| exports[`should match snapshot 1`] = ` | ||
| <body> | ||
| <div> | ||
| <div | ||
| class="rcx-box rcx-box--full rcx-css-1kopyx3" | ||
| > | ||
| <span | ||
| class="rcx-box rcx-box--full rcx-tag rcx-tag--medium" | ||
| > | ||
| <span | ||
| class="rcx-tag__inner" | ||
| > | ||
| Test Tag | ||
| </span> | ||
| </span> | ||
| </div> | ||
| </div> | ||
| </body> | ||
| `; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.