Skip to content
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

feat: tests for root post delete helper plugin #182

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
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
66 changes: 66 additions & 0 deletions data/test-cases/plugins/post-delete-helper/test_1.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
---
# (Required) Ensure all values are filled up
name: "Installation and uninstallation of the Post Delete Helper Plugin"
status: Active
priority: Normal
folder: Post Delete Helper
authors: "@saturninoabril"
team_ownership:
- Deployment Eng
priority_p1_to_p4: P2 - Core Functions (Do core functions work?)

# (Optional)
location: Plugins
component: null
tags: []
labels: []
tested_by_contributor: ""

# (Optional) Test type and tools
cypress: N/A
detox: N/A
mmctl: N/A
playwright: N/A
rainforest: []
manual_test_environments: []

# Do not change
id: null
key: null
created_on: null
last_updated: null
case_hashed: null
steps_hashed: null

---

**Step 1**

Install Across Different Server Setups

1. Obtain the plugin by either downloading it from the [repository](https://github.com/mattermost/mattermost-plugin-post-delete-helper) or by building it from source.
2. Upload the plugin to the Mattermost server.
3. Perform sanity check
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be more explicit about what is involved in the sanity check? E.g. Can the plugin be started and stopped? Or, given the steps to follow that test the plugin functionality, maybe the "sanity check" step isn't needed here?

Also, a nit: should have a . at the end of the sentence for consistency. :)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Steps 1 and 2 cover general plugin functionality. To make it more plugin-specific, I've added "perform sanity check," which could focus on a core function (deleting a root post). However, I’ve kept the details minimal, as it could correspond to any of the tests from 2 to 7. However, as I read again, looks good to remove step 3. (I'll update but will wait for the other comment).

Thanks!


**Expected**

The plugin should install and uninstall without any issues across different server setups, including:

- Server Editions: All
- Licensing: With or without a license
- Hosting: Self-hosted only, Cloud does not allow plugin upload
- Deployment: Single-tenant or High-Availability setup

The plugin should perform its intended functionality (delete root posts without deleting the thread) correctly without errors or unexpected behavior.

---

**Step 2**

Install Plugin on Supported and Unsupported Server Versions

1. Attempt to install the plugin on both supported and unsupported Mattermost server versions.

**Expected**

The plugin should install successfully only on supported versions. The minimum supported server version is `6.2.1`.
51 changes: 51 additions & 0 deletions data/test-cases/plugins/post-delete-helper/test_2.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
---
# (Required) Ensure all values are filled up
name: "Verify 'Remove root post' Post Option Availability"
status: Active
priority: Normal
folder: Post Delete Helper
authors: "@saturninoabril"
team_ownership:
- Deployment Eng
priority_p1_to_p4: P2 - Core Functions (Do core functions work?)

# (Optional)
location: Plugins
component: null
tags: []
labels: []
tested_by_contributor: ""

# (Optional) Test type and tools
cypress: N/A
detox: N/A
mmctl: N/A
playwright: N/A
rainforest: []
manual_test_environments: []

# Do not change
id: null
key: null
created_on: null
last_updated: null
case_hashed: null
steps_hashed: null

---

**Step 1**

1. Confirm that the "Remove root post" option is available in the "Message Actions" menu of posts, except for:

- System messages
- Not a root post
- Root post without any reply
- Posts where the user lacks permission to edit
- Posts created after the edit time limit has expired

2. Create posts of each type listed above and confirm that the "Remove root post" option is not available.

**Expected**

The "Remove root post" option should not appear in the "Message Actions" menu for the specified posts.
59 changes: 59 additions & 0 deletions data/test-cases/plugins/post-delete-helper/test_3.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
---
# (Required) Ensure all values are filled up
name: "Delete a root post"
status: Active
priority: Normal
folder: Post Delete Helper
authors: "@saturninoabril"
team_ownership:
- Deployment Eng
priority_p1_to_p4: P2 - Core Functions (Do core functions work?)

