Skip to content

Commit

Permalink
Merge branch 'release-7.0.0' into chore/mongo
Browse files Browse the repository at this point in the history
  • Loading branch information
ggazzo authored Apr 12, 2024
2 parents 12f1156 + 7ebff42 commit 877a93b
Show file tree
Hide file tree
Showing 10 changed files with 114 additions and 52 deletions.
8 changes: 0 additions & 8 deletions .changeset/clever-guests-invent.md

This file was deleted.

6 changes: 0 additions & 6 deletions apps/meteor/server/modules/listeners/listeners.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -209,12 +209,6 @@ export class ListenersModule {
});

service.onEvent('watch.inquiries', async ({ clientAction, inquiry, diff }): Promise<void> => {
// We do not need inquiries on the client when the routing method is not manual
// When the routing method changes, client fetches inquiries again and discards the received ones
if (settings.get('Livechat_Routing_Method') !== 'Manual_Selection') {
return;
}

const type = minimongoChangeMap[clientAction] as 'added' | 'changed' | 'removed';
if (clientAction === 'removed') {
notifications.streamLivechatQueueData.emitWithoutBroadcast(inquiry._id, {
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
81 changes: 70 additions & 11 deletions apps/meteor/tests/e2e/message-actions.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,33 +122,92 @@ test.describe.serial('message-actions', () => {
});

test('expect forward message to channel', async () => {
const message = 'this is a message to forward to channel'
const message = 'this is a message to forward to channel';
await poHomeChannel.content.sendMessage(message);
await poHomeChannel.content.forwardMessage(forwardChannel)
await poHomeChannel.content.forwardMessage(forwardChannel);

await poHomeChannel.sidenav.openChat(forwardChannel);
await expect(poHomeChannel.content.lastUserMessage).toContainText(message)
await expect(poHomeChannel.content.lastUserMessage).toContainText(message);
})

test('expect forward message to team', async () => {
const message = 'this is a message to forward to team'
const message = 'this is a message to forward to team';
await poHomeChannel.content.sendMessage(message);
await poHomeChannel.content.forwardMessage(forwardTeam)
await poHomeChannel.content.forwardMessage(forwardTeam);

await poHomeChannel.sidenav.openChat(forwardTeam);
await expect(poHomeChannel.content.lastUserMessage).toContainText(message)
await expect(poHomeChannel.content.lastUserMessage).toContainText(message);
})

test('expect forward message to direct message', async () => {
const message = 'this is a message to forward to direct message'
const direct = 'RocketChat Internal Admin Test'
const message = 'this is a message to forward to direct message';
const direct = 'RocketChat Internal Admin Test';

// todo: Forward modal is using name as display and the sidebar is using username
await poHomeChannel.content.sendMessage(message);
await poHomeChannel.content.forwardMessage(direct)
await poHomeChannel.content.forwardMessage(direct);

await poHomeChannel.sidenav.openChat(ADMIN_CREDENTIALS.username);
await expect(poHomeChannel.content.lastUserMessage).toContainText(message)
await expect(poHomeChannel.content.lastUserMessage).toContainText(message);
})
});

test('expect forward text file to channel', async () => {
const filename = 'any_file.txt';
await poHomeChannel.content.sendFileMessage(filename);
await poHomeChannel.content.btnModalConfirm.click();
await expect(poHomeChannel.content.lastUserMessage).toContainText(filename);

await poHomeChannel.content.forwardMessage(forwardChannel);

await poHomeChannel.sidenav.openChat(forwardChannel);
await expect(poHomeChannel.content.lastUserMessage).toContainText(filename);
})

test('expect forward image file to channel', async () => {
const filename = 'test-image.jpeg';
await poHomeChannel.content.sendFileMessage(filename);
await poHomeChannel.content.btnModalConfirm.click();
await expect(poHomeChannel.content.lastUserMessage).toContainText(filename);

await poHomeChannel.content.forwardMessage(forwardChannel);

await poHomeChannel.sidenav.openChat(forwardChannel);
await expect(poHomeChannel.content.lastUserMessage).toContainText(filename);
})

test('expect forward pdf file to channel', async () => {
const filename = 'test_pdf_file.pdf';
await poHomeChannel.content.sendFileMessage(filename);
await poHomeChannel.content.btnModalConfirm.click();
await expect(poHomeChannel.content.lastUserMessage).toContainText(filename);

await poHomeChannel.content.forwardMessage(forwardChannel);

await poHomeChannel.sidenav.openChat(forwardChannel);
await expect(poHomeChannel.content.lastUserMessage).toContainText(filename);
})

test('expect forward audio message to channel', async () => {
const filename = 'sample-audio.mp3';
await poHomeChannel.content.sendFileMessage(filename);
await poHomeChannel.content.btnModalConfirm.click();
await expect(poHomeChannel.content.lastUserMessage).toContainText(filename);

await poHomeChannel.content.forwardMessage(forwardChannel);

await poHomeChannel.sidenav.openChat(forwardChannel);
await expect(poHomeChannel.content.lastUserMessage).toContainText(filename);
})

test('expect forward video message to channel', async () => {
const filename = 'test_video.mp4';
await poHomeChannel.content.sendFileMessage(filename);
await poHomeChannel.content.btnModalConfirm.click();
await expect(poHomeChannel.content.lastUserMessage).toContainText(filename);

await poHomeChannel.content.forwardMessage(forwardChannel);

await poHomeChannel.sidenav.openChat(forwardChannel);
await expect(poHomeChannel.content.lastUserMessage).toContainText(filename);
})
});
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,16 @@ test.describe.serial('OC - Livechat Appearance', () => {
test('OC - Livechat Appearance - Hide system messages', async ({ page }) => {
await test.step('expect to have default values', async () => {
// Clicking at the edge of the element to prevent playwright from clicking a chip by mistake
await poLivechatAppearance.inputHideSystemMessages.click({ position: { x: 0, y: 0 } });
await poLivechatAppearance.inputHideSystemMessages.locator('.rcx-icon--name-chevron-down').click();
await expect(poLivechatAppearance.findHideSystemMessageOption('uj')).toHaveAttribute('aria-selected', 'true');
await expect(poLivechatAppearance.findHideSystemMessageOption('ul')).toHaveAttribute('aria-selected', 'true');
await expect(poLivechatAppearance.findHideSystemMessageOption('livechat-close')).toHaveAttribute('aria-selected', 'true');
await poLivechatAppearance.inputHideSystemMessages.click({ position: { x: 0, y: 0 } });
await poLivechatAppearance.inputHideSystemMessages.locator('.rcx-icon--name-chevron-up').click();
});

await test.step('expect to change values', async () => {
// Clicking at the edge of the element to prevent playwright from clicking a chip by mistake
await poLivechatAppearance.inputHideSystemMessages.click({ position: { x: 0, y: 0 } });
await poLivechatAppearance.inputHideSystemMessages.locator('.rcx-icon--name-chevron-down').click();
await poLivechatAppearance.findHideSystemMessageOption('livechat_transfer_history').click();
await poLivechatAppearance.findHideSystemMessageOption('livechat-close').click();
await poLivechatAppearance.btnSave.click();
Expand All @@ -43,7 +43,7 @@ test.describe.serial('OC - Livechat Appearance', () => {
await test.step('expect to have saved changes', async () => {
await page.reload();
// Clicking at the edge of the element to prevent playwright from clicking a chip by mistake
await poLivechatAppearance.inputHideSystemMessages.click({ position: { x: 0, y: 0 } });
await poLivechatAppearance.inputHideSystemMessages.locator('.rcx-icon--name-chevron-down').click();
await expect(poLivechatAppearance.findHideSystemMessageOption('uj')).toHaveAttribute('aria-selected', 'true');
await expect(poLivechatAppearance.findHideSystemMessageOption('ul')).toHaveAttribute('aria-selected', 'true');
await expect(poLivechatAppearance.findHideSystemMessageOption('livechat_transfer_history')).toHaveAttribute('aria-selected', 'true');
Expand Down
5 changes: 4 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 @@ -79,7 +79,6 @@ export class HomeContent {
}

async forwardMessage(chatName: string) {

await this.page.locator('[data-qa-type="message"]').last().hover();
await this.page.locator('role=button[name="Forward message"]').click();

Expand Down Expand Up @@ -248,6 +247,10 @@ export class HomeContent {
await this.page.locator('[role=dialog][data-qa="DropTargetOverlay"]').dispatchEvent('drop', { dataTransfer });
}

async sendFileMessage(fileName: string): Promise<void> {
await this.page.locator('input[type=file]').setInputFiles(`./tests/e2e/fixtures/files/${fileName}`);
}

async openLastMessageMenu(): Promise<void> {
await this.page.locator('[data-qa-type="message"]').last().hover();
await this.page.locator('[data-qa-type="message"]').last().locator('role=button[name="More"]').waitFor();
Expand Down
52 changes: 30 additions & 22 deletions apps/meteor/tests/e2e/utils/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ declare global {

let apiContext: APIRequestContext;

const cacheFromCredentials = new Map<string, string>();

export const test = baseTest.extend<BaseTest>({
context: async ({ context }, use) => {
if (!process.env.E2E_COVERAGE) {
Expand Down Expand Up @@ -66,36 +68,38 @@ export const test = baseTest.extend<BaseTest>({
},

api: async ({ request }, use) => {
const newContext = async (token: string, userId: string) =>
baseRequest.newContext({
baseURL: BASE_API_URL,
extraHTTPHeaders: {
'X-Auth-Token': token,
'X-User-Id': userId,
},
});

const login = async (credentials: { username: string; password: string }): Promise<APIRequestContext> => {
if (credentials.username === Users.admin.data.username) {
return baseRequest.newContext({
baseURL: BASE_API_URL,
extraHTTPHeaders: {
'X-Auth-Token': Users.admin.data.loginToken,
'X-User-Id': Users.admin.data.username,
},
});
return newContext(Users.admin.data.loginToken, Users.admin.data.username);
}

if (cacheFromCredentials.has(credentials.username + credentials.password)) {
const token = cacheFromCredentials.get(credentials.username + credentials.password);
return newContext(token!, credentials.username);
}

const resp = await request.post(`${BASE_API_URL}/login`, { data: credentials });
const json = await resp.json();

return baseRequest.newContext({
baseURL: BASE_API_URL,
extraHTTPHeaders: {
'X-Auth-Token': json.data.authToken,
'X-User-Id': json.data.userId,
},
});
cacheFromCredentials.set(credentials.username + credentials.password, json.data.authToken);

return newContext(json.data.authToken, json.data.userId);
};

const recreateContext = async () => {
apiContext = await login(ADMIN_CREDENTIALS);
};

if (!apiContext) {
await recreateContext();
}
await recreateContext();

await use({
recreateContext,
Expand All @@ -115,11 +119,15 @@ export const test = baseTest.extend<BaseTest>({
});
},
makeAxeBuilder: async ({ page }, use) => {
const SELECT_KNOW_ISSUES = ['aria-hidden-focus', 'nested-interactive']

const makeAxeBuilder = () => new AxeBuilder({ page }).withTags(['wcag2a', 'wcag2aa', 'wcag21a', 'wcag21aa']).include('body').disableRules([...SELECT_KNOW_ISSUES]);
await use(makeAxeBuilder);
}
const SELECT_KNOW_ISSUES = ['aria-hidden-focus', 'nested-interactive'];

const makeAxeBuilder = () =>
new AxeBuilder({ page })
.withTags(['wcag2a', 'wcag2aa', 'wcag21a', 'wcag21aa'])
.include('body')
.disableRules([...SELECT_KNOW_ISSUES]);
await use(makeAxeBuilder);
},
});

export const { expect } = test;
Expand Down
6 changes: 6 additions & 0 deletions turbo.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,12 @@
"@rocket.chat/meteor#build:ci": {
"dependsOn": ["^build"],
"cache": false
},

"@rocket.chat/ddp-streamer#build": {
"dependsOn": ["^build"],
"outputs": ["dist/**"],
"inputs": ["../../../apps/meteor/server/**", "./src/**"]
}
}
}

0 comments on commit 877a93b

Please sign in to comment.