Skip to content
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 17 additions & 2 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
name: Build
name: Build and Test

on:
workflow_call:

jobs:
build:
build-and-test:
runs-on: ubuntu-latest
permissions:
contents: read
Expand All @@ -16,9 +16,24 @@ jobs:
uses: actions/setup-node@cdca7365b2dadb8aad0a33bc7601856ffabcc48e # v4.3.0
with:
node-version: 22
cache: 'npm' # Added caching for faster installs

- name: Install dependencies
run: npm ci

- name: Build
run: npm run build

- name: Run Cypress Tests
run: npm run test

- name: Upload Cypress Screenshots
if: always() # Run this step even if tests fail
uses: actions/upload-artifact@v4
with:
name: cypress-screenshots
path: |
cypress/screenshots/
retention-days: 7 # Keep artifacts for 7 days
if-no-files-found: warn # Warn instead of fail if no screenshots found

15 changes: 8 additions & 7 deletions cypress/support/component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ import { ThemeProvider } from '@ui5/webcomponents-react';
import { mount } from 'cypress/react';
// Import commands.js using ES2015 syntax:
import './commands';
import { FrontendConfigProvider, Landscape } from "../../src/context/FrontendConfigContext";
import { FrontendConfigProvider } from '../../src/context/FrontendConfigContext';
import { AuthProviderOnboarding } from '../../src/context/AuthProviderOnboarding';

// Augment the Cypress namespace to include type definitions for
// your custom command.
Expand All @@ -36,12 +37,12 @@ declare global {
}



Cypress.Commands.add('mount', (component, options) => {
return mount(<ThemeProvider><FrontendConfigProvider config={{
"backendUrl": "http://localhost:3000",
"landscape": "DEV" as Landscape,
"documentationBaseUrl": "http://localhost:3000"
}}>{component} </FrontendConfigProvider></ThemeProvider>, options);
return mount(<ThemeProvider>
<FrontendConfigProvider>

{component}
</FrontendConfigProvider>
</ThemeProvider>, options);
});

8 changes: 5 additions & 3 deletions src/context/FrontendConfigContext.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { ReactNode, createContext, use } from 'react';
import { DocLinkCreator } from '../lib/shared/links';
import { isInTestingMode } from '../utils';

export enum Landscape {
Live = 'LIVE',
Expand All @@ -19,15 +20,16 @@ const FrontendConfigContext = createContext<FrontendConfigContextProps | null>(
null,
);

const fetchPromise = fetch('/frontend-config.json').then((res) => res.json());

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

interface FrontendConfigProviderProps {
children: ReactNode;
}

export function FrontendConfigProvider({
children,
}: FrontendConfigProviderProps) {
children,
}: FrontendConfigProviderProps) {
const config = use(fetchPromise);
const docLinks = new DocLinkCreator(config.documentationBaseUrl);
const value: FrontendConfigContextProps = {
Expand Down
2 changes: 2 additions & 0 deletions src/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,5 @@ export const extractWorkspaceNameFromNamespace = (namespace: string) => {
export const projectnameToNamespace = (projectname: string) => {
return `project-${projectname}`;
};

export const isInTestingMode:Boolean = !!window.Cypress;
Loading