Repository navigation
feat: compact Healthcheck issue rows #4463
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
astandrik
wants to merge
3
commits into
main
Choose a base branch
from
codex/issue-4448-design-review
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+335
−36
Open
Changes from 1 commit
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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
64 changes: 64 additions & 0 deletions
64
src/components/EntityStatus/__test__/EntityStatus.test.tsx
This file contains hidden or 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,64 @@ | ||
| import {ThemeProvider} from '@gravity-ui/uikit'; | ||
| import {fireEvent, render, screen} from '@testing-library/react'; | ||
|
|
||
| import {EFlag} from '../../../types/api/enums'; | ||
| import {EntityStatus} from '../EntityStatus'; | ||
|
|
||
| describe('EntityStatus.Label', () => { | ||
| test.each([ | ||
| [EFlag.Red, 'Critical', 'danger'], | ||
| [EFlag.Orange, 'Caution', 'danger'], | ||
| [EFlag.Yellow, 'Warning', 'warning'], | ||
| [EFlag.Blue, 'Normal', 'info'], | ||
| [EFlag.Green, 'Good', 'success'], | ||
| [EFlag.Grey, 'Unknown', 'unknown'], | ||
| ] as const)('renders %s as an accessible compact status', async (status, name, theme) => { | ||
| const {container} = render(<EntityStatus.Label status={status} view="compact" />, { | ||
| wrapper: ThemeProvider, | ||
| }); | ||
| const icon = screen.getByRole('img', {name}); | ||
|
|
||
| expect(icon).not.toHaveAttribute('tabindex'); | ||
| expect(screen.queryByText(name)).not.toBeInTheDocument(); | ||
| expect(container.querySelector('.g-label__text')).not.toBeInTheDocument(); | ||
| expect(container.querySelector(`.g-label_theme_${theme}`)).toBeInTheDocument(); | ||
| expect(container.querySelector('.ydb-entity-status_critical')).not.toBeInTheDocument(); | ||
| expect(screen.queryByRole('button')).not.toBeInTheDocument(); | ||
|
|
||
| fireEvent.mouseEnter(icon); | ||
| expect(await screen.findByText(name)).toBeVisible(); | ||
| }); | ||
|
|
||
| test('preserves the default critical label, content and description', async () => { | ||
| const {container} = render( | ||
| <EntityStatus.Label status={EFlag.Red} endContent="extra"> | ||
| Cluster | ||
| </EntityStatus.Label>, | ||
| {wrapper: ThemeProvider}, | ||
| ); | ||
|
|
||
| expect(container).toHaveTextContent('ClusterCritical'); | ||
| expect(screen.getByText('extra')).toBeVisible(); | ||
| const label = container.getElementsByClassName('ydb-entity-status_critical')[0]; | ||
| expect(label).toBeInTheDocument(); | ||
| fireEvent.mouseEnter(label); | ||
| expect( | ||
| await screen.findByText('Critical state, requires immediate attention'), | ||
| ).toBeVisible(); | ||
| }); | ||
|
|
||
| test('preserves existing icon-and-content labels and click handlers', () => { | ||
| const onClick = jest.fn(); | ||
| const {container} = render( | ||
| <EntityStatus.Label status={EFlag.Blue} withStatusName={false} onClick={onClick}> | ||
| Replication | ||
| </EntityStatus.Label>, | ||
| {wrapper: ThemeProvider}, | ||
| ); | ||
|
|
||
| expect(container.querySelector('.g-label_theme_success')).toBeInTheDocument(); | ||
| fireEvent.click(screen.getByRole('button', {name: 'Replication'})); | ||
| expect(onClick).toHaveBeenCalledTimes(1); | ||
| expect(screen.queryByText('Normal')).not.toBeInTheDocument(); | ||
| }); | ||
| }); |
This file contains hidden or 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 hidden or 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
81 changes: 81 additions & 0 deletions
81
src/containers/Tenant/Healthcheck/components/__test__/HealthcheckIssue.test.tsx
This file contains hidden or 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,81 @@ | ||
| import {fireEvent, render, screen} from '@testing-library/react'; | ||
| import {MemoryRouter} from 'react-router-dom'; | ||
| import {QueryParamProvider} from 'use-query-params'; | ||
| import {ReactRouter5Adapter} from 'use-query-params/adapters/react-router-5'; | ||
|
|
||
| import type {IssuesTree} from '../../../../../store/reducers/healthcheckInfo/types'; | ||
| import {SelfCheckResult, StatusFlag} from '../../../../../types/api/healthcheck'; | ||
| import {HealthcheckContext} from '../../HealthcheckContext'; | ||
| import type {HealthcheckContextValue} from '../../HealthcheckContext'; | ||
| import {HealthcheckIssue} from '../HealthcheckIssue'; | ||
|
|
||
| const issue = { | ||
| id: 'vdisk-1', | ||
| message: 'VDisk is not available', | ||
| status: StatusFlag.RED, | ||
| categoryForUI: 'storage', | ||
| } satisfies IssuesTree; | ||
|
|
||
| function renderIssue(assistant?: HealthcheckContextValue['assistant'], value: IssuesTree = issue) { | ||
| return render( | ||
| <MemoryRouter> | ||
| <QueryParamProvider adapter={ReactRouter5Adapter}> | ||
| <HealthcheckContext.Provider value={{database: '/Root/db', assistant}}> | ||
| <HealthcheckIssue issue={value} /> | ||
| </HealthcheckContext.Provider> | ||
| </QueryParamProvider> | ||
| </MemoryRouter>, | ||
| ); | ||
| } | ||
|
|
||
| test('keeps the compact status before the title and the full row as the disclosure trigger', () => { | ||
| const {container} = renderIssue(); | ||
| const status = screen.getByRole('img', {name: 'Critical'}); | ||
| const title = screen.getAllByText(issue.message)[0]; | ||
| expect(status.compareDocumentPosition(title)).toBe(Node.DOCUMENT_POSITION_FOLLOWING); | ||
| const trigger = screen.getByRole('button', {name: /VDisk is not available/}); | ||
| expect(trigger).toHaveAttribute('aria-expanded', 'false'); | ||
| expect(container.querySelector('button button')).not.toBeInTheDocument(); | ||
|
|
||
| fireEvent.click(trigger); | ||
| expect(trigger).toHaveAttribute('aria-expanded', 'true'); | ||
| expect(screen.getByText('Details')).toBeInTheDocument(); | ||
| fireEvent.click(trigger); | ||
| expect(trigger).toHaveAttribute('aria-expanded', 'false'); | ||
| }); | ||
|
|
||
| test('keeps Fix independent from disclosure and passes the original issue and target', () => { | ||
| const fix = jest.fn(); | ||
| const target = { | ||
| scope: 'database' as const, | ||
| request: {database: '/Root/db', clusterName: 'test'}, | ||
| }; | ||
| const snapshot = {selfCheckResult: SelfCheckResult.EMERGENCY, issues: [issue]}; | ||
| const renderAction = jest.fn((props) => ( | ||
| <button type="button" onClick={() => fix(props)}> | ||
| Fix | ||
| </button> | ||
| )); | ||
| const {container} = renderIssue({target, snapshot, renderAction}); | ||
|
|
||
| expect(screen.getByRole('img', {name: 'Critical'})).toBeInTheDocument(); | ||
| const disclosure = screen.getByRole('button', {name: /Expand/}); | ||
| fireEvent.click(screen.getByRole('button', {name: 'Fix'})); | ||
| expect(fix).toHaveBeenCalledTimes(1); | ||
| expect(fix).toHaveBeenCalledWith({action: 'fix', issue, target, snapshot}); | ||
| expect(disclosure).toHaveAttribute('aria-expanded', 'false'); | ||
| expect(container.querySelector('button button')).not.toBeInTheDocument(); | ||
|
|
||
| fireEvent.click(screen.getAllByText(issue.message)[0]); | ||
| expect(disclosure).toHaveAttribute('aria-expanded', 'true'); | ||
| fireEvent.click(screen.getByRole('button', {name: 'Fix'})); | ||
| expect(disclosure).toHaveAttribute('aria-expanded', 'true'); | ||
| expect(screen.getByText('Details')).toBeInTheDocument(); | ||
| }); | ||
|
|
||
| test('renders a title without a status placeholder when status is absent', () => { | ||
| const {container} = renderIssue(undefined, {...issue, status: undefined}); | ||
| expect(screen.queryByRole('img')).not.toBeInTheDocument(); | ||
| expect(container.querySelector('.ydb-healthcheck__issue-status')).not.toBeInTheDocument(); | ||
| expect(screen.getByRole('button', {name: issue.message})).toBeInTheDocument(); | ||
| }); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.