-
Notifications
You must be signed in to change notification settings - Fork 368
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: [UIE-8139] - add new assigned entities table component part 1
- Loading branch information
1 parent
ab2a7e5
commit bda1fdf
Showing
15 changed files
with
511 additions
and
135 deletions.
There are no files selected for viewing
5 changes: 5 additions & 0 deletions
5
packages/api-v4/.changeset/pr-11588-upcoming-features-1738244661751.md
This file contains 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,5 @@ | ||
--- | ||
"@linode/api-v4": Upcoming Features | ||
--- | ||
|
||
updated types for iam ([#11588](https://github.com/linode/manager/pull/11588)) |
This file contains 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
5 changes: 5 additions & 0 deletions
5
packages/manager/.changeset/pr-11588-upcoming-features-1738244711758.md
This file contains 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,5 @@ | ||
--- | ||
"@linode/manager": Upcoming Features | ||
--- | ||
|
||
add new table component for the assigned entities in the iam ([#11588](https://github.com/linode/manager/pull/11588)) |
This file contains 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
131 changes: 131 additions & 0 deletions
131
...ages/manager/src/features/IAM/Shared/AssignedEntitiesTable/AssignedEntitiesTable.test.tsx
This file contains 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,131 @@ | ||
import { fireEvent, waitFor } from '@testing-library/react'; | ||
import React from 'react'; | ||
|
||
import { accountResourcesFactory } from 'src/factories/accountResources'; | ||
import { userPermissionsFactory } from 'src/factories/userPermissions'; | ||
import { renderWithTheme } from 'src/utilities/testHelpers'; | ||
|
||
import { AssignedEntitiesTable } from './AssignedEntitiesTable'; | ||
|
||
const queryMocks = vi.hoisted(() => ({ | ||
useAccountResources: vi.fn().mockReturnValue({}), | ||
useAccountUserPermissions: vi.fn().mockReturnValue({}), | ||
})); | ||
|
||
vi.mock('src/queries/iam/iam', async () => { | ||
const actual = await vi.importActual<any>('src/queries/iam/iam'); | ||
return { | ||
...actual, | ||
useAccountUserPermissions: queryMocks.useAccountUserPermissions, | ||
}; | ||
}); | ||
|
||
vi.mock('src/queries/resources/resources', async () => { | ||
const actual = await vi.importActual<any>('src/queries/resources/resources'); | ||
return { | ||
...actual, | ||
useAccountResources: queryMocks.useAccountResources, | ||
}; | ||
}); | ||
|
||
describe('AssignedEntitiesTable', () => { | ||
it('should display no roles text if there are no roles assigned to user', async () => { | ||
queryMocks.useAccountUserPermissions.mockReturnValue({ | ||
data: {}, | ||
}); | ||
|
||
const { getByText } = renderWithTheme(<AssignedEntitiesTable />); | ||
|
||
getByText('No Entities are assigned.'); | ||
}); | ||
|
||
it('should display roles and menu when data is available', async () => { | ||
queryMocks.useAccountUserPermissions.mockReturnValue({ | ||
data: userPermissionsFactory.build(), | ||
}); | ||
|
||
queryMocks.useAccountResources.mockReturnValue({ | ||
data: accountResourcesFactory.build(), | ||
}); | ||
|
||
const { getAllByLabelText, getByText } = renderWithTheme( | ||
<AssignedEntitiesTable /> | ||
); | ||
|
||
expect(getByText('firewall-us-123')).toBeInTheDocument(); | ||
expect(getByText('Firewall')).toBeInTheDocument(); | ||
expect(getByText('update_firewall')).toBeInTheDocument(); | ||
|
||
const actionMenuButton = getAllByLabelText('action menu')[0]; | ||
expect(actionMenuButton).toBeInTheDocument(); | ||
|
||
fireEvent.click(actionMenuButton); | ||
expect(getByText('Change Role')).toBeInTheDocument(); | ||
expect(getByText('Remove Assignment')).toBeInTheDocument(); | ||
}); | ||
|
||
it('should display empty state when no roles match filters', async () => { | ||
queryMocks.useAccountUserPermissions.mockReturnValue({ | ||
data: userPermissionsFactory.build(), | ||
}); | ||
|
||
queryMocks.useAccountResources.mockReturnValue({ | ||
data: accountResourcesFactory.build(), | ||
}); | ||
|
||
const { getByPlaceholderText, getByText } = renderWithTheme( | ||
<AssignedEntitiesTable /> | ||
); | ||
|
||
const searchInput = getByPlaceholderText('Search'); | ||
fireEvent.change(searchInput, { target: { value: 'NonExistentRole' } }); | ||
|
||
await waitFor(() => { | ||
expect(getByText('No Entities are assigned.')).toBeInTheDocument(); | ||
}); | ||
}); | ||
|
||
it('should filter roles based on search query', async () => { | ||
queryMocks.useAccountUserPermissions.mockReturnValue({ | ||
data: userPermissionsFactory.build(), | ||
}); | ||
|
||
queryMocks.useAccountResources.mockReturnValue({ | ||
data: accountResourcesFactory.build(), | ||
}); | ||
|
||
const { getByPlaceholderText, queryByText } = renderWithTheme( | ||
<AssignedEntitiesTable /> | ||
); | ||
|
||
const searchInput = getByPlaceholderText('Search'); | ||
fireEvent.change(searchInput, { | ||
target: { value: 'firewall-us-123' }, | ||
}); | ||
|
||
await waitFor(() => { | ||
expect(queryByText('firewall-us-123')).toBeInTheDocument(); | ||
}); | ||
}); | ||
|
||
it('should filter roles based on selected resource type', async () => { | ||
queryMocks.useAccountUserPermissions.mockReturnValue({ | ||
data: userPermissionsFactory.build(), | ||
}); | ||
|
||
queryMocks.useAccountResources.mockReturnValue({ | ||
data: accountResourcesFactory.build(), | ||
}); | ||
|
||
const { getByPlaceholderText, queryByText } = renderWithTheme( | ||
<AssignedEntitiesTable /> | ||
); | ||
|
||
const autocomplete = getByPlaceholderText('All Assigned Entities'); | ||
fireEvent.change(autocomplete, { target: { value: 'Firewalls' } }); | ||
|
||
await waitFor(() => { | ||
expect(queryByText('firewall-us-123')).toBeInTheDocument(); | ||
}); | ||
}); | ||
}); |
Oops, something went wrong.