Skip to content

Commit 2470d2d

Browse files
lerouxbCopilot
andauthored
fix: clear the errors in the insert document modal when there are no errors COMPASS-3246 (#7157)
* clear the errors in the insert document modal when there are no errors * Update packages/compass-crud/src/components/insert-document-dialog.tsx Co-authored-by: Copilot <[email protected]> --------- Co-authored-by: Copilot <[email protected]>
1 parent 71f0259 commit 2470d2d

File tree

3 files changed

+18
-0
lines changed

3 files changed

+18
-0
lines changed

packages/compass-crud/src/components/insert-document-dialog.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,8 @@ const InsertDocumentDialog: React.FC<InsertDocumentDialogProps> = ({
194194
setInvalidElements((invalidElements) =>
195195
without(invalidElements, el.uuid)
196196
);
197+
} else {
198+
setInvalidElements([]);
197199
}
198200
},
199201
[hasErrors, setInvalidElements]

packages/compass-e2e-tests/helpers/selectors.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -730,6 +730,8 @@ export const HadronDocumentClickableKey =
730730
'[data-testid="hadron-document-clickable-key"]';
731731
export const HadronDocumentKeyEditor =
732732
'[data-testid="hadron-document-key-editor"]';
733+
export const HadronDocumentTypeEditor =
734+
'[data-testid="hadron-document-type-editor"]';
733735
export const HadronDocumentValue =
734736
'[data-testid="hadron-document-element-value"]';
735737
export const HadronDocumentValueEditor =

packages/compass-e2e-tests/tests/collection-import.test.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,20 @@ describe('Collection import', function () {
241241
`${Selectors.InsertDialog} ${Selectors.HadronDocumentAddSibling}`
242242
);
243243

244+
// set the type to Date (this causes an error)
245+
await browser
246+
.$(
247+
`${Selectors.InsertDialog} ${Selectors.HadronDocumentElement}:last-child ${Selectors.HadronDocumentTypeEditor}`
248+
)
249+
.selectByAttribute('value', 'Date');
250+
251+
// set the type to String (this clears the error)
252+
await browser
253+
.$(
254+
`${Selectors.InsertDialog} ${Selectors.HadronDocumentElement}:last-child ${Selectors.HadronDocumentTypeEditor}`
255+
)
256+
.selectByAttribute('value', 'String');
257+
244258
// Add field data
245259
await browser.setValueVisible(
246260
`${Selectors.InsertDialog} ${Selectors.HadronDocumentElement}:last-child ${Selectors.HadronDocumentKeyEditor}`,

0 commit comments

Comments
 (0)