Skip to content

Commit 7187d42

Browse files
committed
fixes
1 parent 09350c5 commit 7187d42

File tree

3 files changed

+11
-9
lines changed

3 files changed

+11
-9
lines changed

cypress/support/component.tsx

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ import { ThemeProvider } from '@ui5/webcomponents-react';
2020
import { mount } from 'cypress/react';
2121
// Import commands.js using ES2015 syntax:
2222
import './commands';
23-
import { FrontendConfigProvider, Landscape } from "../../src/context/FrontendConfigContext";
23+
import { FrontendConfigProvider } from "../../src/context/FrontendConfigContext";
24+
import { AuthProviderOnboarding } from '../../src/context/AuthProviderOnboarding';
2425

2526
// Augment the Cypress namespace to include type definitions for
2627
// your custom command.
@@ -38,10 +39,7 @@ declare global {
3839

3940

4041
Cypress.Commands.add('mount', (component, options) => {
41-
return mount(<ThemeProvider><FrontendConfigProvider config={{
42-
"backendUrl": "http://localhost:3000",
43-
"landscape": "DEV" as Landscape,
44-
"documentationBaseUrl": "http://localhost:3000"
45-
}}>{component} </FrontendConfigProvider></ThemeProvider>, options);
42+
return mount(<ThemeProvider><FrontendConfigProvider >
43+
<AuthProviderOnboarding>{component} </AuthProviderOnboarding></FrontendConfigProvider></ThemeProvider>, options);
4644
});
4745

src/context/FrontendConfigContext.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { ReactNode, createContext, use } from 'react';
22
import { DocLinkCreator } from '../lib/shared/links';
3+
import { isInTestingMode } from '../utils';
34

45
export enum Landscape {
56
Live = 'LIVE',
@@ -19,15 +20,16 @@ const FrontendConfigContext = createContext<FrontendConfigContextProps | null>(
1920
null,
2021
);
2122

22-
const fetchPromise = fetch('/frontend-config.json').then((res) => res.json());
23+
24+
const fetchPromise = fetch(isInTestingMode ? '/__cypress/src/frontend-config.json': '/frontend-config.json').then((res) => res.json());
2325

2426
interface FrontendConfigProviderProps {
2527
children: ReactNode;
2628
}
2729

2830
export function FrontendConfigProvider({
29-
children,
30-
}: FrontendConfigProviderProps) {
31+
children,
32+
}: FrontendConfigProviderProps) {
3133
const config = use(fetchPromise);
3234
const docLinks = new DocLinkCreator(config.documentationBaseUrl);
3335
const value: FrontendConfigContextProps = {

src/utils/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,5 @@ export const extractWorkspaceNameFromNamespace = (namespace: string) => {
1010
export const projectnameToNamespace = (projectname: string) => {
1111
return `project-${projectname}`;
1212
};
13+
14+
export const isInTestingMode:Boolean = !!window.Cypress;

0 commit comments

Comments
 (0)