diff --git a/frontend/app-development/router/routes.test.tsx b/frontend/app-development/router/routes.test.tsx new file mode 100644 index 00000000000..55e28f2ef9c --- /dev/null +++ b/frontend/app-development/router/routes.test.tsx @@ -0,0 +1,61 @@ +import { render, screen } from '@testing-library/react'; +import { routerRoutes } from './routes'; +import { RoutePaths } from '../enums/RoutePaths'; +import React from 'react'; +import { createQueryClientMock } from 'app-shared/mocks/queryClientMock'; +import { QueryKey } from 'app-shared/types/QueryKey'; +import { AppVersion } from 'app-shared/types/AppVersion'; +import { ServicesContextProvider } from 'app-shared/contexts/ServicesContext'; +import { queriesMock } from 'app-shared/mocks/queriesMock'; + +// Mocks: +jest.mock('../../packages/ux-editor-v3/src/SubApp', () => ({ + SubApp: () =>
, +})); +jest.mock('../../packages/ux-editor/src/SubApp', () => ({ + SubApp: () => , +})); + +// Test data +const org = 'org'; +const app = 'app'; + +describe('routes', () => { + describe(RoutePaths.UIEditor, () => { + type FrontendVersion = null | '3.0.0' | '4.0.0'; + type PackageVersion = 'version 3' | 'latest version'; + type TestCase = [PackageVersion, FrontendVersion]; + + const testCases: TestCase[] = [ + ['version 3', null], + ['version 3', '3.0.0'], + ['latest version', '4.0.0'], + ]; + + it.each(testCases)( + 'Renders the %s schema editor page when the app frontend version is %s', + (expectedPackage, frontendVersion) => { + renderUiEditor(frontendVersion); + expect(screen.getByTestId(expectedPackage)).toBeInTheDocument(); + }, + ); + + const renderUiEditor = (frontendVersion: string | null) => + renderSubapp(RoutePaths.UIEditor, frontendVersion); + }); +}); + +const renderSubapp = (path: RoutePathsm, frontendVersion: string = null) => { + const Subapp = routerRoutes.find((route) => route.path === path)!.subapp; + const appVersion: AppVersion = { + frontendVersion, + backendVersion: '7.0.0', + }; + const queryClient = createQueryClientMock(); + queryClient.setQueryData([QueryKey.AppVersion, org, app], appVersion); + return render( +{message}
+{t('ux_editor.component_deletion_text')}
+
+ {t('right_menu.dynamics_description')}
+
+
+ {t('right_menu.dynamics_link')}
+
+
{t('ux_editor.text_resource_bindings.delete_confirm_question')}
+{t('ux_editor.text_resource_bindings.delete_info')}
++ {this.props.t( + 'ux_editor.modal_configure_conditional_rendering_configure_output_field_helper', + )} +
+ {Object.keys(this.state.conditionalRendering.selectedFields).map((key: any) => { + return ( +
+
{t('right_menu.expressions_function_on_property')}
+ } + onClick={() => onRemoveSubExpression(subExpression)} + variant='tertiary' + size='small' + /> ++ {expressionFunctionTexts(t)[subExpression.function]} +
+
+
+
+