-
Notifications
You must be signed in to change notification settings - Fork 894
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Hailong Cui <[email protected]> recnetly viewed workspace Signed-off-by: Hailong Cui <[email protected]> recent Signed-off-by: Hailong Cui <[email protected]>
- Loading branch information
1 parent
eaf5fea
commit 70de058
Showing
14 changed files
with
535 additions
and
5 deletions.
There are no files selected for viewing
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
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
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
121 changes: 121 additions & 0 deletions
121
.../workspace/public/components/service_card/__snapshots__/workspace_list_card.test.tsx.snap
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
6 changes: 6 additions & 0 deletions
6
src/plugins/workspace/public/components/service_card/index.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 |
---|---|---|
@@ -0,0 +1,6 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
export { WorkspaceListCard } from './workspace_list_card'; |
66 changes: 66 additions & 0 deletions
66
src/plugins/workspace/public/components/service_card/workspace_list_card.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,66 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import React from 'react'; | ||
import { coreMock } from '../../../../../core/public/mocks'; | ||
import { fireEvent, render, waitFor } from '@testing-library/react'; | ||
import { WorkspaceListCard } from './workspace_list_card'; | ||
import { recentWorkspaceManager } from '../../recent_workspace_manager'; | ||
|
||
describe('workspace list card render normally', () => { | ||
const coreStart = coreMock.createStart(); | ||
|
||
beforeAll(() => { | ||
const workspaceList = [ | ||
{ | ||
id: 'ws-1', | ||
name: 'foo', | ||
lastUpdatedTime: new Date().toISOString(), | ||
}, | ||
{ | ||
id: 'ws-2', | ||
name: 'bar', | ||
lastUpdatedTime: new Date().toISOString(), | ||
}, | ||
]; | ||
coreStart.workspaces.workspaceList$.next(workspaceList); | ||
}); | ||
|
||
it('should show workspace list card correctly', () => { | ||
const { container } = render(<WorkspaceListCard core={coreStart} />); | ||
expect(container).toMatchSnapshot(); | ||
}); | ||
|
||
it('should show empty state if no recently viewed workspace', () => { | ||
const { getByTestId, getByText } = render(<WorkspaceListCard core={coreStart} />); | ||
expect(getByTestId('workspace_filter')).toHaveDisplayValue('Recently viewed'); | ||
|
||
// empty statue for recently viewed | ||
expect(getByText('Workspaces you have recently viewed will appear here.')).toBeInTheDocument(); | ||
}); | ||
|
||
it('should show default filter as recently viewed', () => { | ||
recentWorkspaceManager.addRecentWorkspace('foo'); | ||
const { getByTestId, getByText } = render(<WorkspaceListCard core={coreStart} />); | ||
expect(getByTestId('workspace_filter')).toHaveDisplayValue('Recently viewed'); | ||
|
||
waitFor(() => { | ||
expect(getByText('foo')).toBeInTheDocument(); | ||
}); | ||
}); | ||
|
||
it('should show updated filter correctly', () => { | ||
const { getByTestId, getByText } = render(<WorkspaceListCard core={coreStart} />); | ||
expect(getByTestId('workspace_filter')).toHaveDisplayValue('Recently viewed'); | ||
|
||
const filterSelector = getByTestId('workspace_filter'); | ||
fireEvent.change(filterSelector, { target: { value: 'updated' } }); | ||
expect(getByTestId('workspace_filter')).toHaveDisplayValue('Recently updated'); | ||
|
||
// workspace list | ||
expect(getByText('foo')).toBeInTheDocument(); | ||
expect(getByText('bar')).toBeInTheDocument(); | ||
}); | ||
}); |
Oops, something went wrong.