File tree Expand file tree Collapse file tree 5 files changed +40
-13
lines changed
Expand file tree Collapse file tree 5 files changed +40
-13
lines changed Original file line number Diff line number Diff line change 1- name : Build
1+ name : Build and Test
22
33on :
44 workflow_call :
55
66jobs :
7- build :
7+ build-and-test :
88 runs-on : ubuntu-latest
99 permissions :
1010 contents : read
1616 uses : actions/setup-node@cdca7365b2dadb8aad0a33bc7601856ffabcc48e # v4.3.0
1717 with :
1818 node-version : 22
19+ cache : ' npm' # Added caching for faster installs
1920
2021 - name : Install dependencies
2122 run : npm ci
2223
2324 - name : Build
2425 run : npm run build
26+
27+ - name : Run Cypress Tests
28+ run : npm run test
29+
30+ - name : Upload Cypress Screenshots
31+ if : always() # Run this step even if tests fail
32+ uses : actions/upload-artifact@v4
33+ with :
34+ name : cypress-screenshots
35+ path : |
36+ cypress/screenshots/
37+ retention-days : 7 # Keep artifacts for 7 days
38+ if-no-files-found : warn # Warn instead of fail if no screenshots found
39+
Original file line number Diff line number Diff line change @@ -20,7 +20,8 @@ import { ThemeProvider } from '@ui5/webcomponents-react';
2020import { mount } from 'cypress/react' ;
2121// Import commands.js using ES2015 syntax:
2222import './commands' ;
23- import { FrontendConfigProvider , Landscape } from "../../src/context/FrontendConfigContext" ;
23+ import { FrontendConfigContext } from '../../src/context/FrontendConfigContext' ;
24+ import { mockedFrontendConfig } from '../../src/utils/testing' ;
2425
2526// Augment the Cypress namespace to include type definitions for
2627// your custom command.
@@ -36,12 +37,11 @@ declare global {
3637}
3738
3839
39-
4040Cypress . 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 ) ;
41+ return mount ( < ThemeProvider >
42+ < FrontendConfigContext value = { mockedFrontendConfig } >
43+ { component }
44+ </ FrontendConfigContext >
45+ </ ThemeProvider > , options ) ;
4646} ) ;
4747
Original file line number Diff line number Diff line change @@ -6,6 +6,7 @@ export enum Landscape {
66 Canary = 'CANARY' ,
77 Staging = 'STAGING' ,
88 Development = 'DEV' ,
9+ Local = 'LOCAL' ,
910}
1011
1112interface FrontendConfigContextProps {
@@ -15,19 +16,18 @@ interface FrontendConfigContextProps {
1516 links : DocLinkCreator ;
1617}
1718
18- const FrontendConfigContext = createContext < FrontendConfigContextProps | null > (
19+ export const FrontendConfigContext = createContext < FrontendConfigContextProps | null > (
1920 null ,
2021) ;
2122
23+
2224const fetchPromise = fetch ( '/frontend-config.json' ) . then ( ( res ) => res . json ( ) ) ;
2325
2426interface FrontendConfigProviderProps {
2527 children : ReactNode ;
2628}
2729
28- export function FrontendConfigProvider ( {
29- children,
30- } : FrontendConfigProviderProps ) {
30+ export function FrontendConfigProvider ( { children } : FrontendConfigProviderProps ) {
3131 const config = use ( fetchPromise ) ;
3232 const docLinks = new DocLinkCreator ( config . documentationBaseUrl ) ;
3333 const value : FrontendConfigContextProps = {
Original file line number Diff line number Diff line change @@ -10,3 +10,4 @@ export const extractWorkspaceNameFromNamespace = (namespace: string) => {
1010export const projectnameToNamespace = ( projectname : string ) => {
1111 return `project-${ projectname } ` ;
1212} ;
13+
Original file line number Diff line number Diff line change 1+ import { DocLinkCreator } from '../lib/shared/links.ts' ;
2+ import { Landscape } from '../context/FrontendConfigContext.tsx' ;
3+
4+ export const isInTestingMode : Boolean = ! ! window . Cypress ;
5+ const documentationBaseUrl = 'http://localhost:3000' ;
6+ export const mockedFrontendConfig = {
7+ backendUrl : 'http://localhost:3000' ,
8+ landscape : Landscape . Local ,
9+ documentationBaseUrl : 'http://localhost:3000' ,
10+ links : new DocLinkCreator ( documentationBaseUrl ) ,
11+ } ;
You can’t perform that action at this time.
0 commit comments