Skip to content
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
4 changes: 4 additions & 0 deletions apps/meteor/tests/e2e/feature-preview.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ test.describe.serial('feature preview', () => {

test('should show "Message" and "Navigation" feature sections', async ({ page }) => {
await page.goto('/account/feature-preview');
await page.waitForSelector('.main-content');

await expect(page.getByRole('button', { name: 'Message' })).toBeVisible();
await expect(page.getByRole('button', { name: 'Navigation' })).toBeVisible();
Expand Down Expand Up @@ -202,6 +203,9 @@ test.describe.serial('feature preview', () => {
await poHomeChannel.content.sendMessage('hello world');

const item = poHomeChannel.sidebar.getSearchRoomByName(targetChannel);

await expect(item).toBeVisible();

await poHomeChannel.sidebar.markItemAsUnread(item);
await poHomeChannel.sidebar.escSearch();

Expand Down
4 changes: 2 additions & 2 deletions apps/meteor/tests/e2e/message-mentions.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ test.describe.serial('Should not allow to send @all mention if permission to do
await expect(page).toHaveURL(`/group/${targetChannel2}`);
});
await test.step('receive notify message', async () => {
await adminPage.content.sendMessage('@all ');
await adminPage.content.sendMessage('@all ', false);
await expect(adminPage.content.lastUserMessage).toContainText('Notify all in this room is not allowed');
});
});
Expand Down Expand Up @@ -98,7 +98,7 @@ test.describe.serial('Should not allow to send @here mention if permission to do
await expect(page).toHaveURL(`/group/${targetChannel2}`);
});
await test.step('receive notify message', async () => {
await adminPage.content.sendMessage('@here ');
await adminPage.content.sendMessage('@here ', false);
await expect(adminPage.content.lastUserMessage).toContainText('Notify all in this room is not allowed');
});
});
Expand Down
20 changes: 19 additions & 1 deletion apps/meteor/tests/e2e/page-objects/fragments/home-content.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,25 @@ export class HomeContent {
await this.joinRoom();
}

async sendMessage(text: string): Promise<void> {
async sendMessage(text: string, enforce = true): Promise<void> {
await this.joinRoomIfNeeded();
await this.page.waitForSelector('[name="msg"]:not([disabled])');
await this.page.locator('[name="msg"]').fill(text);
const responsePromise = this.page.waitForResponse(
(response) =>
/api\/v1\/method.call\/sendMessage/.test(response.url()) && response.status() === 200 && response.request().method() === 'POST',
);
await this.page.getByRole('button', { name: 'Send', exact: true }).click();

if (enforce) {
const response = await (await responsePromise).json();

const mid = JSON.parse(response.message).result._id;
const messageLocator = this.getMessageById(mid);

await expect(messageLocator).toBeVisible();
await expect(messageLocator).not.toHaveClass('rcx-message--pending');
}
}

async dispatchSlashCommand(text: string): Promise<void> {
Expand Down Expand Up @@ -432,6 +446,10 @@ export class HomeContent {
return this.page.locator('[role="listitem"][aria-roledescription="message"]', { hasText: text });
}

getMessageById(id: string): Locator {
return this.page.locator(`[data-qa-type="message"][id="${id}"]`);
}

async waitForChannel(): Promise<void> {
await this.page.locator('role=main').waitFor();
await this.page.locator('role=main >> role=heading[level=1]').waitFor();
Expand Down
Loading