From 4b10a26730ed0406d95b9875b12c1e2773b7823d Mon Sep 17 00:00:00 2001 From: Saturnino Abril <5334504+saturninoabril@users.noreply.github.com> Date: Wed, 4 Sep 2024 07:03:48 +0800 Subject: [PATCH] feat(attachment remover): hide option if no permission nor outside edit time limit --- .../plugins/attachment-remover/MM-T5618.md | 2 ++ .../plugins/attachment-remover/MM-T5620.md | 22 ++++++++++++++----- .../plugins/attachment-remover/MM-T5621.md | 8 +++---- 3 files changed, 23 insertions(+), 9 deletions(-) diff --git a/data/test-cases/plugins/attachment-remover/MM-T5618.md b/data/test-cases/plugins/attachment-remover/MM-T5618.md index 5e27c7450..d6fd21514 100644 --- a/data/test-cases/plugins/attachment-remover/MM-T5618.md +++ b/data/test-cases/plugins/attachment-remover/MM-T5618.md @@ -45,6 +45,8 @@ steps_hashed: 89aed0aabf59790c8ede1d5bed14e86026f66a255ccacad4299ba3aa43d58eb9dd - System messages - Posts without attachment +- Posts where the user lacks permission to edit +- Posts created after the edit time limit has expired 1. Create the above types of messages/posts and verify that the "Remove attachments" option is not present. diff --git a/data/test-cases/plugins/attachment-remover/MM-T5620.md b/data/test-cases/plugins/attachment-remover/MM-T5620.md index e73cc770a..60472f81b 100644 --- a/data/test-cases/plugins/attachment-remover/MM-T5620.md +++ b/data/test-cases/plugins/attachment-remover/MM-T5620.md @@ -41,12 +41,24 @@ steps_hashed: c53e077778f5b51096bb3bce8e97f7908d8213a491c7539e69fbca3730915b8904 **Step 1** -1. Post two messages with attachments: one where the user has permission to edit others' posts, and one without that permission. -2. Check if the "Remove attachments" option is available. -3. Attempt to remove attachments for both posts. +1. Post two messages with attachments: one where the user has permission to `Edit Own Posts` (configured in `System Console > Permission`), and one without that permission. +2. Check if the "Remove attachments" option is available for each post. +3. If available, remove the attachment from the post. **Expected** -- The "Remove attachments" option is available for both posts. +- The "Remove attachments" option should only be available for posts where the user has permission to edit. - If the user has permission, the attachment is removed, and the post is marked as `Edited`. -- If the user lacks permission, the attachment is not removed, and a system message displays `Can't remove attachments: Not authorized`. +- If the user lacks permission, the option to remove the attachment should not be available. + +**Step 2** + +1. Post two messages with attachments: one where the user has permission to `Edit Others' Posts` (configured in `System Console > Permission`), and one without that permission. +2. Verify if the "Remove attachments" option is available for each post. +3. If available, remove the attachment from the post. + +**Expected** + +- The "Remove attachments" option should only be available for posts where the user has permission to edit. +- If the user has permission, the attachment is removed, and the post is marked as `Edited`. +- If the user lacks permission, the option to remove the attachment should not be available. diff --git a/data/test-cases/plugins/attachment-remover/MM-T5621.md b/data/test-cases/plugins/attachment-remover/MM-T5621.md index d248cb916..7f3d85ee2 100644 --- a/data/test-cases/plugins/attachment-remover/MM-T5621.md +++ b/data/test-cases/plugins/attachment-remover/MM-T5621.md @@ -41,12 +41,12 @@ steps_hashed: 58d32b3afdadaf57f4db05833e369598d077f6c7340a791a9794587f779d9e3dd7 **Step 1** -1. Set a post edit time limit (e.g., `60` seconds). +1. Enable `Edit Own Posts` in `System Console > Permission` and set the `Edit Post Time Limit` (e.g., `60` seconds). 2. Post a message with an attachment and remove it within the time limit. -3. Post another message with an attachment and attempt to remove it after the time limit. +3. Post another message with an attachment, then check if the "Remove attachments" option is still available after the time limit has passed. **Expected** -- The "Remove attachments" option is available for both posts. +- The "Remove attachments" option should only be available within the edit time limit. - Removing within the time limit successfully removes the attachment, and the post is marked as `Edited`. -- Attempting removal after the time limit fails, with a system message: `Can't remove attachments: Post is too old to edit`. +- Once the edit time limit has passed, the option to remove the attachment should no longer be available.