-
Notifications
You must be signed in to change notification settings - Fork 13.1k
fix: Prune messages form not resetting properly #35962
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
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
36ca707
Use controlled checkbox component
yash-rajpal 8671cc4
test: should reset form after pruning messages
cardoso e142fa8
Merge branch 'develop' into prune-messages-not-resetting
cardoso a0b9b21
add changeset
yash-rajpal e892c62
Merge branch 'develop' into prune-messages-not-resetting
kodiakhq[bot] d14cf19
Merge branch 'develop' into prune-messages-not-resetting
kodiakhq[bot] File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| '@rocket.chat/meteor': patch | ||
| --- | ||
|
|
||
| Fixes prune messages contextual bar not resetting form after submitting. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
apps/meteor/tests/e2e/page-objects/fragments/home-flextab-pruneMessages.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| import type { Locator, Page } from '@playwright/test'; | ||
|
|
||
| export class HomeFlextabPruneMessages { | ||
| private readonly page: Page; | ||
|
|
||
| constructor(page: Page) { | ||
| this.page = page; | ||
| } | ||
|
|
||
| private get form(): Locator { | ||
| return this.page.getByRole('dialog', { name: 'Prune Messages' }); | ||
| } | ||
|
|
||
| get doNotPrunePinned(): Locator { | ||
| return this.form.getByRole('checkbox', { name: 'Do not prune pinned messages', exact: true }); | ||
| } | ||
|
|
||
| get filesOnly(): Locator { | ||
| return this.form.getByRole('checkbox', { name: 'Only remove the attached files, keep messages', exact: true }); | ||
| } | ||
|
|
||
| async prune(): Promise<void> { | ||
| await this.form.getByRole('button', { name: 'Prune' }).click(); | ||
| return this.page | ||
| .getByRole('dialog', { name: 'Are you sure?', exact: true }) | ||
| .getByRole('button', { name: 'Yes, prune them!', exact: true }) | ||
| .click(); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| import type { Locator, Page } from '@playwright/test'; | ||
|
|
||
| export class ToastBar { | ||
| private readonly page: Page; | ||
|
|
||
| constructor(page: Page) { | ||
| this.page = page; | ||
| } | ||
|
|
||
| get content(): Locator { | ||
| return this.page.locator('.rcx-toastbar'); | ||
| } | ||
|
|
||
| get alert(): Locator { | ||
| return this.content.getByRole('alert'); | ||
| } | ||
|
|
||
| get dismiss(): Locator { | ||
| return this.content.getByRole('button', { name: 'Dismiss alert', exact: true }); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,96 @@ | ||
| import { Users } from './fixtures/userStates'; | ||
| import { HomeChannel } from './page-objects/home-channel'; | ||
| import { ToastBar } from './page-objects/toastBar'; | ||
| import { createTargetChannel, sendTargetChannelMessage } from './utils'; | ||
| import { test, expect } from './utils/test'; | ||
|
|
||
| test.use({ storageState: Users.admin.state }); | ||
|
|
||
| test.describe('prune-messages', () => { | ||
| let poHomeChannel: HomeChannel; | ||
| let poToastBar: ToastBar; | ||
| let targetChannel: string; | ||
|
|
||
| test.beforeAll('create target channel', async ({ api }) => { | ||
| targetChannel = await createTargetChannel(api, { members: [Users.admin.data.username] }); | ||
| }); | ||
|
|
||
| test.afterAll('delete target channel', async ({ api }) => { | ||
| expect((await api.post('/channels.delete', { roomName: targetChannel })).status()).toBe(200); | ||
| }); | ||
|
|
||
| test.beforeEach(async ({ page }) => { | ||
| poToastBar = new ToastBar(page); | ||
| poHomeChannel = new HomeChannel(page); | ||
|
|
||
| await page.goto(`/channel/${targetChannel}/clean-history`); | ||
| }); | ||
|
|
||
| test( | ||
| 'should reset form after pruning messages', | ||
| { | ||
| tag: '@channel', | ||
| annotation: { | ||
| type: 'issue', | ||
| description: 'https://rocketchat.atlassian.net/browse/CORE-1146', | ||
| }, | ||
| }, | ||
| async ({ api }) => { | ||
| const { | ||
| content, | ||
| tabs: { pruneMessages }, | ||
| } = poHomeChannel; | ||
| const { alert, dismiss } = poToastBar; | ||
|
|
||
| await content.sendFileMessage('any_file.txt'); | ||
| await content.descriptionInput.fill('a message with a file'); | ||
| await content.btnModalConfirm.click(); | ||
| await expect(content.lastMessageFileName).toHaveText('any_file.txt'); | ||
|
|
||
| await sendTargetChannelMessage(api, targetChannel, { | ||
| msg: 'a message without files', | ||
| }); | ||
|
|
||
| await sendTargetChannelMessage(api, targetChannel, { | ||
| msg: 'a pinned message without files', | ||
| pinned: true, | ||
| }); | ||
|
|
||
| await test.step('prune files only not pinned', async () => { | ||
| await pruneMessages.doNotPrunePinned.check({ force: true }); | ||
| await pruneMessages.filesOnly.check({ force: true }); | ||
| await pruneMessages.prune(); | ||
| await expect(alert).toHaveText('1 message pruned'); | ||
| await dismiss.click(); | ||
| await expect(pruneMessages.filesOnly, 'Checkbox is reset after success').not.toBeChecked(); | ||
| await expect(pruneMessages.doNotPrunePinned, 'Checkbox is reset after success').not.toBeChecked(); | ||
| }); | ||
|
|
||
| await test.step('prune files only again', async () => { | ||
| await pruneMessages.doNotPrunePinned.check({ force: true }); | ||
| await pruneMessages.filesOnly.check({ force: true }); | ||
| await pruneMessages.prune(); | ||
| await expect(alert).toHaveText('No messages found to prune'); | ||
| await dismiss.click(); | ||
| await expect(pruneMessages.filesOnly, 'Checkbox retains value after error').toBeChecked(); | ||
| await expect(pruneMessages.doNotPrunePinned, 'Checkbox retains value after error').toBeChecked(); | ||
| }); | ||
|
|
||
| await test.step('uncheck files only', async () => { | ||
| await pruneMessages.filesOnly.uncheck({ force: true }); | ||
| await pruneMessages.prune(); | ||
| await expect(alert).toHaveText('2 messages pruned'); | ||
| await dismiss.click(); | ||
| await expect(pruneMessages.filesOnly, 'Checkbox is reset after success').not.toBeChecked(); | ||
| }); | ||
|
|
||
| await test.step('uncheck do not prune pinned', async () => { | ||
| await pruneMessages.doNotPrunePinned.uncheck({ force: true }); | ||
| await pruneMessages.prune(); | ||
| await expect(alert).toHaveText('1 message pruned'); | ||
| await dismiss.click(); | ||
| await expect(content.lastUserMessage).not.toBeVisible(); | ||
| }); | ||
| }, | ||
| ); | ||
| }); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.