Skip to content

Commit

Permalink
resolve comments, add tests
Browse files Browse the repository at this point in the history
Signed-off-by: Qxisylolo <[email protected]>
  • Loading branch information
Qxisylolo committed Nov 11, 2024
1 parent a827562 commit fcf568f
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,29 @@ describe('WorkspaceList', () => {
expect(queryByText('Create workspace')).toBeNull();
});

it('displays "Delete 1 workspace" when one workspace is selected for deletion', async () => {
const { getByText, container, getByTestId } = render(getWrapWorkspaceListInContext());
const checkboxes = container.querySelectorAll('[data-test-subj^="checkboxSelectRow-"]');
expect(checkboxes.length).toBeGreaterThanOrEqual(2);
fireEvent.click(checkboxes[0]);
expect(getByText('Delete 1 workspace')).toBeInTheDocument();
const deleteButton = getByTestId('workspace-list-page-delete-button');
fireEvent.click(deleteButton);
expect(screen.queryByLabelText('mock delete workspace modal')).toBeInTheDocument();
});

it('should display "Delete 2 workspaces" and show modal when two workspaces are selected for deletion', async () => {
const { getByText, container, getByTestId } = render(getWrapWorkspaceListInContext());
const checkboxes = container.querySelectorAll('[data-test-subj^="checkboxSelectRow-"]');
expect(checkboxes.length).toBeGreaterThanOrEqual(2);
fireEvent.click(checkboxes[0]);
fireEvent.click(checkboxes[1]);
expect(getByText('Delete 2 workspaces')).toBeInTheDocument();
const deleteButton = getByTestId('workspace-list-page-delete-button');
fireEvent.click(deleteButton);
expect(screen.queryByLabelText('mock delete workspace modal')).toBeInTheDocument();
});

it('should render data source badge when more than two data sources', async () => {
const { getByTestId } = render(getWrapWorkspaceListInContext());
await waitFor(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,13 @@ export const WorkspaceListInner = ({
size="s"
data-test-subj="multi-deletion-button"
>
Delete {selection.length} Workspace
{i18n.translate('workspace.list.page.delete.button.info', {
defaultMessage: 'Delete {num} workspace{pluralSuffix, select, true {} other {s}}',
values: {
num: selection.length,
pluralSuffix: selection.length === 1,
},
})}
</EuiButton>
{deletedWorkspaces && deletedWorkspaces.length > 0 && (
<DeleteWorkspaceModal
Expand Down

0 comments on commit fcf568f

Please sign in to comment.