From 268c0ab39e83e5c2d0006cf4c7a15ca9254802d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Maro=C5=A1i?= Date: Thu, 20 Jul 2023 09:26:14 +0200 Subject: [PATCH 1/5] Block RH domains that break login session. --- cypress.config.ts | 1 + cypress/e2e/spec.cy.ts | 16 ++++++--- cypress/support/commands.ts | 10 +++--- src/analytics/resetIntegrations.ts | 52 ++++++++++++++++-------------- 4 files changed, 44 insertions(+), 35 deletions(-) diff --git a/cypress.config.ts b/cypress.config.ts index eb6706a16..7f472d4ea 100644 --- a/cypress.config.ts +++ b/cypress.config.ts @@ -31,6 +31,7 @@ export default defineConfig({ }, }, e2e: { + blockHosts: ['static.redhat.com', 'consent.trustarc.com', 'www.redhat.com/en/cms/ajax/site-switcher'], baseUrl: 'https://stage.foo.redhat.com:1337/beta', env: { E2E_USER: process.env.E2E_USER, diff --git a/cypress/e2e/spec.cy.ts b/cypress/e2e/spec.cy.ts index 6c31673c8..5ac316d99 100644 --- a/cypress/e2e/spec.cy.ts +++ b/cypress/e2e/spec.cy.ts @@ -1,6 +1,12 @@ -describe('empty spec', () => { - it('passes', () => { - // authenticate the session - cy.login(); - }); +describe('Test environment init', () => { + it( + 'initializes user session', + { + retries: 3, + }, + () => { + // authenticate the session + cy.login(); + } + ); }); diff --git a/cypress/support/commands.ts b/cypress/support/commands.ts index fd92921fa..dae033b9b 100644 --- a/cypress/support/commands.ts +++ b/cypress/support/commands.ts @@ -40,18 +40,16 @@ Cypress.Commands.add('login', () => { cy.session( `login-${Cypress.env('E2E_USER')}`, () => { + cy.intercept({ url: '/beta/apps/*', times: 1 }, {}); + cy.intercept({ url: '/api/', times: 4 }, {}); cy.visit('/'); - + cy.wait(1000); // login into the session cy.get('#username-verification').type(Cypress.env('E2E_USER')); cy.get('#login-show-step2').click(); cy.get('#password').type(Cypress.env('E2E_PASSWORD')); cy.get('#rh-password-verification-submit-button').click(); - - // close cookies bar - cy.get('#truste-consent-buttons').click(); - - cy.url().should('eq', `${Cypress.config().baseUrl}/`); + // cy.url().should('eq', `${Cypress.config().baseUrl}/`); }, { cacheAcrossSpecs: true } ); diff --git a/src/analytics/resetIntegrations.ts b/src/analytics/resetIntegrations.ts index 6cdeb4b00..60677e2fc 100644 --- a/src/analytics/resetIntegrations.ts +++ b/src/analytics/resetIntegrations.ts @@ -3,34 +3,38 @@ import { AnalyticsBrowser } from '@segment/analytics-next'; // reset segment integrations (pendo, intercom, ...) when API key has changed export const resetIntegrations = (client: AnalyticsBrowser) => { client.ready(() => { - const intercomDestination = client.instance?.queue.plugins.find((plugin) => plugin.name == 'Intercom Web (Actions)'); - const pendoDestination = client.instance?.queue.plugins.find((plugin) => plugin.name == 'Pendo'); + try { + const intercomDestination = client.instance?.queue.plugins.find((plugin) => plugin.name == 'Intercom Web (Actions)'); + const pendoDestination = client.instance?.queue.plugins.find((plugin) => plugin.name == 'Pendo'); - // if no intercom destination, teardown intercom if it exists - if (!intercomDestination && window.Intercom) { - window?.Intercom('shutdown'); - window.Intercom = undefined; - } - // if no pendo destination, teardown pendo if it exists - if (!pendoDestination && window.pendo) { - window.pendo?.flushNow?.(); - window.pendo?.setGuidesDisabled?.(true); - window.pendo?.stopGuides?.(); - window.pendo?.stopSendingEvents?.(); - window.pendo = undefined; - } - - // disable/enable pendo guides - if (pendoDestination && window.pendo) { - if (intercomDestination) { - // disable pendo guides + // if no intercom destination, teardown intercom if it exists + if (!intercomDestination && window.Intercom) { + window?.Intercom('shutdown'); + window.Intercom = undefined; + } + // if no pendo destination, teardown pendo if it exists + if (!pendoDestination && window.pendo) { + window.pendo?.flushNow?.(); window.pendo?.setGuidesDisabled?.(true); window.pendo?.stopGuides?.(); - } else { - // (re)enable pendo guides - window.pendo?.setGuidesDisabled?.(false); - window.pendo?.startGuides?.(); + window.pendo?.stopSendingEvents?.(); + window.pendo = undefined; + } + + // disable/enable pendo guides + if (pendoDestination && window.pendo) { + if (intercomDestination) { + // disable pendo guides + window.pendo?.setGuidesDisabled?.(true); + window.pendo?.stopGuides?.(); + } else { + // (re)enable pendo guides + window.pendo?.setGuidesDisabled?.(false); + window.pendo?.startGuides?.(); + } } + } catch (error) { + console.error('Unable to reset integrations. Reason: ', error); } }); }; From 840233359fb6e663a5f2c6bca562ab9e30c4585d Mon Sep 17 00:00:00 2001 From: AsToNlele Date: Thu, 20 Jul 2023 11:41:18 +0200 Subject: [PATCH 2/5] [RHINENG-663] - Add subtitle property in AllServices --- src/components/AllServices/allServicesLinks.ts | 1 + .../AllServicesDropdown/AllServicesGalleryLink.tsx | 10 +++++++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/components/AllServices/allServicesLinks.ts b/src/components/AllServices/allServicesLinks.ts index c561c8967..488c1b594 100644 --- a/src/components/AllServices/allServicesLinks.ts +++ b/src/components/AllServices/allServicesLinks.ts @@ -3,6 +3,7 @@ import AllServicesIcons from './AllServicesIcons'; export type AllServicesLink = { href: string; title: string; + subtitle?: string; description?: string; isExternal?: boolean; prod?: boolean; diff --git a/src/components/AllServicesDropdown/AllServicesGalleryLink.tsx b/src/components/AllServicesDropdown/AllServicesGalleryLink.tsx index 643922e4d..2c8fad47f 100644 --- a/src/components/AllServicesDropdown/AllServicesGalleryLink.tsx +++ b/src/components/AllServicesDropdown/AllServicesGalleryLink.tsx @@ -12,7 +12,7 @@ import { AllServicesDropdownContext } from './common'; export type AllServicesGalleryLinkProps = AllServicesLinkProps; -const AllServicesGalleryLink = ({ href, title, description, isExternal }: AllServicesGalleryLinkProps) => { +const AllServicesGalleryLink = ({ href, title, description, isExternal, subtitle }: AllServicesGalleryLinkProps) => { const bundle = bundleMapping[href.split('/')[1]]; const { favoritePage, unfavoritePage, favoritePages } = useFavoritePagesWrapper(); const { onLinkClick } = useContext(AllServicesDropdownContext); @@ -68,8 +68,12 @@ const AllServicesGalleryLink = ({ href, title, description, isExternal }: AllSer - {/* do not show bundle if the card title matches bundle title */} - {bundle !== title ? bundle : null} + {/* + if subtitle is not set use bundle + + do not show bundle if the card title matches bundle title + */} + {subtitle || (bundle !== title ? bundle : null)} {description ?? ''} From 74c74847c7ef8406ddad31ff4833b71a1baf164a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Maro=C5=A1i?= Date: Thu, 20 Jul 2023 16:26:52 +0200 Subject: [PATCH 3/5] Start consuming SSO url from generated FEO config. --- src/utils/common.ts | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/utils/common.ts b/src/utils/common.ts index 227321fc9..246b01f31 100644 --- a/src/utils/common.ts +++ b/src/utils/common.ts @@ -338,6 +338,10 @@ export function getChromeStaticPathname(type: 'modules' | 'navigation' | 'servic return `${CHROME_SERVICE_BASE}${chromeServiceStaticPathname[stableEnv][prodEnv]}/${type}`; } +function getChromeDynamicPaths() { + return `${isBeta() ? '/beta' : ''}/apps/chrome/operator-generated/fed-modules.json`; +} + const fedModulesheaders = { 'Cache-Control': 'no-cache', Pragma: 'no-cache', @@ -345,8 +349,14 @@ const fedModulesheaders = { }; export const loadFedModules = async () => - axios.get(`${getChromeStaticPathname('modules')}/fed-modules.json`, { - headers: fedModulesheaders, + Promise.all([ + axios.get(`${getChromeStaticPathname('modules')}/fed-modules.json`, { + headers: fedModulesheaders, + }), + axios.get(getChromeDynamicPaths()).catch(() => ({ data: {} })), + ]).then(([staticConfig, feoConfig]) => { + staticConfig.data.chrome = feoConfig?.data?.chrome; + return staticConfig; }); export const generateRoutesList = (modules: { [key: string]: ChromeModule }) => From 704f8263dbae4b71537befd2b55260a465aa2571 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Maro=C5=A1i?= Date: Thu, 20 Jul 2023 17:11:04 +0200 Subject: [PATCH 4/5] Add CSC fallback --- src/utils/common.ts | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/utils/common.ts b/src/utils/common.ts index 246b01f31..30db46a3a 100644 --- a/src/utils/common.ts +++ b/src/utils/common.ts @@ -348,11 +348,21 @@ const fedModulesheaders = { Expires: '0', }; +// FIXME: Remove once qaprodauth is dealt with +// can't use /beta because it will ge redirected by Akamai to /preview and we don't have any assets there\\ +// Always use stable +const loadCSCFedModules = () => + axios.get(`${window.location.origin}/config/chrome/fed-modules.json?ts=${Date.now()}`, { + headers: fedModulesheaders, + }); + export const loadFedModules = async () => Promise.all([ - axios.get(`${getChromeStaticPathname('modules')}/fed-modules.json`, { - headers: fedModulesheaders, - }), + axios + .get(`${getChromeStaticPathname('modules')}/fed-modules.json`, { + headers: fedModulesheaders, + }) + .catch(loadCSCFedModules), axios.get(getChromeDynamicPaths()).catch(() => ({ data: {} })), ]).then(([staticConfig, feoConfig]) => { staticConfig.data.chrome = feoConfig?.data?.chrome; From 0ae9598df6aa79972196cf366f8ffc8734eb72d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Maro=C5=A1i?= Date: Fri, 21 Jul 2023 08:41:39 +0200 Subject: [PATCH 5/5] Ensure undefined chrome is not added into module definition. --- src/utils/common.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/utils/common.ts b/src/utils/common.ts index 30db46a3a..3706a252c 100644 --- a/src/utils/common.ts +++ b/src/utils/common.ts @@ -365,7 +365,9 @@ export const loadFedModules = async () => .catch(loadCSCFedModules), axios.get(getChromeDynamicPaths()).catch(() => ({ data: {} })), ]).then(([staticConfig, feoConfig]) => { - staticConfig.data.chrome = feoConfig?.data?.chrome; + if (feoConfig?.data?.chrome) { + staticConfig.data.chrome = feoConfig?.data?.chrome; + } return staticConfig; });