# (Optional)
location: Plugins
component: null
tags: []
labels: []
tested_by_contributor: ""

# (Optional) Test type and tools
cypress: N/A
detox: N/A
mmctl: N/A
playwright: N/A
rainforest: []
manual_test_environments: []

# Do not change
id: null
key: null
created_on: null
last_updated: null
case_hashed: null
steps_hashed: null

---

**Step 1**

1. Post a root message with one or more replies. A root post could be:
- with or without attachments
- with or without reactions
- with attachment only and without message
2. Verify that the "Remove root post" option is visible in the root post's menu.
3. Select "Remove root post".

**Expected**

The "Remove root post" option should be available for a root post. When selected, the root message is replaced with `*Deleted*` (default), attachments and reactions are removed, the root post is marked as `Edited`, and the thread remains unchanged. After deletion, the "Remove root post" option is no longer visible for the root post.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should steps also be added to verify:

  1. After root post is deleted, reaction should not be able to be added. In my testing, I am able to click to add a reaction to the deleted root post, and it appears briefly then disappears. Seems the reaction should not be available to add at all?
  2. After root post is deleted, it should not be editable, correct? I am able to edit the Deleted message after deleting a root post.
  3. After a root post is deleted, should users still be able to reply in that thread? I am able to. Perhaps a test should be added to verify the expected behavior either way?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch Linda! Let's hear from @wiggin77 then I'll update accordingly.

  • For 1 and 2, I raised a similar concern about the "Delete" (menu option in red) but I was told such option cannot be suppressed from the plugin. Maybe the same is true for other post options?
  • For 2, I can click "Edit" and enter a change but on save, it didn't take effect. The text remain as is (with *Deleted*).
  • For 3, it may make sense to not allow replying to a deleted root post but I'll defer to DE.

**Step 2**

1. Navigate to `System Console > PLUGINS > Post Delete Helper` and change the `Message text to be used after deletion` to a custom value (e.g. `(root post deleted)`)
2. Post a root message with one or more replies.
3. Verify that the "Remove root post" option is visible in the root post's menu.
4. Select "Remove root post".

**Expected**

The "Remove root post" option should be available for the root post. When selected, the root message is replaced with the custom text `(root post deleted)`, the root post is marked as `Edited`, and the thread remains unchanged.
61 changes: 61 additions & 0 deletions data/test-cases/plugins/post-delete-helper/test_4.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
---
# (Required) Ensure all values are filled up
name: "Permission-Based Root Post Deletion"
status: Active
priority: Normal
folder: Post Delete Helper
authors: "@saturninoabril"
team_ownership:
- Deployment Eng
priority_p1_to_p4: P2 - Core Functions (Do core functions work?)

# (Optional)
location: Plugins
component: null
tags: []
labels: []
tested_by_contributor: ""

# (Optional) Test type and tools
cypress: N/A
detox: N/A
mmctl: N/A
playwright: N/A
rainforest: []
manual_test_environments: []

# Do not change
id: null
key: null
created_on: null
last_updated: null
case_hashed: null
steps_hashed: null

---

**Step 1**

1. Create two threads: one with a root post where the user has the `Edit Own Posts` permission (configured in `System Console > Permission`), and another without such permission.
2. Check if the "Remove root post" option is available for each root post.
3. If available, select "Remove root post".

**Expected**

- The "Remove root post" option should be available only for root posts where the user has permission to edit their own posts.
- When the root post is deleted by its own user with the correct permission, the root post message is replaced with `*Deleted*` (default), marked as `Edited`, and the thread remains unchanged.
- If the user lacks permission, the option to delete the root post should not be available.

---

**Step 2**

1. Post two threads: one with root post where the user has `Edit Others' Posts` permission (configured in `System Console > Permission`), and another without such permission.
2. Verify if the "Remove root post" option is available for each root post.
3. If available, select "Remove root post".

**Expected**

