diff --git a/packages/compass-e2e-tests/helpers/commands/set-validation.ts b/packages/compass-e2e-tests/helpers/commands/set-validation.ts index ef9e22744ee..da7e0d60265 100644 --- a/packages/compass-e2e-tests/helpers/commands/set-validation.ts +++ b/packages/compass-e2e-tests/helpers/commands/set-validation.ts @@ -18,6 +18,11 @@ export async function setValidation( // Confirm in the confirmation modal. await browser.clickVisible(Selectors.confirmationModalConfirmButton()); + // Close toast. + await browser.clickVisible( + Selectors.closeToastButton(Selectors.ValidationSuccessToast) + ); + // both buttons should become hidden if it succeeds await validationActionMessageElement.waitForDisplayed({ reverse: true, diff --git a/packages/compass-e2e-tests/helpers/selectors.ts b/packages/compass-e2e-tests/helpers/selectors.ts index a12bf9fd959..81cd84fe37a 100644 --- a/packages/compass-e2e-tests/helpers/selectors.ts +++ b/packages/compass-e2e-tests/helpers/selectors.ts @@ -1151,6 +1151,8 @@ export const ValidationActionMessage = '[data-testid="validation-action-message"]'; export const UpdateValidationButton = '[data-testid="update-validation-button"]'; +export const ValidationSuccessToast = + '[data-testid="toast-schema-validation-update"]'; export const ValidationMatchingDocumentsPreview = '[data-testid="validation-content"] [data-testid="matching-documents"] [data-testid="document-preview"]'; export const ValidationLoadMatchingDocumentsBtn = `${ValidationMatchingDocumentsPreview} [data-testid="load-sample-document"]`; diff --git a/packages/compass-schema-validation/src/modules/validation.ts b/packages/compass-schema-validation/src/modules/validation.ts index c2059e38ba7..5aec4caa407 100644 --- a/packages/compass-schema-validation/src/modules/validation.ts +++ b/packages/compass-schema-validation/src/modules/validation.ts @@ -2,6 +2,7 @@ import type { RootAction, RootState, SchemaValidationThunkAction } from '.'; import { EJSON } from 'bson'; import { parseFilter } from 'mongodb-query-parser'; import { stringify as javascriptStringify } from 'javascript-stringify'; +import { openToast } from '@mongodb-js/compass-components'; import { clearSampleDocuments } from './sample-documents'; import { zeroStateChanged } from './zero-state'; import { isLoadedChanged } from './is-loaded'; @@ -451,6 +452,8 @@ export function validationFromCollection( }; } +const toastId = 'schema-validation-update'; + /** * Save validation. */ @@ -487,6 +490,10 @@ export const saveValidation = ( } ); dispatch(fetchValidation(namespace)); + openToast(toastId, { + title: 'New validation rules applied', + variant: 'success', + }); dispatch(disableEditRules()); } catch (error) { dispatch(validationSaveFailed(error as Error));