From c2d9e6e71e7cbed073c8c2b64194d32778e40f44 Mon Sep 17 00:00:00 2001 From: MartinSchoeler Date: Tue, 11 Jun 2024 16:26:16 -0300 Subject: [PATCH 1/3] test(Omnichannel): EE Menu Items After Login --- ...mnichannel-enterprise-menus-logout.spec.ts | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 apps/meteor/tests/e2e/omnichannel/omnichannel-enterprise-menus-logout.spec.ts diff --git a/apps/meteor/tests/e2e/omnichannel/omnichannel-enterprise-menus-logout.spec.ts b/apps/meteor/tests/e2e/omnichannel/omnichannel-enterprise-menus-logout.spec.ts new file mode 100644 index 000000000000..057dd8bd73dc --- /dev/null +++ b/apps/meteor/tests/e2e/omnichannel/omnichannel-enterprise-menus-logout.spec.ts @@ -0,0 +1,31 @@ +import type { Page } from '@playwright/test'; + +import { ADMIN_CREDENTIALS, IS_EE } from '../config/constants'; +import injectInitialData from '../fixtures/inject-initial-data'; +import { test, expect } from '../utils/test'; + +test.describe('OC - Enterprise Menu Items After Relogin', () => { + // Create page object and redirect to home + test.beforeEach(async ({ page }: { page: Page }) => { + await page.goto('/omnichannel/current'); + + await page.locator('role=textbox[name=/username/i]').waitFor({ state: 'visible' }); + await page.locator('role=textbox[name=/username/i]').fill(ADMIN_CREDENTIALS.email); + await page.locator('[name=password]').fill(ADMIN_CREDENTIALS.password); + await page.locator('role=button[name="Login"]').click(); + + await page.locator('.main-content').waitFor(); + }); + + // Delete all data + test.afterAll(async () => { + await injectInitialData(); + }); + + test('OC - Enterprise Menu Items - Logout & Login', async ({ page }) => { + test.skip(!IS_EE); + await test.step('expect EE menu items to be visible', async () => { + await expect(page.locator('a[href="/omnichannel/tags"]')).toBeVisible(); + }); + }); +}); From 9a4938fd446a725fb403e5f1222ccac9e401b7cf Mon Sep 17 00:00:00 2001 From: Martin Schoeler Date: Tue, 11 Jun 2024 14:59:36 -0300 Subject: [PATCH 2/3] Create fuzzy-readers-bake.md --- .changeset/fuzzy-readers-bake.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/fuzzy-readers-bake.md diff --git a/.changeset/fuzzy-readers-bake.md b/.changeset/fuzzy-readers-bake.md new file mode 100644 index 000000000000..a487096a312e --- /dev/null +++ b/.changeset/fuzzy-readers-bake.md @@ -0,0 +1,5 @@ +--- +"@rocket.chat/meteor": patch +--- + +Fixes issues with loading license modules when loading the page while logged out From d9d8904a5e2cac1913935c2b8fe2db318f530217 Mon Sep 17 00:00:00 2001 From: MartinSchoeler Date: Tue, 11 Jun 2024 16:28:39 -0300 Subject: [PATCH 3/3] fix: Run QueryClient.clear() on logout only --- apps/meteor/client/providers/UserProvider/UserProvider.tsx | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/apps/meteor/client/providers/UserProvider/UserProvider.tsx b/apps/meteor/client/providers/UserProvider/UserProvider.tsx index 27c540928e86..27bba21eae95 100644 --- a/apps/meteor/client/providers/UserProvider/UserProvider.tsx +++ b/apps/meteor/client/providers/UserProvider/UserProvider.tsx @@ -4,7 +4,7 @@ import type { SubscriptionWithRoom } from '@rocket.chat/ui-contexts'; import { UserContext, useEndpoint } from '@rocket.chat/ui-contexts'; import { Meteor } from 'meteor/meteor'; import type { ContextType, ReactElement, ReactNode } from 'react'; -import React, { useEffect, useMemo } from 'react'; +import React, { useEffect, useMemo, useRef } from 'react'; import { Subscriptions, ChatRoom } from '../../../app/models/client'; import { getUserPreference } from '../../../app/utils/client'; @@ -43,6 +43,7 @@ type UserProviderProps = { const UserProvider = ({ children }: UserProviderProps): ReactElement => { const userId = useReactiveValue(getUserId); + const previousUserId = useRef(userId); const user = useReactiveValue(getUser); const [userLanguage, setUserLanguage] = useLocalStorage('userLanguage', ''); const [preferedLanguage, setPreferedLanguage] = useLocalStorage('preferedLanguage', ''); @@ -94,9 +95,11 @@ const UserProvider = ({ children }: UserProviderProps): ReactElement => { }, [preferedLanguage, setPreferedLanguage, setUserLanguage, user?.language, userLanguage, userId, setUserPreferences]); useEffect(() => { - if (!userId) { + if (previousUserId.current && previousUserId.current !== userId) { queryClient.clear(); } + + previousUserId.current = userId; }, [userId]); return ;