- The "Remove root post" option should be available only for root posts where the user has permission to edit others' posts.
- When the root post is deleted by other user with the correct permission, the root post message is replaced with `*Deleted*` (default), marked as `Edited`, and the thread remains unchanged.
- If the user lacks permission, the option to delete the root post of others should not be available.
48 changes: 48 additions & 0 deletions data/test-cases/plugins/post-delete-helper/test_5.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
---
# (Required) Ensure all values are filled up
name: "Root Post Deletion with Time Limit"
status: Active
priority: Normal
folder: Post Delete Helper
authors: "@saturninoabril"
team_ownership:
- Deployment Eng
priority_p1_to_p4: P2 - Core Functions (Do core functions work?)

# (Optional)
location: Plugins
component: null
tags: []
labels: []
tested_by_contributor: ""

# (Optional) Test type and tools
cypress: N/A
detox: N/A
mmctl: N/A
playwright: N/A
rainforest: []
manual_test_environments: []

# Do not change
id: null
key: null
created_on: null
last_updated: null
case_hashed: null
steps_hashed: null

---

**Step 1**

1. Enable `Edit Own Posts` in `System Console > Permission` and set the `Edit Post Time Limit` (e.g., `60` seconds).
2. Post a thread and delete the root post within the time limit.
3. Post another thread, then verify whether the "Remove root post" option is still available after the time limit has expired.

**Expected**

- The "Remove root post" option should only be available within the edit time limit.
- Deleting within the time limit successfully deleted the root post with its message replaced with `*Deleted*` (default) and the post is marked as `Edited`, and its thread remains unchanged.
- Once the edit time limit has passed, the option to remove the root post should no longer be available.
- These expectations apply both to users who own the post and users with permission to edit others' posts.
67 changes: 67 additions & 0 deletions data/test-cases/plugins/post-delete-helper/test_6.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
---
# (Required) Ensure all values are filled up
name: "Delete Root Post via Slash Command"
status: Active
priority: Normal
folder: Post Delete Helper
authors: "@saturninoabril"
team_ownership:
- Deployment Eng
priority_p1_to_p4: P2 - Core Functions (Do core functions work?)

# (Optional)
location: Plugins
component: null
tags: []
labels: []
tested_by_contributor: ""

# (Optional) Test type and tools
cypress: N/A
detox: N/A
mmctl: N/A
playwright: N/A
rainforest: []
manual_test_environments: []

# Do not change
id: null
key: null
created_on: null
last_updated: null
case_hashed: null
steps_hashed: null

---

**Step 1**

1. Post a thread, retrieve its root post ID, and execute the slash command `/deleterootpost <root_post_id>`.

**Expected**

- No autocompletion is available when typing `/deleterootpost`.
- A dialog appears with the header `Delete Root Post` and the message `Are you sure you want to delete this post? The thread will remain.`, along with `Cancel` and `Delete` buttons.
- Selecting `Cancel` keeps the attachment intact.
- Selecting `Delete` successfully deletes the root post provided all deletion conditions are met. Otherwise, a system message appears in the channel indicating the reason for failure, such as:
- `Can't delete root post: Invalid post ID` if `root_post_id` is not valid.
- `Can't delete root post: Post does not exist` if `root_post_id` cannot be found.
- `Can't delete root post: Not authorized` if the user has no permission.
- `Can't delete root post: Post is too old to edit` if the edit time limit has expired.

**Step 2**

1. Create a root post without any replies, retrieve its post ID, and execute the slash command `/deleterootpost <root_post_id>`.

**Expected**

- The `Delete Root Post` dialog should not appear, and the post should not be deleted, as the root post has no replies.
saturninoabril marked this conversation as resolved.
Show resolved Hide resolved


**Step 3**

1. Post a thread, retrieve the post ID of any reply within the thread, and execute the slash command `/deleterootpost <post_id>`.

**Expected**

- The `Delete Root Post` dialog should not appear, and the post should not be deleted, as the command is intended only for root posts.
saturninoabril marked this conversation as resolved.
Show resolved Hide resolved
Loading