-
Notifications
You must be signed in to change notification settings - Fork 170
feat(drive-integration): display validationFindings in mapping-review UI [INTEG-4383] #11087
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
david-shibley-contentful
wants to merge
4
commits into
master
Choose a base branch
from
feat/drive-integration-integ-4383
base: master
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.
+275
−5
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
ea9efab
feat(drive-integration): display validationFindings in mapping-review…
david-shibley-contentful 733fe25
style(drive-integration): apply prettier formatting [INTEG-4383]
david-shibley-contentful 956958d
refactor(drive-integration): address PR review comments [INTEG-4383]
david-shibley-contentful 9b356de
style(drive-integration): apply prettier formatting [INTEG-4383]
david-shibley-contentful 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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -125,6 +125,25 @@ export interface TabsImagesSuspendPayload { | |
| tabs?: DocTabOption[]; | ||
| } | ||
|
|
||
| export enum ValidationFindingSeverity { | ||
| Block = 'block', | ||
| Warn = 'warn', | ||
| } | ||
|
|
||
| /** A single validation finding from the validate-payload step. */ | ||
| export interface ValidationFinding { | ||
| /** Machine-readable finding code. */ | ||
| code: string; | ||
| /** Human-readable explanation. */ | ||
| message: string; | ||
| /** `block` findings prevent advancing; `warn` findings are advisory. */ | ||
| severity: ValidationFindingSeverity; | ||
| /** Zero-based entry index, when entry-scoped. */ | ||
| entryIndex?: number; | ||
| /** Field ID, when field-scoped. */ | ||
| fieldId?: string; | ||
| } | ||
|
|
||
| export interface MappingReviewSuspendPayload { | ||
| reason?: string; | ||
| suspendStepId: 'mapping-review'; | ||
|
|
@@ -134,6 +153,7 @@ export interface MappingReviewSuspendPayload { | |
| entryBlockGraph: EntryBlockGraph; | ||
| referenceGraph: ReviewedReferenceGraph; | ||
| contentTypes: WorkflowContentType[]; | ||
| validationFindings?: ValidationFinding[]; | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ⛏️Nit: I would remove the comment |
||
| } | ||
|
|
||
| export type WorkflowRunResult = | ||
|
|
||
111 changes: 111 additions & 0 deletions
111
apps/drive-integration/test/locations/Page/components/overview/OverviewEntryList.spec.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,111 @@ | ||
| import { cleanup, render, screen } from '@testing-library/react'; | ||
| import { afterEach, describe, expect, it, vi } from 'vitest'; | ||
| import { ValidationFindingSeverity } from '@types'; | ||
| import type { ValidationFinding } from '@types'; | ||
| import type { EntryListRow } from '../../../../../src/utils/overviewEntryList'; | ||
| import { OverviewEntryList } from '../../../../../src/locations/Page/components/overview/OverviewEntryList'; | ||
|
|
||
| const makeRow = (entryIndex: number, label: string): EntryListRow => ({ | ||
| id: `row-${entryIndex}`, | ||
| entryIndex, | ||
| contentTypeName: 'Article', | ||
| entryTitle: label, | ||
| children: [], | ||
| }); | ||
|
|
||
| const renderList = ( | ||
| rows: EntryListRow[], | ||
| findingsByEntryIndex?: ReadonlyMap<number, ValidationFinding[]> | ||
| ) => | ||
| render( | ||
| <OverviewEntryList | ||
| rows={rows} | ||
| selectedEntryIndex={null} | ||
| selectedEntryKeys={new Set()} | ||
| onSelect={vi.fn()} | ||
| onToggleEntrySelection={vi.fn()} | ||
| findingsByEntryIndex={findingsByEntryIndex} | ||
| /> | ||
| ); | ||
|
|
||
| afterEach(() => cleanup()); | ||
|
|
||
| describe('OverviewEntryList — validation finding badges (INTEG-4383)', () => { | ||
| it('renders a "Needs attention" badge for entries with block findings', () => { | ||
| const rows = [makeRow(0, 'Entry A')]; | ||
| const findings: ValidationFinding[] = [ | ||
| { | ||
| code: 'required-field-missing', | ||
| message: 'title missing', | ||
| severity: ValidationFindingSeverity.Block, | ||
| entryIndex: 0, | ||
| }, | ||
| ]; | ||
| renderList(rows, new Map([[0, findings]])); | ||
|
|
||
| expect(screen.getByText('Needs attention')).toBeTruthy(); | ||
| expect(screen.queryByText('Warning')).toBeNull(); | ||
| }); | ||
|
|
||
| it('renders a "Warning" badge for entries with only warn findings', () => { | ||
| const rows = [makeRow(0, 'Entry A')]; | ||
| const findings: ValidationFinding[] = [ | ||
| { | ||
| code: 'displayField-blank', | ||
| message: 'title blank', | ||
| severity: ValidationFindingSeverity.Warn, | ||
| entryIndex: 0, | ||
| }, | ||
| ]; | ||
| renderList(rows, new Map([[0, findings]])); | ||
|
|
||
| expect(screen.getByText('Warning')).toBeTruthy(); | ||
| expect(screen.queryByText('Needs attention')).toBeNull(); | ||
| }); | ||
|
|
||
| it('renders "Needs attention" (not Warning) when entry has both block and warn findings', () => { | ||
| const rows = [makeRow(0, 'Entry A')]; | ||
| const findings: ValidationFinding[] = [ | ||
| { | ||
| code: 'required-field-missing', | ||
| message: 'title missing', | ||
| severity: ValidationFindingSeverity.Block, | ||
| entryIndex: 0, | ||
| }, | ||
| { | ||
| code: 'displayField-blank', | ||
| message: 'title blank', | ||
| severity: ValidationFindingSeverity.Warn, | ||
| entryIndex: 0, | ||
| }, | ||
| ]; | ||
| renderList(rows, new Map([[0, findings]])); | ||
|
|
||
| expect(screen.getByText('Needs attention')).toBeTruthy(); | ||
| expect(screen.queryByText('Warning')).toBeNull(); | ||
| }); | ||
|
|
||
| it('renders no finding badges when findingsByEntryIndex is undefined', () => { | ||
| const rows = [makeRow(0, 'Entry A')]; | ||
| renderList(rows, undefined); | ||
|
|
||
| expect(screen.queryByText('Needs attention')).toBeNull(); | ||
| expect(screen.queryByText('Warning')).toBeNull(); | ||
| }); | ||
|
|
||
| it('renders no finding badges for entries with no findings', () => { | ||
| const rows = [makeRow(0, 'Entry A'), makeRow(1, 'Entry B')]; | ||
| const findings: ValidationFinding[] = [ | ||
| { | ||
| code: 'required-field-missing', | ||
| message: 'title missing', | ||
| severity: ValidationFindingSeverity.Block, | ||
| entryIndex: 1, | ||
| }, | ||
| ]; | ||
| renderList(rows, new Map([[1, findings]])); | ||
|
|
||
| // Only entry 1 should have the badge | ||
| expect(screen.getAllByText('Needs attention')).toHaveLength(1); | ||
| }); | ||
| }); |
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"No mapped content"and"Needs attention"/"Warning"are rendered as sibling<Badge>elements in a<Paragraph>. If an entry simultaneously has no mapped content type AND a block finding, both badges appear.Perhaps this is an expected behavior but since the PR didn't mention about this, just wanted to double check it with you!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch — this is intentional. An entry with no mapped content fields that also has a block finding (e.g. a required field is missing) would legitimately show both. The badges serve different purposes: "No mapped content" means none of the field mappings have any source refs, while "Needs attention" means the validate-payload step flagged a structural issue. They're not mutually exclusive so showing both makes sense here.