Skip to content

Remove trash success notifications #19534

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

Merged
merged 4 commits into from
Jun 27, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import { UmbRepositoryBase } from '@umbraco-cms/backoffice/repository';
export abstract class UmbRecycleBinRepositoryBase extends UmbRepositoryBase implements UmbRecycleBinRepository {
#recycleBinSource: UmbRecycleBinDataSource;
#notificationContext?: typeof UMB_NOTIFICATION_CONTEXT.TYPE;
#requestTrashSuccessNotification?: UmbNotificationHandler;
#requestRestoreSuccessNotification?: UmbNotificationHandler;

/**
Expand All @@ -48,15 +47,7 @@ export abstract class UmbRecycleBinRepositoryBase extends UmbRepositoryBase impl
* @memberof UmbRecycleBinRepositoryBase
*/
async requestTrash(args: UmbRecycleBinTrashRequestArgs) {
const { error } = await this.#recycleBinSource.trash(args);

if (!error) {
this.#requestTrashSuccessNotification?.close();
const notification = { data: { message: `Trashed` } };
this.#requestTrashSuccessNotification = this.#notificationContext?.peek('positive', notification);
}

return { error };
return this.#recycleBinSource.trash(args);
}

/**
Expand All @@ -69,6 +60,7 @@ export abstract class UmbRecycleBinRepositoryBase extends UmbRepositoryBase impl
const { error } = await this.#recycleBinSource.restore(args);

if (!error) {
// TODO: keep this notification until we refresh the tree/structure correctly after the action
this.#requestRestoreSuccessNotification?.close();
const notification = { data: { message: `Restored` } };
this.#requestRestoreSuccessNotification = this.#notificationContext?.peek('positive', notification);
Expand All @@ -83,13 +75,6 @@ export abstract class UmbRecycleBinRepositoryBase extends UmbRepositoryBase impl
* @memberof UmbRecycleBinRepositoryBase
*/
async requestEmpty() {
const { error } = await this.#recycleBinSource.empty();

if (!error) {
const notification = { data: { message: `Recycle Bin Emptied` } };
this.#notificationContext?.peek('positive', notification);
}

return this.#recycleBinSource.empty();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ test('can trash an invariant content node', {tag: '@smoke'}, async ({umbracoApi,
await umbracoUi.content.clickConfirmTrashButton();

// Assert
await umbracoUi.content.doesSuccessNotificationHaveText(NotificationConstantHelper.success.movedToRecycleBin);
await umbracoUi.content.waitForContentToBeTrashed();
expect(await umbracoApi.document.doesNameExist(contentName)).toBeFalsy();
await umbracoUi.content.isItemVisibleInRecycleBin(contentName);
expect(await umbracoApi.document.doesItemExistInRecycleBin(contentName)).toBeTruthy();
Expand All @@ -58,7 +58,7 @@ test('can trash a variant content node', async ({umbracoApi, umbracoUi}) => {
await umbracoUi.content.clickConfirmTrashButton();

// Assert
await umbracoUi.content.doesSuccessNotificationHaveText(NotificationConstantHelper.success.movedToRecycleBin);
await umbracoUi.content.waitForContentToBeTrashed();
expect(await umbracoApi.document.doesNameExist(contentName)).toBeFalsy();
await umbracoUi.content.isItemVisibleInRecycleBin(contentName);
expect(await umbracoApi.document.doesItemExistInRecycleBin(contentName)).toBeTruthy();
Expand All @@ -80,7 +80,7 @@ test('can trash a published content node', async ({umbracoApi, umbracoUi}) => {
await umbracoUi.content.clickConfirmTrashButton();

// Assert
await umbracoUi.content.doesSuccessNotificationHaveText(NotificationConstantHelper.success.movedToRecycleBin);
await umbracoUi.content.waitForContentToBeTrashed();
expect(await umbracoApi.document.doesNameExist(contentName)).toBeFalsy();
await umbracoUi.content.isItemVisibleInRecycleBin(contentName);
expect(await umbracoApi.document.doesItemExistInRecycleBin(contentName)).toBeTruthy();
Expand All @@ -107,7 +107,7 @@ test('can trash an invariant content node that references one item', async ({umb
await umbracoUi.content.clickConfirmTrashButton();

// Assert
await umbracoUi.content.doesSuccessNotificationHaveText(NotificationConstantHelper.success.movedToRecycleBin);
await umbracoUi.content.waitForContentToBeTrashed();
expect(await umbracoApi.document.doesNameExist(contentName)).toBeFalsy();
await umbracoUi.content.isItemVisibleInRecycleBin(contentName);
expect(await umbracoApi.document.doesItemExistInRecycleBin(contentName)).toBeTruthy();
Expand All @@ -134,7 +134,7 @@ test('can trash a variant content node that references one item', async ({umbrac
await umbracoUi.content.clickConfirmTrashButton();

// Assert
await umbracoUi.content.doesSuccessNotificationHaveText(NotificationConstantHelper.success.movedToRecycleBin);
await umbracoUi.content.waitForContentToBeTrashed();
expect(await umbracoApi.document.doesNameExist(contentName)).toBeFalsy();
await umbracoUi.content.isItemVisibleInRecycleBin(contentName);
expect(await umbracoApi.document.doesItemExistInRecycleBin(contentName)).toBeTruthy();
Expand Down Expand Up @@ -170,7 +170,7 @@ test('can trash an invariant content node that references more than 3 items', as
await umbracoUi.content.clickConfirmTrashButton();

// Assert
await umbracoUi.content.doesSuccessNotificationHaveText(NotificationConstantHelper.success.movedToRecycleBin);
await umbracoUi.content.waitForContentToBeTrashed();
expect(await umbracoApi.document.doesNameExist(contentName)).toBeFalsy();
await umbracoUi.content.isItemVisibleInRecycleBin(contentName);
expect(await umbracoApi.document.doesItemExistInRecycleBin(contentName)).toBeTruthy();
Expand Down Expand Up @@ -211,7 +211,7 @@ test('can trash a variant content node that references more than 3 items', async
await umbracoUi.content.clickConfirmTrashButton();

// Assert
await umbracoUi.content.doesSuccessNotificationHaveText(NotificationConstantHelper.success.movedToRecycleBin);
await umbracoUi.content.waitForContentToBeTrashed();
expect(await umbracoApi.document.doesNameExist(contentName)).toBeFalsy();
await umbracoUi.content.isItemVisibleInRecycleBin(contentName);
expect(await umbracoApi.document.doesItemExistInRecycleBin(contentName)).toBeTruthy();
Expand All @@ -226,6 +226,7 @@ test('can trash a content node with multiple cultures that references one item',
// Arrange
const firstCulture = 'en-US';
const secondCulture = 'da';
await umbracoApi.language.ensureIsoCodeNotExists(secondCulture);
await umbracoApi.language.createDanishLanguage();
// Create a content node with multiple cultures
const documentTypeId = await umbracoApi.documentType.createVariantDocumentTypeWithInvariantPropertyEditor(documentTypeName, dataTypeName, dataTypeId);
Expand All @@ -247,11 +248,11 @@ test('can trash a content node with multiple cultures that references one item',
await umbracoUi.content.clickConfirmTrashButton();

// Assert
await umbracoUi.content.doesSuccessNotificationHaveText(NotificationConstantHelper.success.movedToRecycleBin);
await umbracoUi.content.waitForContentToBeTrashed();
expect(await umbracoApi.document.doesNameExist(contentName)).toBeFalsy();
await umbracoUi.content.isItemVisibleInRecycleBin(contentName);
expect(await umbracoApi.document.doesItemExistInRecycleBin(contentName)).toBeTruthy();

// Clean
await umbracoApi.language.ensureIsoCodeNotExists(secondCulture);
});
});
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {ConstantHelper, NotificationConstantHelper, test} from '@umbraco/playwright-testhelpers';

Check notice on line 1 in tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Media/Media.spec.ts

View check run for this annotation

CodeScene Delta Analysis / CodeScene Cloud Delta Analysis (main)

✅ Getting better: Code Duplication

reduced similar code in: 'can trash a folder','can trash a media item'. Avoid duplicated, aka copy-pasted, code inside the module. More duplication lowers the code health.
import {expect} from '@playwright/test';

const mediaFileName = 'TestMediaFile';
Expand Down Expand Up @@ -116,7 +116,6 @@

// Assert
await umbracoUi.media.waitForMediaToBeTrashed();
await umbracoUi.media.doesSuccessNotificationHaveText(NotificationConstantHelper.success.movedToRecycleBin);
await umbracoUi.media.isTreeItemVisible(folderName, false);
await umbracoUi.media.isItemVisibleInRecycleBin(folderName);
expect(await umbracoApi.media.doesNameExist(folderName)).toBeFalsy();
Expand Down Expand Up @@ -180,7 +179,6 @@

// Assert
await umbracoUi.media.waitForMediaToBeTrashed();
await umbracoUi.media.doesSuccessNotificationHaveText(NotificationConstantHelper.success.movedToRecycleBin);
await umbracoUi.media.isMediaTreeItemVisible(mediaFileName, false);
await umbracoUi.media.isItemVisibleInRecycleBin(mediaFileName);
expect(await umbracoApi.media.doesNameExist(mediaFileName)).toBeFalsy();
Expand Down
Loading