-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: missing empty state for workspaces dropdown #2305
- Loading branch information
1 parent
9cefd9a
commit 11edf2d
Showing
7 changed files
with
93 additions
and
15 deletions.
There are no files selected for viewing
2 changes: 2 additions & 0 deletions
2
...dashboard/src/components/queryEditor/iotSiteWiseQueryEditor/dataStreamSearch/constants.ts
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 |
---|---|---|
@@ -1 +1,3 @@ | ||
export const MAX_QUERY_STATEMENT_LENGTH = 1000; | ||
export const infoMessage = 'To find you assests, make sure to enter the exact model name or characters.'; | ||
export const errorMessage = 'Advanced search not supported, no workspace available.'; |
41 changes: 41 additions & 0 deletions
41
.../components/queryEditor/iotSiteWiseQueryEditor/dataStreamSearch/dataStreamSearch.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,41 @@ | ||
import React from 'react'; | ||
import { render, screen } from '@testing-library/react'; | ||
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'; | ||
import { DataStreamSearch } from './dataStreamSearch'; | ||
import { IoTTwinMakerClient } from '@aws-sdk/client-iottwinmaker'; | ||
|
||
jest.mock('./workspaceSelector/useWorkspaces', () => ({ | ||
useWorkspaces: jest.fn(() => ({ | ||
workspaces: [], | ||
status: 'error', | ||
})), | ||
})); | ||
|
||
describe('DataStreamSearch component', () => { | ||
test('renders error and info component when no workspaceis available', async () => { | ||
render( | ||
<QueryClientProvider client={new QueryClient()}> | ||
<DataStreamSearch onSubmit={jest.fn()} client={{ send: jest.fn() } as unknown as IoTTwinMakerClient} /> | ||
</QueryClientProvider> | ||
); | ||
|
||
const errorMessage = screen.getByText('Advanced search not supported, no workspace available.'); | ||
expect(errorMessage).toBeInTheDocument(); | ||
|
||
const infoMessage = screen.getByText('To find you assests, make sure to enter the exact model name or characters.'); | ||
expect(infoMessage).toBeInTheDocument(); | ||
}); | ||
|
||
test('expects to have an external link ', () => { | ||
render( | ||
<QueryClientProvider client={new QueryClient()}> | ||
<DataStreamSearch onSubmit={jest.fn()} client={{ send: jest.fn() } as unknown as IoTTwinMakerClient} /> | ||
</QueryClientProvider> | ||
); | ||
|
||
expect(screen.getByRole('link', { name: 'Learn more about creating a workspace' })).toHaveAttribute( | ||
'href', | ||
'https://docs.aws.amazon.com/iot-twinmaker/latest/guide/twinmaker-gs-workspace.html' | ||
); | ||
}); | ||
}); |
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
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
19 changes: 19 additions & 0 deletions
19
...rc/components/queryEditor/iotSiteWiseQueryEditor/dataStreamSearch/workspaceErrorState.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,19 @@ | ||
import React from 'react'; | ||
import { Alert, Link, SpaceBetween } from '@cloudscape-design/components'; | ||
import { infoMessage, errorMessage } from './constants'; | ||
|
||
export const WorkspaceErrorState = () => { | ||
return ( | ||
<SpaceBetween size='s'> | ||
<Alert statusIconAriaLabel='Info' type='info' dismissible dismissAriaLabel='cancel'> | ||
{infoMessage} | ||
</Alert> | ||
<Alert statusIconAriaLabel='Error' type='error' dismissible dismissAriaLabel='cancel'> | ||
{errorMessage} | ||
<Link external href='https://docs.aws.amazon.com/iot-twinmaker/latest/guide/twinmaker-gs-workspace.html'> | ||
Learn more about creating a workspace | ||
</Link> | ||
</Alert> | ||
</SpaceBetween> | ||
); | ||
}; |
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
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