From cb99d2a3dc52945b06d6fcbd98c4c1131ad51437 Mon Sep 17 00:00:00 2001 From: "eclipse-otterdog[bot]" <158182605+eclipse-otterdog[bot]@users.noreply.github.com> Date: Thu, 21 Nov 2024 07:41:51 +0000 Subject: [PATCH 1/3] Initial commit --- README.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..d092443 --- /dev/null +++ b/README.md @@ -0,0 +1 @@ +# mnestix-browser \ No newline at end of file From bb1c389443fa1bedfe41f091150476b71ef9f2f2 Mon Sep 17 00:00:00 2001 From: Alina Geesen-Stucky Date: Mon, 2 Dec 2024 16:26:49 +0100 Subject: [PATCH 2/3] test(CarbonFootprintVisualizations): write test for CarbonFootprintVisualizations --- .../CarbonFootprintVisualizations.spec.tsx | 72 +++++++++++++++++++ .../CO2Equivalents.tsx | 4 +- .../CO2EquivalentsDistribution.tsx | 2 +- .../CalculationMethod.tsx | 3 +- .../visualization-components/Comparison.tsx | 2 +- .../ProductJourney.spec.tsx | 4 +- .../ProductJourney.tsx | 2 +- .../ProductLifecycle.tsx | 1 + 8 files changed, 83 insertions(+), 7 deletions(-) create mode 100644 src/app/[locale]/viewer/_components/submodel/carbon-footprint/CarbonFootprintVisualizations.spec.tsx diff --git a/src/app/[locale]/viewer/_components/submodel/carbon-footprint/CarbonFootprintVisualizations.spec.tsx b/src/app/[locale]/viewer/_components/submodel/carbon-footprint/CarbonFootprintVisualizations.spec.tsx new file mode 100644 index 0000000..226273e --- /dev/null +++ b/src/app/[locale]/viewer/_components/submodel/carbon-footprint/CarbonFootprintVisualizations.spec.tsx @@ -0,0 +1,72 @@ +import { screen } from '@testing-library/react'; +import { expect } from '@jest/globals'; +import testSubmodel from '../../submodel/carbon-footprint/test-submodel/carbonFootprint-test.json'; +import { Submodel } from '@aas-core-works/aas-core3.0-typescript/types'; +import { CustomRenderReactIntl } from 'test-utils/CustomRenderReactIntl'; +import { + CarbonFootprintVisualizations +} from 'app/[locale]/viewer/_components/submodel/carbon-footprint/CarbonFootprintVisualizations'; + +window.ResizeObserver = + window.ResizeObserver || + jest.fn().mockImplementation(() => ({ + disconnect: jest.fn(), + observe: jest.fn(), + unobserve: jest.fn(), + })); + +jest.mock('recharts', () => { + const OriginalRechartsModule = jest.requireActual('recharts'); + + return { + ...OriginalRechartsModule, + ResponsiveContainer: ({ height, children }: never) => ( +
+ {children} +
+ ), + }; +}); + +describe('CarbonFootprintVisualizations Detail', () => { + it('should render all submodel visualilzations for irdi id', async () => { + CustomRenderReactIntl( + , + ); + assertOnElements(); + }); + + it('should render all submodel visualilzations for URL id', async () => { + CustomRenderReactIntl( + , + ); + assertOnElements(); + }); +}); + +function assertOnElements() { + const totalCo2Equivalents = screen.getByTestId('total-co2-equivalents-text'); + expect(totalCo2Equivalents).toBeDefined(); + expect(totalCo2Equivalents).toBeInTheDocument(); + + const productLifecycle = screen.getByTestId('product-lifecycle-stepper'); + expect(productLifecycle).toBeDefined(); + expect(productLifecycle).toBeInTheDocument(); + + const co2EquivalentsDistribution = screen.getByTestId('co2-equivalents-distribution-box'); + expect(co2EquivalentsDistribution).toBeDefined(); + expect(co2EquivalentsDistribution).toBeInTheDocument(); + + const co2Comparison = screen.getByTestId('co2-comparison-box'); + expect(co2Comparison).toBeDefined(); + expect(co2Comparison).toBeInTheDocument(); + + const productJourney = screen.getByTestId('product-journey-box'); + expect(productJourney).toBeDefined(); + expect(productJourney).toBeInTheDocument(); + + const calculationMethod = screen.getByTestId('co2-calculation-method-text'); + expect(calculationMethod).toBeDefined(); + expect(calculationMethod).toBeInTheDocument(); +} + diff --git a/src/app/[locale]/viewer/_components/submodel/carbon-footprint/visualization-components/CO2Equivalents.tsx b/src/app/[locale]/viewer/_components/submodel/carbon-footprint/visualization-components/CO2Equivalents.tsx index aeffafc..ac2018c 100644 --- a/src/app/[locale]/viewer/_components/submodel/carbon-footprint/visualization-components/CO2Equivalents.tsx +++ b/src/app/[locale]/viewer/_components/submodel/carbon-footprint/visualization-components/CO2Equivalents.tsx @@ -5,7 +5,9 @@ const unit = 'kg'; export function CO2Equivalents(props: { totalCO2Equivalents: number }) { return ( - + {`${cutDecimalPlaces(props.totalCO2Equivalents, 3)} ${unit}`} ); diff --git a/src/app/[locale]/viewer/_components/submodel/carbon-footprint/visualization-components/CO2EquivalentsDistribution.tsx b/src/app/[locale]/viewer/_components/submodel/carbon-footprint/visualization-components/CO2EquivalentsDistribution.tsx index 5df2822..797170c 100644 --- a/src/app/[locale]/viewer/_components/submodel/carbon-footprint/visualization-components/CO2EquivalentsDistribution.tsx +++ b/src/app/[locale]/viewer/_components/submodel/carbon-footprint/visualization-components/CO2EquivalentsDistribution.tsx @@ -33,7 +33,7 @@ export function CO2EquivalentsDistribution(props: { }; return ( - + diff --git a/src/app/[locale]/viewer/_components/submodel/carbon-footprint/visualization-components/CalculationMethod.tsx b/src/app/[locale]/viewer/_components/submodel/carbon-footprint/visualization-components/CalculationMethod.tsx index 2070f20..0f0842f 100644 --- a/src/app/[locale]/viewer/_components/submodel/carbon-footprint/visualization-components/CalculationMethod.tsx +++ b/src/app/[locale]/viewer/_components/submodel/carbon-footprint/visualization-components/CalculationMethod.tsx @@ -7,7 +7,8 @@ export function CalculationMethod(props: { calculationMethod: string }) { const { calculationMethod } = props; return ( - + {calculationMethod}{' '} {calculationMethod === 'GHG Protocol' && ( diff --git a/src/app/[locale]/viewer/_components/submodel/carbon-footprint/visualization-components/Comparison.tsx b/src/app/[locale]/viewer/_components/submodel/carbon-footprint/visualization-components/Comparison.tsx index 7e9f3d2..1abc93c 100644 --- a/src/app/[locale]/viewer/_components/submodel/carbon-footprint/visualization-components/Comparison.tsx +++ b/src/app/[locale]/viewer/_components/submodel/carbon-footprint/visualization-components/Comparison.tsx @@ -18,7 +18,7 @@ export function Comparison(props: { co2Equivalents: number }) { const { value: timePeriod, unit: unitOfTimePeriod } = determineTimePeriod(props.co2Equivalents); return ( - + diff --git a/src/app/[locale]/viewer/_components/submodel/carbon-footprint/visualization-components/ProductJourney.spec.tsx b/src/app/[locale]/viewer/_components/submodel/carbon-footprint/visualization-components/ProductJourney.spec.tsx index a3f73c3..c3b28a0 100644 --- a/src/app/[locale]/viewer/_components/submodel/carbon-footprint/visualization-components/ProductJourney.spec.tsx +++ b/src/app/[locale]/viewer/_components/submodel/carbon-footprint/visualization-components/ProductJourney.spec.tsx @@ -41,7 +41,7 @@ describe('ProductJourney', () => { it('renders the ProductJourney', async () => { CustomRender(); - const map = screen.getByTestId('test-map'); + const map = screen.getByTestId('product-journey-box'); expect(map).toBeDefined(); expect(map).toBeInTheDocument(); @@ -56,7 +56,7 @@ describe('ProductJourney', () => { CustomRender(); - const map = screen.getByTestId('test-map'); + const map = screen.getByTestId('product-journey-box'); expect(map).toBeDefined(); expect(map).toBeInTheDocument(); diff --git a/src/app/[locale]/viewer/_components/submodel/carbon-footprint/visualization-components/ProductJourney.tsx b/src/app/[locale]/viewer/_components/submodel/carbon-footprint/visualization-components/ProductJourney.tsx index 2e18ee3..6e17b7e 100644 --- a/src/app/[locale]/viewer/_components/submodel/carbon-footprint/visualization-components/ProductJourney.tsx +++ b/src/app/[locale]/viewer/_components/submodel/carbon-footprint/visualization-components/ProductJourney.tsx @@ -90,7 +90,7 @@ export function ProductJourney(props: { addressesPerLifeCyclePhase: AddressPerLi <> {props.completedStages.map((step, index) => ( From 9311e4c0a72c02e076d940784b3c3df290eea612 Mon Sep 17 00:00:00 2001 From: Alina Geesen-Stucky Date: Wed, 4 Dec 2024 10:37:17 +0100 Subject: [PATCH 3/3] test(CarbonFootprintVisualizations): fix merge conflict --- .../carbon-footprint/CarbonFootprintVisualizations.spec.tsx | 2 +- .../visualization-components/CO2Equivalents.tsx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/app/[locale]/viewer/_components/submodel/carbon-footprint/CarbonFootprintVisualizations.spec.tsx b/src/app/[locale]/viewer/_components/submodel/carbon-footprint/CarbonFootprintVisualizations.spec.tsx index 226273e..47f7e5d 100644 --- a/src/app/[locale]/viewer/_components/submodel/carbon-footprint/CarbonFootprintVisualizations.spec.tsx +++ b/src/app/[locale]/viewer/_components/submodel/carbon-footprint/CarbonFootprintVisualizations.spec.tsx @@ -45,7 +45,7 @@ describe('CarbonFootprintVisualizations Detail', () => { }); function assertOnElements() { - const totalCo2Equivalents = screen.getByTestId('total-co2-equivalents-text'); + const totalCo2Equivalents = screen.getByTestId('co2-equivalents'); expect(totalCo2Equivalents).toBeDefined(); expect(totalCo2Equivalents).toBeInTheDocument(); diff --git a/src/app/[locale]/viewer/_components/submodel/carbon-footprint/visualization-components/CO2Equivalents.tsx b/src/app/[locale]/viewer/_components/submodel/carbon-footprint/visualization-components/CO2Equivalents.tsx index ac2018c..a21b2e5 100644 --- a/src/app/[locale]/viewer/_components/submodel/carbon-footprint/visualization-components/CO2Equivalents.tsx +++ b/src/app/[locale]/viewer/_components/submodel/carbon-footprint/visualization-components/CO2Equivalents.tsx @@ -7,7 +7,7 @@ export function CO2Equivalents(props: { totalCO2Equivalents: number }) { return ( + data-testid="co2-equivalents"> {`${cutDecimalPlaces(props.totalCO2Equivalents, 3)} ${unit}`} );