-
Notifications
You must be signed in to change notification settings - Fork 891
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* Changeset file for PR #7237 created/updated * feat: remove the euispacer * feat: update empty state * feat: update i18n key * feat: update --------- (cherry picked from commit 46afb96) Signed-off-by: SuZhou-Joe <[email protected]> Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: opensearch-changeset-bot[bot] <154024398+opensearch-changeset-bot[bot]@users.noreply.github.com> (cherry picked from commit d89447b) Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
- Loading branch information
1 parent
d59e3ea
commit 7d97386
Showing
20 changed files
with
479 additions
and
10 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
feat: | ||
- [navigation-next] add recent works in new homepage ([#7237](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/7237)) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -39,4 +39,5 @@ export { | |
NavType, | ||
RightNavigationButton, | ||
RightNavigationButtonProps, | ||
createRecentNavLink, | ||
} from './header'; |
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
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
98 changes: 98 additions & 0 deletions
98
src/plugins/saved_objects_management/public/management_section/recent_work.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,98 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import React from 'react'; | ||
import { BehaviorSubject } from 'rxjs'; | ||
import { fireEvent, render } from '@testing-library/react'; | ||
import { RecentWork } from './recent_work'; | ||
import { coreMock } from '../../../../core/public/mocks'; | ||
import { ChromeRecentlyAccessedHistoryItem } from 'opensearch-dashboards/public'; | ||
import { SavedObjectWithMetadata } from '../types'; | ||
|
||
const mockedRecentItems: ChromeRecentlyAccessedHistoryItem[] = [ | ||
{ | ||
link: '/app/visualize', | ||
label: 'visualize', | ||
id: 'visualize', | ||
meta: { | ||
type: 'visualize', | ||
}, | ||
}, | ||
{ | ||
link: '/app/dashboard', | ||
label: 'dashboard', | ||
id: 'dashboard-in-workspace', | ||
workspaceId: 'workspace-id', | ||
meta: { | ||
type: 'dashboard', | ||
}, | ||
}, | ||
]; | ||
|
||
const savedObjectsFromServer: SavedObjectWithMetadata[] = [ | ||
{ | ||
type: 'visualize', | ||
id: 'visualize', | ||
attributes: {}, | ||
references: [], | ||
updated_at: '2024-07-20T00:00:00.000Z', | ||
meta: {}, | ||
}, | ||
{ | ||
type: 'dashboard', | ||
id: 'dashboard-in-workspace', | ||
attributes: {}, | ||
references: [], | ||
updated_at: '2024-07-20T00:00:01.000Z', | ||
meta: {}, | ||
}, | ||
]; | ||
|
||
const getStartMockForRecentWork = () => { | ||
const coreStartMock = coreMock.createStart(); | ||
coreStartMock.chrome.recentlyAccessed.get$.mockReturnValue(new BehaviorSubject([])); | ||
coreStartMock.chrome.navLinks.getNavLinks$.mockReturnValue(new BehaviorSubject([])); | ||
return coreStartMock; | ||
}; | ||
|
||
describe('<RecentWork />', () => { | ||
it('render with emty recent work', async () => { | ||
const { findByText } = render(<RecentWork core={getStartMockForRecentWork()} />); | ||
await findByText('No recent work'); | ||
}); | ||
|
||
it('render with recent works', async () => { | ||
const coreStartMock = getStartMockForRecentWork(); | ||
coreStartMock.http.get.mockImplementation((url) => { | ||
if (typeof url === 'string') { | ||
if ((url as string).includes(mockedRecentItems[0].id)) { | ||
return Promise.resolve(savedObjectsFromServer[0]); | ||
} else { | ||
return Promise.resolve(savedObjectsFromServer[1]); | ||
} | ||
} | ||
|
||
return Promise.reject({}); | ||
}); | ||
|
||
coreStartMock.chrome.recentlyAccessed.get$.mockReturnValue( | ||
new BehaviorSubject(mockedRecentItems) | ||
); | ||
|
||
const { findAllByTestId, getByTestId } = render(<RecentWork core={coreStartMock} />); | ||
const allCards = await findAllByTestId('recentlyCard'); | ||
expect(allCards.length).toBe(2); | ||
expect(allCards[0].querySelector('.euiCard__titleAnchor')?.textContent).toEqual( | ||
mockedRecentItems[0].label | ||
); | ||
|
||
// click the filter button | ||
fireEvent.click(getByTestId('filterButton-recently%20updated')); | ||
const allCardsAfterSort = await findAllByTestId('recentlyCard'); | ||
expect(allCardsAfterSort[0].querySelector('.euiCard__titleAnchor')?.textContent).toEqual( | ||
mockedRecentItems[1].label | ||
); | ||
}); | ||
}); |
Oops, something went wrong.