Skip to content

Commit

Permalink
Merge branch 'master' into segment-proxy
Browse files Browse the repository at this point in the history
  • Loading branch information
Hyperkid123 authored Jul 21, 2023
2 parents 39be9ba + 9781d80 commit 93ef5a9
Show file tree
Hide file tree
Showing 7 changed files with 76 additions and 40 deletions.
1 change: 1 addition & 0 deletions cypress.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
16 changes: 11 additions & 5 deletions cypress/e2e/spec.cy.ts
Original file line number Diff line number Diff line change
@@ -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();
}
);
});
10 changes: 4 additions & 6 deletions cypress/support/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
);
Expand Down
52 changes: 28 additions & 24 deletions src/analytics/resetIntegrations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
});
};
1 change: 1 addition & 0 deletions src/components/AllServices/allServicesLinks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import AllServicesIcons from './AllServicesIcons';
export type AllServicesLink = {
href: string;
title: string;
subtitle?: string;
description?: string;
isExternal?: boolean;
prod?: boolean;
Expand Down
10 changes: 7 additions & 3 deletions src/components/AllServicesDropdown/AllServicesGalleryLink.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -68,8 +68,12 @@ const AllServicesGalleryLink = ({ href, title, description, isExternal }: AllSer
</SplitItem>
</Split>
<TextContent>
{/* do not show bundle if the card title matches bundle title */}
<Text component="small">{bundle !== title ? bundle : null}</Text>
{/*
if subtitle is not set use bundle
do not show bundle if the card title matches bundle title
*/}
<Text component="small">{subtitle || (bundle !== title ? bundle : null)}</Text>
<Text component="small" className="pf-u-color-100">
{description ?? ''}
</Text>
Expand Down
26 changes: 24 additions & 2 deletions src/utils/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -338,17 +338,39 @@ 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',
Expires: '0',
};

export const loadFedModules = async () =>
axios.get(`${getChromeStaticPathname('modules')}/fed-modules.json`, {
// 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,
})
.catch(loadCSCFedModules),
axios.get(getChromeDynamicPaths()).catch(() => ({ data: {} })),
]).then(([staticConfig, feoConfig]) => {
if (feoConfig?.data?.chrome) {
staticConfig.data.chrome = feoConfig?.data?.chrome;
}
return staticConfig;
});

export const generateRoutesList = (modules: { [key: string]: ChromeModule }) =>
Object.entries(modules)
.reduce<RouteDefinition[]>(
Expand Down

0 comments on commit 93ef5a9

Please sign in to comment.