From 7187d423972d524b991328921caa9e9aed846c48 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Goral?= Date: Mon, 31 Mar 2025 16:17:17 +0200 Subject: [PATCH 01/15] fixes --- cypress/support/component.tsx | 10 ++++------ src/context/FrontendConfigContext.tsx | 8 +++++--- src/utils/index.ts | 2 ++ 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/cypress/support/component.tsx b/cypress/support/component.tsx index 3c4f63b8..bc971d3f 100644 --- a/cypress/support/component.tsx +++ b/cypress/support/component.tsx @@ -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. @@ -38,10 +39,7 @@ declare global { Cypress.Commands.add('mount', (component, options) => { - return mount({component} , options); + return mount( + {component} , options); }); diff --git a/src/context/FrontendConfigContext.tsx b/src/context/FrontendConfigContext.tsx index bdf1346b..b4384c35 100644 --- a/src/context/FrontendConfigContext.tsx +++ b/src/context/FrontendConfigContext.tsx @@ -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', @@ -19,15 +20,16 @@ const FrontendConfigContext = createContext( 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 = { diff --git a/src/utils/index.ts b/src/utils/index.ts index 434cba47..85b21176 100644 --- a/src/utils/index.ts +++ b/src/utils/index.ts @@ -10,3 +10,5 @@ export const extractWorkspaceNameFromNamespace = (namespace: string) => { export const projectnameToNamespace = (projectname: string) => { return `project-${projectname}`; }; + +export const isInTestingMode:Boolean = !!window.Cypress; \ No newline at end of file From 56b8462649e930ad54810a09bbffdb1278340f79 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Goral?= Date: Mon, 31 Mar 2025 16:19:29 +0200 Subject: [PATCH 02/15] Update build.yaml --- .github/workflows/build.yaml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index d88fd9d2..87803ba2 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -22,3 +22,6 @@ jobs: - name: Build run: npm run build + + - name: Test + run: npm run test From d9db619ef68dbb70ce42da3fd24004fc867c12e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Goral?= Date: Mon, 31 Mar 2025 16:42:25 +0200 Subject: [PATCH 03/15] test --- cypress/support/component.tsx | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/cypress/support/component.tsx b/cypress/support/component.tsx index bc971d3f..cca5201a 100644 --- a/cypress/support/component.tsx +++ b/cypress/support/component.tsx @@ -39,7 +39,6 @@ declare global { Cypress.Commands.add('mount', (component, options) => { - return mount( - {component} , options); + return mount({component} , options); }); From e62b76e44a72915b4192454e54d61f144b3022b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Goral?= Date: Tue, 1 Apr 2025 11:23:55 +0200 Subject: [PATCH 04/15] Update build.yaml --- .github/workflows/build.yaml | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 87803ba2..c7b7e5be 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -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 @@ -16,6 +16,7 @@ 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 @@ -23,5 +24,17 @@ jobs: - name: Build run: npm run build - - name: Test + - name: Run Cypress Tests run: npm run test + continue-on-error: true + + - 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 + From bb1308588801c26698498b508bd23f9f59870910 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Goral?= Date: Tue, 1 Apr 2025 11:37:34 +0200 Subject: [PATCH 05/15] Update build.yaml --- .github/workflows/build.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index c7b7e5be..ca8aaae0 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -26,7 +26,6 @@ jobs: - name: Run Cypress Tests run: npm run test - continue-on-error: true - name: Upload Cypress Screenshots if: always() # Run this step even if tests fail From 567b488775d5e911dac77f7d8a003055d3b0bfab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Goral?= Date: Tue, 1 Apr 2025 11:44:04 +0200 Subject: [PATCH 06/15] Update build-and-test.yaml --- .github/workflows/{build.yaml => build-and-test.yaml} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename .github/workflows/{build.yaml => build-and-test.yaml} (100%) diff --git a/.github/workflows/build.yaml b/.github/workflows/build-and-test.yaml similarity index 100% rename from .github/workflows/build.yaml rename to .github/workflows/build-and-test.yaml From 221cb343f07531e7f989a4cef2d6992d7430af85 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Goral?= Date: Tue, 1 Apr 2025 11:56:55 +0200 Subject: [PATCH 07/15] Revert "Update build-and-test.yaml" This reverts commit 567b488775d5e911dac77f7d8a003055d3b0bfab. --- .github/workflows/{build-and-test.yaml => build.yaml} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename .github/workflows/{build-and-test.yaml => build.yaml} (100%) diff --git a/.github/workflows/build-and-test.yaml b/.github/workflows/build.yaml similarity index 100% rename from .github/workflows/build-and-test.yaml rename to .github/workflows/build.yaml From d9316c822a58ca00c7ed177faf2e44fadb90b88e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Goral?= Date: Tue, 1 Apr 2025 11:59:42 +0200 Subject: [PATCH 08/15] Update build.yaml --- .github/workflows/build.yaml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index ca8aaae0..53bb745f 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -25,7 +25,9 @@ jobs: run: npm run build - name: Run Cypress Tests - run: npm run test + uses: cypress-io/github-action@v6 + with: + start: npm run test - name: Upload Cypress Screenshots if: always() # Run this step even if tests fail From 26aef465aa4de9e0de1df261c8244cbb33d9c155 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Goral?= Date: Tue, 1 Apr 2025 12:27:05 +0200 Subject: [PATCH 09/15] Update component.tsx --- cypress/support/component.tsx | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/cypress/support/component.tsx b/cypress/support/component.tsx index cca5201a..b9f8b685 100644 --- a/cypress/support/component.tsx +++ b/cypress/support/component.tsx @@ -20,8 +20,7 @@ import { ThemeProvider } from '@ui5/webcomponents-react'; import { mount } from 'cypress/react'; // Import commands.js using ES2015 syntax: import './commands'; -import { FrontendConfigProvider } from "../../src/context/FrontendConfigContext"; -import { AuthProviderOnboarding } from '../../src/context/AuthProviderOnboarding'; + // Augment the Cypress namespace to include type definitions for // your custom command. From 2694289ac930b2256a9cacfe4c1294b4ec83c3e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Goral?= Date: Tue, 1 Apr 2025 12:35:33 +0200 Subject: [PATCH 10/15] Update component.tsx --- cypress/support/component.tsx | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/cypress/support/component.tsx b/cypress/support/component.tsx index b9f8b685..092bdf85 100644 --- a/cypress/support/component.tsx +++ b/cypress/support/component.tsx @@ -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 } from '../../src/context/FrontendConfigContext'; +import { AuthProviderOnboarding } from '../../src/context/AuthProviderOnboarding'; // Augment the Cypress namespace to include type definitions for // your custom command. @@ -36,8 +37,13 @@ declare global { } - Cypress.Commands.add('mount', (component, options) => { - return mount({component} , options); + return mount( + + + {component} + + + , options); }); From 3814d3841a0a5357648ebca21d941cb3c8f74d02 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Goral?= Date: Tue, 1 Apr 2025 12:39:53 +0200 Subject: [PATCH 11/15] Update build.yaml --- .github/workflows/build.yaml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 53bb745f..ca8aaae0 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -25,9 +25,7 @@ jobs: run: npm run build - name: Run Cypress Tests - uses: cypress-io/github-action@v6 - with: - start: npm run test + run: npm run test - name: Upload Cypress Screenshots if: always() # Run this step even if tests fail From 15e4c51287092862b8e2ab0aab7c2a48539e1cc5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Goral?= Date: Tue, 1 Apr 2025 13:23:36 +0200 Subject: [PATCH 12/15] Update component.tsx --- cypress/support/component.tsx | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/cypress/support/component.tsx b/cypress/support/component.tsx index 092bdf85..d440e78f 100644 --- a/cypress/support/component.tsx +++ b/cypress/support/component.tsx @@ -40,9 +40,8 @@ declare global { Cypress.Commands.add('mount', (component, options) => { return mount( - + {component} - , options); }); From 78a2b40c9fdf8ad02127f2af84c1162b34f81589 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Goral?= Date: Tue, 1 Apr 2025 13:55:55 +0200 Subject: [PATCH 13/15] Update component.tsx --- cypress/support/component.tsx | 2 -- 1 file changed, 2 deletions(-) diff --git a/cypress/support/component.tsx b/cypress/support/component.tsx index d440e78f..03656099 100644 --- a/cypress/support/component.tsx +++ b/cypress/support/component.tsx @@ -21,7 +21,6 @@ import { mount } from 'cypress/react'; // Import commands.js using ES2015 syntax: import './commands'; import { FrontendConfigProvider } from '../../src/context/FrontendConfigContext'; -import { AuthProviderOnboarding } from '../../src/context/AuthProviderOnboarding'; // Augment the Cypress namespace to include type definitions for // your custom command. @@ -40,7 +39,6 @@ declare global { Cypress.Commands.add('mount', (component, options) => { return mount( - {component} , options); From 7b73d358ae04e11beb15873b7e52722b92e6cd84 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Goral?= Date: Wed, 2 Apr 2025 14:11:05 +0200 Subject: [PATCH 14/15] refactor --- cypress/support/component.tsx | 9 +++++---- src/context/FrontendConfigContext.tsx | 6 +++--- src/utils/index.ts | 1 - src/utils/testing.ts | 11 +++++++++++ 4 files changed, 19 insertions(+), 8 deletions(-) create mode 100644 src/utils/testing.ts diff --git a/cypress/support/component.tsx b/cypress/support/component.tsx index 03656099..78400390 100644 --- a/cypress/support/component.tsx +++ b/cypress/support/component.tsx @@ -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 } from '../../src/context/FrontendConfigContext'; +import { FrontendConfigContext } from '../../src/context/FrontendConfigContext'; +import { mockedFrontendConfig } from '../../src/utils/testing'; // Augment the Cypress namespace to include type definitions for // your custom command. @@ -38,9 +39,9 @@ declare global { Cypress.Commands.add('mount', (component, options) => { return mount( - - {component} - + + {component} + , options); }); diff --git a/src/context/FrontendConfigContext.tsx b/src/context/FrontendConfigContext.tsx index b4384c35..12f47b51 100644 --- a/src/context/FrontendConfigContext.tsx +++ b/src/context/FrontendConfigContext.tsx @@ -1,12 +1,12 @@ import { ReactNode, createContext, use } from 'react'; import { DocLinkCreator } from '../lib/shared/links'; -import { isInTestingMode } from '../utils'; export enum Landscape { Live = 'LIVE', Canary = 'CANARY', Staging = 'STAGING', Development = 'DEV', + Local = 'LOCAL', } interface FrontendConfigContextProps { @@ -16,12 +16,12 @@ interface FrontendConfigContextProps { links: DocLinkCreator; } -const FrontendConfigContext = createContext( +export const FrontendConfigContext = createContext( null, ); -const fetchPromise = fetch(isInTestingMode ? '/__cypress/src/frontend-config.json': '/frontend-config.json').then((res) => res.json()); +const fetchPromise = fetch('/frontend-config.json').then((res) => res.json()); interface FrontendConfigProviderProps { children: ReactNode; diff --git a/src/utils/index.ts b/src/utils/index.ts index 85b21176..8dc63d58 100644 --- a/src/utils/index.ts +++ b/src/utils/index.ts @@ -11,4 +11,3 @@ export const projectnameToNamespace = (projectname: string) => { return `project-${projectname}`; }; -export const isInTestingMode:Boolean = !!window.Cypress; \ No newline at end of file diff --git a/src/utils/testing.ts b/src/utils/testing.ts new file mode 100644 index 00000000..b191d422 --- /dev/null +++ b/src/utils/testing.ts @@ -0,0 +1,11 @@ +import { DocLinkCreator } from '../lib/shared/links.ts'; +import { Landscape } from '../context/FrontendConfigContext.tsx'; + +export const isInTestingMode: Boolean = !!window.Cypress; +const documentationBaseUrl = 'http://localhost:3000'; +export const mockedFrontendConfig = { + backendUrl: 'http://localhost:3000', + landscape: Landscape.Local, + documentationBaseUrl: 'http://localhost:3000', + links: new DocLinkCreator(documentationBaseUrl), +}; \ No newline at end of file From e5147ea3f4227bac3c4e8888f04f239fda4746f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Goral?= Date: Wed, 2 Apr 2025 16:29:20 +0200 Subject: [PATCH 15/15] Update FrontendConfigContext.tsx --- src/context/FrontendConfigContext.tsx | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/context/FrontendConfigContext.tsx b/src/context/FrontendConfigContext.tsx index 12f47b51..d1d0ebab 100644 --- a/src/context/FrontendConfigContext.tsx +++ b/src/context/FrontendConfigContext.tsx @@ -27,9 +27,7 @@ interface FrontendConfigProviderProps { children: ReactNode; } -export function FrontendConfigProvider({ - children, - }: FrontendConfigProviderProps) { +export function FrontendConfigProvider({ children }: FrontendConfigProviderProps) { const config = use(fetchPromise); const docLinks = new DocLinkCreator(config.documentationBaseUrl); const value: FrontendConfigContextProps = {