From eadebb006096eb92ab09544c85a2ba1161b4f3d0 Mon Sep 17 00:00:00 2001 From: rocketchat-github-ci Date: Fri, 16 Feb 2024 20:22:41 +0000 Subject: [PATCH 1/9] Bump 6.6.1 --- .changeset/bump-patch-1708114961345.md | 5 +++++ yarn.lock | 22 +++++++++++----------- 2 files changed, 16 insertions(+), 11 deletions(-) create mode 100644 .changeset/bump-patch-1708114961345.md diff --git a/.changeset/bump-patch-1708114961345.md b/.changeset/bump-patch-1708114961345.md new file mode 100644 index 0000000000000..e1eaa7980afb1 --- /dev/null +++ b/.changeset/bump-patch-1708114961345.md @@ -0,0 +1,5 @@ +--- +'@rocket.chat/meteor': patch +--- + +Bump @rocket.chat/meteor version. diff --git a/yarn.lock b/yarn.lock index 6d568be3e6476..e43d51516fe1d 100644 --- a/yarn.lock +++ b/yarn.lock @@ -9341,16 +9341,16 @@ __metadata: typescript: ~5.3.2 peerDependencies: "@rocket.chat/apps-engine": "*" - "@rocket.chat/eslint-config": 0.6.1-rc.0 + "@rocket.chat/eslint-config": 0.6.1 "@rocket.chat/fuselage": "*" "@rocket.chat/fuselage-hooks": "*" "@rocket.chat/fuselage-polyfills": "*" "@rocket.chat/icons": "*" "@rocket.chat/prettier-config": "*" "@rocket.chat/styled": "*" - "@rocket.chat/ui-contexts": 4.0.0-rc.4 - "@rocket.chat/ui-kit": 0.33.0-rc.0 - "@rocket.chat/ui-video-conf": 4.0.0-rc.4 + "@rocket.chat/ui-contexts": 4.0.0 + "@rocket.chat/ui-kit": 0.33.0 + "@rocket.chat/ui-video-conf": 4.0.0 "@tanstack/react-query": "*" react: "*" react-dom: "*" @@ -9432,14 +9432,14 @@ __metadata: ts-jest: ~29.1.1 typescript: ~5.3.2 peerDependencies: - "@rocket.chat/core-typings": 6.6.0-rc.4 + "@rocket.chat/core-typings": 6.6.0 "@rocket.chat/css-in-js": "*" "@rocket.chat/fuselage": "*" "@rocket.chat/fuselage-tokens": "*" "@rocket.chat/message-parser": "*" "@rocket.chat/styled": "*" - "@rocket.chat/ui-client": 4.0.0-rc.4 - "@rocket.chat/ui-contexts": 4.0.0-rc.4 + "@rocket.chat/ui-client": 4.0.0 + "@rocket.chat/ui-contexts": 4.0.0 katex: "*" react: "*" languageName: unknown @@ -10621,7 +10621,7 @@ __metadata: "@rocket.chat/fuselage": "*" "@rocket.chat/fuselage-hooks": "*" "@rocket.chat/icons": "*" - "@rocket.chat/ui-contexts": 4.0.0-rc.4 + "@rocket.chat/ui-contexts": 4.0.0 react: ~17.0.2 languageName: unknown linkType: soft @@ -10796,7 +10796,7 @@ __metadata: "@rocket.chat/fuselage-hooks": "*" "@rocket.chat/icons": "*" "@rocket.chat/styled": "*" - "@rocket.chat/ui-contexts": 4.0.0-rc.4 + "@rocket.chat/ui-contexts": 4.0.0 react: ^17.0.2 react-dom: ^17.0.2 languageName: unknown @@ -10884,8 +10884,8 @@ __metadata: typescript: ~5.3.2 peerDependencies: "@rocket.chat/layout": "*" - "@rocket.chat/tools": 0.2.1-rc.0 - "@rocket.chat/ui-contexts": 4.0.0-rc.4 + "@rocket.chat/tools": 0.2.1 + "@rocket.chat/ui-contexts": 4.0.0 "@tanstack/react-query": "*" react: "*" react-hook-form: "*" From 8686d41394fab8cd66a0118b507cca75600e0f38 Mon Sep 17 00:00:00 2001 From: Pierre Lehnen <55164754+pierre-lehnen-rc@users.noreply.github.com> Date: Thu, 15 Feb 2024 18:31:51 -0300 Subject: [PATCH 2/9] fix: Custom OAuth not working if other login services are also enabled (#31753) --- .changeset/lucky-ducks-join.md | 5 +++++ apps/meteor/client/startup/customOAuth.ts | 2 +- apps/meteor/tests/e2e/config/global-setup.ts | 3 +++ .../tests/e2e/fixtures/addCustomOAuth.ts | 18 ++++++++++++++++ apps/meteor/tests/e2e/oauth.spec.ts | 21 +++++++++++++++++++ apps/meteor/tests/e2e/page-objects/auth.ts | 4 ++++ 6 files changed, 52 insertions(+), 1 deletion(-) create mode 100644 .changeset/lucky-ducks-join.md create mode 100644 apps/meteor/tests/e2e/fixtures/addCustomOAuth.ts diff --git a/.changeset/lucky-ducks-join.md b/.changeset/lucky-ducks-join.md new file mode 100644 index 0000000000000..e64661b0841b0 --- /dev/null +++ b/.changeset/lucky-ducks-join.md @@ -0,0 +1,5 @@ +--- +'@rocket.chat/meteor': patch +--- + +Fixed an issue where the login button for Custom OAuth services would not work if any non-custom login service was also available diff --git a/apps/meteor/client/startup/customOAuth.ts b/apps/meteor/client/startup/customOAuth.ts index 1b9060f84e3a7..5796814444cfc 100644 --- a/apps/meteor/client/startup/customOAuth.ts +++ b/apps/meteor/client/startup/customOAuth.ts @@ -7,7 +7,7 @@ Meteor.startup(() => { loginServices.onLoad((services) => { for (const service of services) { if (!('custom' in service && service.custom)) { - return; + continue; } new CustomOAuth(service.service, { diff --git a/apps/meteor/tests/e2e/config/global-setup.ts b/apps/meteor/tests/e2e/config/global-setup.ts index 6e2d750d59385..d273ffc831080 100644 --- a/apps/meteor/tests/e2e/config/global-setup.ts +++ b/apps/meteor/tests/e2e/config/global-setup.ts @@ -1,3 +1,4 @@ +import addCustomOAuth from '../fixtures/addCustomOAuth'; import injectInitialData from '../fixtures/inject-initial-data'; import insertApp from '../fixtures/insert-apps'; @@ -5,4 +6,6 @@ export default async function (): Promise { await injectInitialData(); await insertApp(); + + await addCustomOAuth(); } diff --git a/apps/meteor/tests/e2e/fixtures/addCustomOAuth.ts b/apps/meteor/tests/e2e/fixtures/addCustomOAuth.ts new file mode 100644 index 0000000000000..10a80a7710a9e --- /dev/null +++ b/apps/meteor/tests/e2e/fixtures/addCustomOAuth.ts @@ -0,0 +1,18 @@ +import { request } from '@playwright/test'; + +import { BASE_API_URL } from '../config/constants'; +import { Users } from './userStates'; + +export default async function addCustomOAuth(): Promise { + const api = await request.newContext(); + + const headers = { + 'X-Auth-Token': Users.admin.data.loginToken, + 'X-User-Id': Users.admin.data.username, + }; + + await api.post(`${BASE_API_URL}/settings.addCustomOAuth`, { data: { name: 'Test' }, headers }); + await api.post(`${BASE_API_URL}/settings/Accounts_OAuth_Custom-Test`, { data: { value: false }, headers }); + await api.post(`${BASE_API_URL}/settings/Accounts_OAuth_Custom-Test-url`, { data: { value: 'https://rocket.chat' }, headers }); + await api.post(`${BASE_API_URL}/settings/Accounts_OAuth_Custom-Test-login_style`, { data: { value: 'redirect' }, headers }); +} diff --git a/apps/meteor/tests/e2e/oauth.spec.ts b/apps/meteor/tests/e2e/oauth.spec.ts index 8d53fa9503b43..c93dc5a4f7dbe 100644 --- a/apps/meteor/tests/e2e/oauth.spec.ts +++ b/apps/meteor/tests/e2e/oauth.spec.ts @@ -19,6 +19,19 @@ test.describe('OAuth', () => { await expect(poRegistration.btnLoginWithGoogle).toBeVisible(); }); + await test.step('expect Custom OAuth button to be visible', async () => { + await expect((await setSettingValueById(api, 'Accounts_OAuth_Custom-Test', true)).status()).toBe(200); + await page.waitForTimeout(5000); + await page.goto('/home'); + + await expect(poRegistration.btnLoginWithCustomOAuth).toBeVisible(); + }); + + await test.step('expect redirect to the configured URL.', async () => { + await poRegistration.btnLoginWithCustomOAuth.click(); + await expect(page).toHaveURL(/https\:\/\/(www)?\.rocket\.chat/); + }); + await test.step('expect OAuth button to not be visible', async () => { await expect((await setSettingValueById(api, 'Accounts_OAuth_Google', false)).status()).toBe(200); await page.waitForTimeout(5000); @@ -26,5 +39,13 @@ test.describe('OAuth', () => { await page.goto('/home'); await expect(poRegistration.btnLoginWithGoogle).not.toBeVisible(); }); + + await test.step('expect Custom OAuth button to not be visible', async () => { + await expect((await setSettingValueById(api, 'Accounts_OAuth_Custom-Test', false)).status()).toBe(200); + await page.waitForTimeout(5000); + + await page.goto('/home'); + await expect(poRegistration.btnLoginWithCustomOAuth).not.toBeVisible(); + }); }); }); diff --git a/apps/meteor/tests/e2e/page-objects/auth.ts b/apps/meteor/tests/e2e/page-objects/auth.ts index 98421f6461ab7..d3e5a3bcb964d 100644 --- a/apps/meteor/tests/e2e/page-objects/auth.ts +++ b/apps/meteor/tests/e2e/page-objects/auth.ts @@ -28,6 +28,10 @@ export class Registration { return this.page.locator('role=button[name="Sign in with Google"]'); } + get btnLoginWithCustomOAuth(): Locator { + return this.page.locator('role=button[name="Sign in with Test"]'); + } + get goToRegister(): Locator { return this.page.locator('role=link[name="Create an account"]'); } From cd9887113055d1223ef59e8508d5bfba3ce0d61d Mon Sep 17 00:00:00 2001 From: gabriellsh <40830821+gabriellsh@users.noreply.github.com> Date: Thu, 15 Feb 2024 15:36:00 -0300 Subject: [PATCH 3/9] fix: User presence not updating (#31723) Co-authored-by: dougfabris --- .changeset/large-toys-matter.md | 5 +++++ apps/meteor/app/notifications/client/index.ts | 1 + apps/meteor/app/notifications/client/lib/Presence.ts | 4 +++- apps/meteor/client/importPackages.ts | 1 + 4 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 .changeset/large-toys-matter.md create mode 100644 apps/meteor/app/notifications/client/index.ts diff --git a/.changeset/large-toys-matter.md b/.changeset/large-toys-matter.md new file mode 100644 index 0000000000000..5dae3df44a466 --- /dev/null +++ b/.changeset/large-toys-matter.md @@ -0,0 +1,5 @@ +--- +"@rocket.chat/meteor": patch +--- + +fixed an issue with the user presence not updating automatically for other users. diff --git a/apps/meteor/app/notifications/client/index.ts b/apps/meteor/app/notifications/client/index.ts new file mode 100644 index 0000000000000..47c2de4137407 --- /dev/null +++ b/apps/meteor/app/notifications/client/index.ts @@ -0,0 +1 @@ +import './lib/Presence'; diff --git a/apps/meteor/app/notifications/client/lib/Presence.ts b/apps/meteor/app/notifications/client/lib/Presence.ts index 3cfc98c440c2f..8cff2ed84f617 100644 --- a/apps/meteor/app/notifications/client/lib/Presence.ts +++ b/apps/meteor/app/notifications/client/lib/Presence.ts @@ -8,6 +8,8 @@ import { Presence } from '../../../../client/lib/presence'; new Meteor.Streamer('user-presence'); -Meteor.StreamerCentral.on('stream-user-presence', (uid: string, username: string, statusChanged?: UserStatus, statusText?: string) => { +type args = [username: string, statusChanged?: UserStatus, statusText?: string]; + +Meteor.StreamerCentral.on('stream-user-presence', (uid: string, [username, statusChanged, statusText]: args) => { Presence.notify({ _id: uid, username, status: statusChanged, statusText }); }); diff --git a/apps/meteor/client/importPackages.ts b/apps/meteor/client/importPackages.ts index ba1bf01862352..99898097b24e5 100644 --- a/apps/meteor/client/importPackages.ts +++ b/apps/meteor/client/importPackages.ts @@ -15,6 +15,7 @@ import '../app/iframe-login/client'; import '../app/lib/client'; import '../app/message-mark-as-unread/client'; import '../app/nextcloud/client'; +import '../app/notifications/client'; import '../app/otr/client'; import '../app/slackbridge/client'; import '../app/slashcommands-archiveroom/client'; From e7ebd44f22e3aa8cf36eca99128e446feaeec387 Mon Sep 17 00:00:00 2001 From: gabriellsh <40830821+gabriellsh@users.noreply.github.com> Date: Thu, 15 Feb 2024 16:15:21 -0300 Subject: [PATCH 4/9] fix: Blinking UI colors when finishing a Livechat conversation. (#31752) Co-authored-by: Martin Schoeler <20868078+MartinSchoeler@users.noreply.github.com> --- .changeset/silver-chicken-learn.md | 5 +++++ packages/livechat/src/lib/room.js | 4 +++- 2 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 .changeset/silver-chicken-learn.md diff --git a/.changeset/silver-chicken-learn.md b/.changeset/silver-chicken-learn.md new file mode 100644 index 0000000000000..3257849ba45c9 --- /dev/null +++ b/.changeset/silver-chicken-learn.md @@ -0,0 +1,5 @@ +--- +"@rocket.chat/livechat": patch +--- + +fixed livechat UI blinking different colors when the chat is finished diff --git a/packages/livechat/src/lib/room.js b/packages/livechat/src/lib/room.js index ad447726d9b00..1e4f975f18861 100644 --- a/packages/livechat/src/lib/room.js +++ b/packages/livechat/src/lib/room.js @@ -29,7 +29,9 @@ export const closeChat = async ({ transcriptRequested } = {}) => { if (clearLocalStorageWhenChatEnded) { // exclude UI-affecting flags - const { minimized, visible, undocked, expanded, businessUnit, ...initial } = initialState(); + const { iframe: currentIframe } = store.state; + const { minimized, visible, undocked, expanded, businessUnit, config, iframe, ...initial } = initialState(); + initial.iframe = { ...currentIframe, guest: {} }; await store.setState(initial); } From f473c580e87d257813edd1e2d787dd445cd0fc44 Mon Sep 17 00:00:00 2001 From: Shivang Yadav <125182653+shivang-16@users.noreply.github.com> Date: Mon, 5 Feb 2024 20:28:55 +0530 Subject: [PATCH 5/9] fix: Favoriting room through rooms page (#31554) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Henrique GuimarĂ£es Ribeiro <43561537+rique223@users.noreply.github.com> --- .changeset/serious-cows-compete.md | 5 +++++ .../client/views/admin/rooms/EditRoom.tsx | 11 +++++----- .../Info/EditRoomInfo/EditRoomInfo.tsx | 10 ++++----- apps/meteor/tests/e2e/administration.spec.ts | 22 +++++++++++++++++++ apps/meteor/tests/e2e/page-objects/admin.ts | 16 ++++++++++++++ 5 files changed, 54 insertions(+), 10 deletions(-) create mode 100644 .changeset/serious-cows-compete.md diff --git a/.changeset/serious-cows-compete.md b/.changeset/serious-cows-compete.md new file mode 100644 index 0000000000000..be419a9bd9cda --- /dev/null +++ b/.changeset/serious-cows-compete.md @@ -0,0 +1,5 @@ +--- +"@rocket.chat/meteor": patch +--- + +Fixed a bug on the rooms page's "Favorite" setting, which previously failed to designate selected rooms as favorites by default. diff --git a/apps/meteor/client/views/admin/rooms/EditRoom.tsx b/apps/meteor/client/views/admin/rooms/EditRoom.tsx index f6c3a0db04f12..bc9899bd438d4 100644 --- a/apps/meteor/client/views/admin/rooms/EditRoom.tsx +++ b/apps/meteor/client/views/admin/rooms/EditRoom.tsx @@ -13,7 +13,7 @@ import { TextAreaInput, FieldError, } from '@rocket.chat/fuselage'; -import { useMutableCallback, useUniqueId } from '@rocket.chat/fuselage-hooks'; +import { useEffectEvent, useUniqueId } from '@rocket.chat/fuselage-hooks'; import { useEndpoint, useRouter, useToastMessageDispatch, useTranslation } from '@rocket.chat/ui-contexts'; import React from 'react'; import { useForm, Controller } from 'react-hook-form'; @@ -96,9 +96,10 @@ const EditRoom = ({ room, onChange, onDelete }: EditRoomProps) => { const handleArchive = useArchiveRoom(room); - const handleUpdateRoomData = useMutableCallback(async ({ isDefault, roomName, favorite, ...formData }) => { + const handleUpdateRoomData = useEffectEvent(async ({ isDefault, roomName, favorite, ...formData }) => { const data = getDirtyFields(formData, dirtyFields); delete data.archived; + delete data.favorite; try { await saveAction({ @@ -117,9 +118,9 @@ const EditRoom = ({ room, onChange, onDelete }: EditRoomProps) => { } }); - const handleSave = useMutableCallback(async (data) => { - await Promise.all([isDirty && handleUpdateRoomData(data), changeArchiving && handleArchive()].filter(Boolean)); - }); + const handleSave = useEffectEvent((data) => + Promise.all([isDirty && handleUpdateRoomData(data), changeArchiving && handleArchive()].filter(Boolean)), + ); const formId = useUniqueId(); const roomNameField = useUniqueId(); diff --git a/apps/meteor/client/views/room/contextualBar/Info/EditRoomInfo/EditRoomInfo.tsx b/apps/meteor/client/views/room/contextualBar/Info/EditRoomInfo/EditRoomInfo.tsx index 09268dc6a43a1..2a9397364757a 100644 --- a/apps/meteor/client/views/room/contextualBar/Info/EditRoomInfo/EditRoomInfo.tsx +++ b/apps/meteor/client/views/room/contextualBar/Info/EditRoomInfo/EditRoomInfo.tsx @@ -20,7 +20,7 @@ import { Box, TextAreaInput, } from '@rocket.chat/fuselage'; -import { useMutableCallback, useUniqueId } from '@rocket.chat/fuselage-hooks'; +import { useEffectEvent, useUniqueId } from '@rocket.chat/fuselage-hooks'; import type { TranslationKey } from '@rocket.chat/ui-contexts'; import { useSetting, useTranslation, useToastMessageDispatch, useEndpoint } from '@rocket.chat/ui-contexts'; import React, { useMemo } from 'react'; @@ -98,7 +98,7 @@ const EditRoomInfo = ({ room, onClickClose, onClickBack }: EditRoomInfoProps) => const handleArchive = useArchiveRoom(room); - const handleUpdateRoomData = useMutableCallback(async ({ hideSysMes, joinCodeRequired, ...formData }) => { + const handleUpdateRoomData = useEffectEvent(async ({ hideSysMes, joinCodeRequired, ...formData }) => { const data = getDirtyFields(formData, dirtyFields); delete data.archived; @@ -119,9 +119,9 @@ const EditRoomInfo = ({ room, onClickClose, onClickBack }: EditRoomInfoProps) => } }); - const handleSave = useMutableCallback(async (data) => { - await Promise.all([isDirty && handleUpdateRoomData(data), changeArchiving && handleArchive()].filter(Boolean)); - }); + const handleSave = useEffectEvent((data) => + Promise.all([isDirty && handleUpdateRoomData(data), changeArchiving && handleArchive()].filter(Boolean)), + ); const formId = useUniqueId(); const roomNameField = useUniqueId(); diff --git a/apps/meteor/tests/e2e/administration.spec.ts b/apps/meteor/tests/e2e/administration.spec.ts index 6df7e425c3969..8c3bd5c23f6be 100644 --- a/apps/meteor/tests/e2e/administration.spec.ts +++ b/apps/meteor/tests/e2e/administration.spec.ts @@ -87,6 +87,28 @@ test.describe.parallel('administration', () => { await poAdmin.getRoomRow(targetChannel).click(); await expect(poAdmin.archivedInput).toBeChecked(); }); + + test.describe.serial('Default rooms', () => { + test('expect target channell to be default', async () => { + await poAdmin.inputSearchRooms.type(targetChannel); + await poAdmin.getRoomRow(targetChannel).click(); + await poAdmin.defaultLabel.click(); + await poAdmin.btnSave.click(); + + await poAdmin.getRoomRow(targetChannel).click(); + await expect(poAdmin.defaultInput).toBeChecked(); + }); + + test('should mark target default channel as "favorite by default"', async () => { + await poAdmin.inputSearchRooms.type(targetChannel); + await poAdmin.getRoomRow(targetChannel).click(); + await poAdmin.favoriteLabel.click(); + await poAdmin.btnSave.click(); + + await poAdmin.getRoomRow(targetChannel).click(); + await expect(poAdmin.favoriteInput).toBeChecked(); + }); + }); }); test.describe('Permissions', () => { diff --git a/apps/meteor/tests/e2e/page-objects/admin.ts b/apps/meteor/tests/e2e/page-objects/admin.ts index 17e5185becaf7..022fd609077f9 100644 --- a/apps/meteor/tests/e2e/page-objects/admin.ts +++ b/apps/meteor/tests/e2e/page-objects/admin.ts @@ -36,6 +36,22 @@ export class Admin { return this.page.locator('input[name="archived"]'); } + get favoriteLabel(): Locator { + return this.page.locator('label >> text=Favorite'); + } + + get favoriteInput(): Locator { + return this.page.locator('input[name="favorite"]'); + } + + get defaultLabel(): Locator { + return this.page.locator('label >> text=Default'); + } + + get defaultInput(): Locator { + return this.page.locator('input[name="isDefault"]'); + } + get inputSearchUsers(): Locator { return this.page.locator('input[placeholder="Search Users"]'); } From 37cb8bb5a2ec83f6956b6cbde10e3b28bf1494fc Mon Sep 17 00:00:00 2001 From: Douglas Fabris Date: Thu, 15 Feb 2024 12:05:31 -0300 Subject: [PATCH 6/9] fix: Admin can't change room name (#31713) --- .changeset/curly-dodos-tan.md | 5 +++++ apps/meteor/client/views/admin/rooms/EditRoom.tsx | 3 +-- apps/meteor/tests/e2e/administration.spec.ts | 15 +++++++++++++-- apps/meteor/tests/e2e/page-objects/admin.ts | 4 ++++ 4 files changed, 23 insertions(+), 4 deletions(-) create mode 100644 .changeset/curly-dodos-tan.md diff --git a/.changeset/curly-dodos-tan.md b/.changeset/curly-dodos-tan.md new file mode 100644 index 0000000000000..939f212754993 --- /dev/null +++ b/.changeset/curly-dodos-tan.md @@ -0,0 +1,5 @@ +--- +'@rocket.chat/meteor': patch +--- + +Fixes an issue not allowing admin users to edit the room name diff --git a/apps/meteor/client/views/admin/rooms/EditRoom.tsx b/apps/meteor/client/views/admin/rooms/EditRoom.tsx index bc9899bd438d4..18edd8cc815aa 100644 --- a/apps/meteor/client/views/admin/rooms/EditRoom.tsx +++ b/apps/meteor/client/views/admin/rooms/EditRoom.tsx @@ -96,7 +96,7 @@ const EditRoom = ({ room, onChange, onDelete }: EditRoomProps) => { const handleArchive = useArchiveRoom(room); - const handleUpdateRoomData = useEffectEvent(async ({ isDefault, roomName, favorite, ...formData }) => { + const handleUpdateRoomData = useEffectEvent(async ({ isDefault, favorite, ...formData }) => { const data = getDirtyFields(formData, dirtyFields); delete data.archived; delete data.favorite; @@ -104,7 +104,6 @@ const EditRoom = ({ room, onChange, onDelete }: EditRoomProps) => { try { await saveAction({ rid: room._id, - roomName: roomType === 'd' ? undefined : roomName, default: isDefault, favorite: { defaultValue: isDefault, favorite }, ...data, diff --git a/apps/meteor/tests/e2e/administration.spec.ts b/apps/meteor/tests/e2e/administration.spec.ts index 8c3bd5c23f6be..2a359bd47f5a9 100644 --- a/apps/meteor/tests/e2e/administration.spec.ts +++ b/apps/meteor/tests/e2e/administration.spec.ts @@ -70,7 +70,18 @@ test.describe.parallel('administration', () => { await page.waitForSelector('[qa-room-id="GENERAL"]'); }); - test('should edit target channel', async () => { + test('should edit target channel name', async () => { + await poAdmin.inputSearchRooms.fill(targetChannel); + await poAdmin.getRoomRow(targetChannel).click(); + await poAdmin.roomNameInput.fill(`${targetChannel}-edited`); + await poAdmin.btnSave.click(); + + await expect(poAdmin.getRoomRow(targetChannel)).toContainText(`${targetChannel}-edited`); + + targetChannel = `${targetChannel}-edited`; + }); + + test('should edit target channel type', async () => { await poAdmin.inputSearchRooms.type(targetChannel); await poAdmin.getRoomRow(targetChannel).click(); await poAdmin.privateLabel.click(); @@ -89,7 +100,7 @@ test.describe.parallel('administration', () => { }); test.describe.serial('Default rooms', () => { - test('expect target channell to be default', async () => { + test('expect target channel to be default', async () => { await poAdmin.inputSearchRooms.type(targetChannel); await poAdmin.getRoomRow(targetChannel).click(); await poAdmin.defaultLabel.click(); diff --git a/apps/meteor/tests/e2e/page-objects/admin.ts b/apps/meteor/tests/e2e/page-objects/admin.ts index 022fd609077f9..30b58cd29becf 100644 --- a/apps/meteor/tests/e2e/page-objects/admin.ts +++ b/apps/meteor/tests/e2e/page-objects/admin.ts @@ -28,6 +28,10 @@ export class Admin { return this.page.locator(`label >> text=Private`); } + get roomNameInput(): Locator { + return this.page.locator('input[name="roomName"]'); + } + get archivedLabel(): Locator { return this.page.locator('label >> text=Archived'); } From c9ffde02f5f5c5abc04cf8c11b82c1d4a9ab022c Mon Sep 17 00:00:00 2001 From: Diego Sampaio Date: Mon, 19 Feb 2024 17:36:25 -0300 Subject: [PATCH 7/9] ci: improve change logs by using PR number from commit msg --- .../release-changelog/src/getGitHubInfo.ts | 105 +++++------------- packages/release-changelog/src/index.ts | 50 +++------ 2 files changed, 38 insertions(+), 117 deletions(-) diff --git a/packages/release-changelog/src/getGitHubInfo.ts b/packages/release-changelog/src/getGitHubInfo.ts index e3579d220108d..7d4152f46bf73 100644 --- a/packages/release-changelog/src/getGitHubInfo.ts +++ b/packages/release-changelog/src/getGitHubInfo.ts @@ -23,6 +23,7 @@ function makeQuery(repos: ReposWithCommitsAndPRsToFetch) { ? `a${data.commit}: object(expression: ${JSON.stringify(data.commit)}) { ... on Commit { commitUrl + message associatedPullRequests(first: 50) { nodes { number @@ -44,6 +45,7 @@ function makeQuery(repos: ReposWithCommitsAndPRsToFetch) { }}` : `pr__${data.pull}: pullRequest(number: ${data.pull}) { url + authorAssociation author { login url @@ -123,15 +125,15 @@ const GHDataLoader = new DataLoader(async (requests: RequestData[]) => { return requests.map(({ repo, ...data }) => cleanedData[repo][data.kind][data.kind === 'pull' ? data.pull : data.commit]); }); -type UserType = { login: string; association: 'CONTRIBUTOR' | 'MEMBER' | 'OWNER' } | null; - -export async function getInfo(request: { commit: string; repo: string }): Promise<{ - user: UserType; - pull: number | null; - links: { - commit: string; - pull: string | null; - user: string | null; +export async function getCommitInfo(request: { commit: string; repo: string; pr?: number }): Promise<{ + pull?: { + number: number; + url: string; + }; + author: { + association: string; + login: string; + url: string; }; }> { if (!request.commit) { @@ -149,84 +151,27 @@ export async function getInfo(request: { commit: string; repo: string }): Promis } const data = await GHDataLoader.load({ kind: 'commit', ...request }); - let user = null; - if (data.author?.user) { - user = { association: 'MEMBER', ...data.author.user }; - } - - const associatedPullRequest = data.associatedPullRequests?.nodes?.length - ? (data.associatedPullRequests.nodes as any[]).sort((a, b) => { - if (a.mergedAt === null && b.mergedAt === null) { - return 0; - } - if (a.mergedAt === null) { - return 1; - } - if (b.mergedAt === null) { - return -1; - } - a = new Date(a.mergedAt); - b = new Date(b.mergedAt); - if (a > b) { - return 1; - } - - return a < b ? -1 : 0; - })[0] - : null; - if (associatedPullRequest) { - user = { - association: associatedPullRequest.authorAssociation, - ...associatedPullRequest.author, + const prMatch = data.message.match(/\(#(\d+)\)$/m); + if (!prMatch && !request.pr) { + return { + author: { login: data.author.login, url: data.author.url, association: 'MEMBER' }, }; } - return { - user, - pull: associatedPullRequest ? associatedPullRequest.number : null, - links: { - commit: `[\`${request.commit.slice(0, 7)}\`](${data.commitUrl})`, - pull: associatedPullRequest ? `[#${associatedPullRequest.number}](${associatedPullRequest.url})` : null, - user: user ? `[@${user.login}](${user.url})` : null, - }, - }; -} - -export async function getInfoFromPullRequest(request: { pull: number; repo: string }): Promise<{ - user: UserType; - commit: string | null; - links: { - commit: string | null; - pull: string; - user: string | null; - }; -}> { - if (request.pull === undefined) { - throw new Error('Please pass a pull request number'); - } - - if (!request.repo) { - throw new Error('Please pass a GitHub repository in the form of userOrOrg/repoName to getInfo'); - } - if (!validRepoNameRegex.test(request.repo)) { - throw new Error( - `Please pass a valid GitHub repository in the form of userOrOrg/repoName to getInfo (it has to match the "${validRepoNameRegex.source}" pattern)`, - ); - } - - const data = await GHDataLoader.load({ kind: 'pull', ...request }); - const user = data?.author; + const pr = request.pr || Number(prMatch[1]); - const commit = data?.mergeCommit; + const pullRequest = await GHDataLoader.load({ kind: 'pull', pull: pr, repo: request.repo }); return { - user: user ? user.login : null, - commit: commit ? commit.abbreviatedOid : null, - links: { - commit: commit ? `[\`${commit.abbreviatedOid.slice(0, 7)}\`](${commit.commitUrl})` : null, - pull: `[#${request.pull}](https://github.com/${request.repo}/pull/${request.pull})`, - user: user ? `[@${user.login}](${user.url})` : null, + pull: { + number: pr, + url: pullRequest.url, + }, + author: { + login: pullRequest.author.login, + url: pullRequest.author.url, + association: pullRequest.authorAssociation, }, }; } diff --git a/packages/release-changelog/src/index.ts b/packages/release-changelog/src/index.ts index dc33606f7730a..3f6206396ec9b 100644 --- a/packages/release-changelog/src/index.ts +++ b/packages/release-changelog/src/index.ts @@ -1,6 +1,6 @@ import type { ChangelogFunctions } from '@changesets/types'; -import { getInfo, getInfoFromPullRequest } from './getGitHubInfo'; +import { getCommitInfo } from './getGitHubInfo'; const changelogFunctions: ChangelogFunctions = { getReleaseLine: async (changeset, _type, options) => { @@ -33,41 +33,17 @@ const changelogFunctions: ChangelogFunctions = { const [firstLine, ...futureLines] = replacedChangelog.split('\n').map((l) => l.trimEnd()); const links = await (async () => { - if (prFromSummary !== undefined) { - const result = await getInfoFromPullRequest({ - repo: options.repo, - pull: prFromSummary, - }); - - let { links } = result; - if (commitFromSummary) { - const shortCommitId = commitFromSummary.slice(0, 7); - links = { - ...links, - commit: `[\`${shortCommitId}\`](https://github.com/${options.repo}/commit/${commitFromSummary})`, - }; - } - - const { user } = result; - - return { - ...links, - user, - }; - } const commitToFetchFrom = commitFromSummary || changeset.commit; - if (commitToFetchFrom) { - const { links, user } = await getInfo({ - repo: options.repo, - commit: commitToFetchFrom, - }); - return { ...links, user }; + if (!commitToFetchFrom) { + return; } - return { - commit: null, - pull: null, - user: null, - }; + + const { author, pull } = await getCommitInfo({ + repo: options.repo, + commit: commitToFetchFrom, + pr: prFromSummary, + }); + return { pull, author }; })(); const users = (() => { @@ -75,13 +51,13 @@ const changelogFunctions: ChangelogFunctions = { return usersFromSummary.map((userFromSummary) => `[@${userFromSummary}](https://github.com/${userFromSummary})`).join(', '); } - if (links.user?.association === 'CONTRIBUTOR') { - return `[@${links.user.login}](https://github.com/${links.user.login})`; + if (links?.author?.association === 'CONTRIBUTOR') { + return `[@${links.author.login}](https://github.com/${links.author.login})`; } })(); const prefix = [ - links.pull === null ? '' : links.pull, + links?.pull ? `#${links?.pull?.number}` : '', // links.commit === null ? '' : links.commit, users ? `by ${users}` : '', ] From 8ae68800a7bb6d68495ec13b40728ccf45252eb0 Mon Sep 17 00:00:00 2001 From: Diego Sampaio Date: Mon, 19 Feb 2024 17:57:49 -0300 Subject: [PATCH 8/9] ci: use full PR link on release notes --- packages/release-changelog/src/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/release-changelog/src/index.ts b/packages/release-changelog/src/index.ts index 3f6206396ec9b..d36c268a01c17 100644 --- a/packages/release-changelog/src/index.ts +++ b/packages/release-changelog/src/index.ts @@ -57,7 +57,7 @@ const changelogFunctions: ChangelogFunctions = { })(); const prefix = [ - links?.pull ? `#${links?.pull?.number}` : '', + links?.pull ? `[#${links?.pull?.number}](${links?.pull?.url})` : '', // links.commit === null ? '' : links.commit, users ? `by ${users}` : '', ] From 98853a16e2b745cd3ac88ea4f009b4b1a26206df Mon Sep 17 00:00:00 2001 From: gabriellsh <40830821+gabriellsh@users.noreply.github.com> Date: Mon, 19 Feb 2024 21:09:34 -0300 Subject: [PATCH 9/9] ci: end-to-end tests breaking (#31789) --- apps/meteor/tests/e2e/fixtures/userStates.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/meteor/tests/e2e/fixtures/userStates.ts b/apps/meteor/tests/e2e/fixtures/userStates.ts index f21405a94f02e..860242d576933 100644 --- a/apps/meteor/tests/e2e/fixtures/userStates.ts +++ b/apps/meteor/tests/e2e/fixtures/userStates.ts @@ -15,7 +15,7 @@ export type IUserState = { }; function generateContext(username: string): IUserState { - const date = new Date('2023-02-17T20:38:12.306Z'); + const date = new Date(); date.setFullYear(date.getFullYear() + 1); const token = {