Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion jest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export default {
// dependencyExtractor: undefined,

// Make calling deprecated APIs throw helpful error messages
// errorOnDeprecated: false,
errorOnDeprecated: true,

// The default configuration for fake timers
// fakeTimers: {
Expand Down
213 changes: 71 additions & 142 deletions package-lock.json

Large diffs are not rendered by default.

21 changes: 8 additions & 13 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@statisticsfinland/pxvisualizer",
"version": "1.4.8",
"version": "1.4.11",
"description": "Component library for visualizing PxGraf data",
"main": "./dist/pxv.cjs",
"jestSonar": {
Expand Down Expand Up @@ -33,9 +33,9 @@
"test:watch": "jest --watchAll=true",
"build": "microbundle --globals highcharts/modules/accessibility.js=highchartsAccessibility,highcharts/modules/exporting.js=highchartsExporting,highcharts/modules/export-data.js=highchartsExportData,highcharts/modules/offline-exporting.js=highchartsOfflineExporting,decimal.js=Decimal,highcharts/modules/pattern-fill.js=patternFill",
"dev": "microbundle watch",
"storybook": "set NODE_OPTIONS=--openssl-legacy-provider && storybook dev -p 6006",
"storybook": "storybook dev -p 6006",
"storybook_legacy": "storybook dev -p 6006",
"build-storybook": "set NODE_OPTIONS=--openssl-legacy-provider && storybook build",
"build-storybook": "storybook build",
"prepublishOnly": "npm run build",
"version-helper": "node .github/scripts/version-helper.js"
},
Expand All @@ -55,22 +55,16 @@
"@storybook/react-webpack5": "^10.3.5",
"@testing-library/dom": "^10.4.0",
"@testing-library/react": "^16.3.0",
"@types/file-saver": "^2.0.7",
"@types/jest": "^30.0.0",
"@types/papaparse": "^5.3.15",
"@types/react": "^19.1.0",
"@types/styled-components": "^5.1.34",
"@types/uuid": "^10.0.0",
"babel-loader": "^10.0.0",
"clean-publish": "^6.0.5",
"decimal.js": "^10.5.0",
"jest": "^30.2.0",
"jest-environment-jsdom": "^30.2.0",
"jest-junit": "^17.0.0",
"jest-sonar-reporter": "^2.0.0",
"jest-styled-components": "^7.2.0",
"microbundle": "^0.15.1",
"papaparse": "^5.5.2",
"react": "^19.1.0",
"react-dom": "^19.1.0",
"semver": "^7.7.0",
Expand All @@ -79,8 +73,7 @@
"ts-jest": "^29.4.9",
"ts-node": "^10.9.2",
"typescript": "^5.8.3",
"uuid": "^14.0.0",
"yaml": "^1.10.3"
"uuid": "^14.0.0"
},
"dependencies": {
"decimal.js": "^10.5.0",
Expand All @@ -98,11 +91,13 @@
"visualization"
],
"overrides": {
"brace-expansion": "^2.0.3",
"brace-expansion": "^2.1.3",
"fast-uri": "3.1.5",
"postcss": "^8.5.10",
"serialize-javascript": "^7.0.4",
"rollup-plugin-typescript2": {
"picomatch": "2.3.1"
".": "0.37.0",
"picomatch": "2.3.2"
}
}
}
76 changes: 14 additions & 62 deletions src/core/chartOptions/Utility/formatters.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { describe, expect, it } from '@jest/globals';
import { DataLabelsOptions, Point, Tooltip } from "highcharts";
import { formatLocale, getDataFormattedForChartType, getDataLabelFormatterFunction, getLineChartToolTipFormatterFunction, getToolTipFormatterFunction, parseScreenReaderFriendlyTimePeriods, shortenStringValue, getFormattedLastUpdatedText } from "./formatters";
import { combinationValuesLinechartViewFixture, multiselectableLineChartViewFixture, simpleQuarterLinechartViewFixture } from "./fixtures/linechartViews";
Expand Down Expand Up @@ -56,68 +57,19 @@ describe('shortenStringValue tests', () => {
});

describe('parseScreenReaderFriendlyTimePeriods', () => {
it('Should return parsed month string', () => {
const testValue = '2000M1';
const result = parseScreenReaderFriendlyTimePeriods(testValue, 'fi');
const expected = '2000 tammikuu';
expect(result).toEqual(expected);
});

it('Should return parsed month string localized', () => {
const testValue = '2000M1';
const result = parseScreenReaderFriendlyTimePeriods(testValue, 'en');
const expected = '2000 January';
expect(result).toEqual(expected);
});

it('Should return parsed quarter string', () => {
const testValue = '2000Q1';
const result = parseScreenReaderFriendlyTimePeriods(testValue, 'fi');
const expected = '2000 1. vuosineljännes';
expect(result).toEqual(expected);
});

it('Should return parsed quarter string localized en first', () => {
const testValue = '2000Q1';
const result = parseScreenReaderFriendlyTimePeriods(testValue, 'en');
const expected = '2000 1st. quarter';
expect(result).toEqual(expected);
});
it('Should return parsed quarter string localized en second', () => {
const testValue = '2000Q2';
const result = parseScreenReaderFriendlyTimePeriods(testValue, 'en');
const expected = '2000 2nd. quarter';
expect(result).toEqual(expected);
});
it('Should return parsed quarter string localized en third', () => {
const testValue = '2000Q3';
const result = parseScreenReaderFriendlyTimePeriods(testValue, 'en');
const expected = '2000 3rd. quarter';
expect(result).toEqual(expected);
});
it('Should return parsed quarter string localized en fourth', () => {
const testValue = '2000Q4';
const result = parseScreenReaderFriendlyTimePeriods(testValue, 'en');
const expected = '2000 4th. quarter';
expect(result).toEqual(expected);
});
it('Should not parse if value doesnt match', () => {
const testValue = 'foobar';
const result = parseScreenReaderFriendlyTimePeriods(testValue, 'fi');
const expected = 'foobar';
expect(result).toEqual(expected);
});
it('Should return parsed preliminary quarter string', () => {
const testValue = '2000Q2*';
const result = parseScreenReaderFriendlyTimePeriods(testValue, 'en');
const expected = '2000 2nd. quarter';
expect(result).toEqual(expected);
});
it('Should return parsed preliminary month string', () => {
const testValue = '2000M2*';
const result = parseScreenReaderFriendlyTimePeriods(testValue, 'en');
const expected = '2000 February';
expect(result).toEqual(expected);
it.each([
{ testValue: '2000M1', locale: 'fi', expected: '2000 tammikuu' },
{ testValue: '2000M1', locale: 'en', expected: '2000 January' },
{ testValue: '2000Q1', locale: 'fi', expected: '2000 1. vuosineljännes' },
{ testValue: '2000Q1', locale: 'en', expected: '2000 1st. quarter' },
{ testValue: '2000Q2', locale: 'en', expected: '2000 2nd. quarter' },
{ testValue: '2000Q3', locale: 'en', expected: '2000 3rd. quarter' },
{ testValue: '2000Q4', locale: 'en', expected: '2000 4th. quarter' },
{ testValue: 'foobar', locale: 'fi', expected: 'foobar' },
{ testValue: '2000Q2*', locale: 'en', expected: '2000 2nd. quarter' },
{ testValue: '2000M2*', locale: 'en', expected: '2000 February' }
])('parses $testValue for $locale', ({ testValue, locale, expected }) => {
expect(parseScreenReaderFriendlyTimePeriods(testValue, locale)).toBe(expected);
});
});

Expand Down
1 change: 1 addition & 0 deletions src/core/chartOptions/Utility/ordinalIntervals.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { describe, expect, it } from '@jest/globals';
import { ETimeVariableInterval, EVisualizationType } from "../../types";
import { ESeriesType, View } from "../../types/view";
import { getOrdinalOptions } from "./ordinalIntervals";
Expand Down
1 change: 1 addition & 0 deletions src/core/chartOptions/Utility/patternFill.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { describe, expect, it } from '@jest/globals';
import { buildPatternObject } from "./patternFill";
import { defaultColors } from "../../highcharts/defaultColors";
import { defaultFillPatterns } from "../../highcharts/fillPatterns";
Expand Down
1 change: 1 addition & 0 deletions src/core/chartOptions/Utility/seriesDataBuilder.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { describe, expect, it } from '@jest/globals';
import { buildLineChartSeries, buildBarChartSeries, buildColumnChartSeries } from "./seriesDataBuilder";
import { simpleGroupHorizontalBarchartViewFixture } from "./fixtures/grouphorizontalbarchartViews";
import { simpleQuarterLinechartViewFixture } from "./fixtures/linechartViews";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { describe, expect, it } from '@jest/globals';
import Decimal from "decimal.js";
import { buildLinearAxisTickPositioner, getDivisibilityScore, getInterval, linearAxisIntervalStepFunction } from "./tickPositionerUtilities";

Expand Down
1 change: 1 addition & 0 deletions src/core/chartOptions/Utility/tickPositioners.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { describe, expect, it } from '@jest/globals';
import { Axis } from "highcharts";
import { getLinearAxisTickPositionerFunction, getLinearSumAxisTickPositionerFunction, getOrdinalAxisTickPositionerFunction, getQuarterlySeriesTickPositionerFunction } from "./tickPositioners";

Expand Down
9 changes: 5 additions & 4 deletions src/core/chartOptions/Utility/timeIntervals.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { ETimeVariableInterval } from "../../types";
import { describe, expect, it } from '@jest/globals';
import { ETimeVariableInterval } from "../../types";
import { EVisualizationType } from "../../types/queryVisualizationResponse";
import { ESeriesType, View } from "../../types/view";
import { getTimeSeriesOptions, getXAxisOptions } from "./timeIntervals";
Expand All @@ -12,7 +13,7 @@ describe('getTimeSeriesOptions tests', () => {
});
it('Should return undefined', () => {
const result = getTimeSeriesOptions(ETimeVariableInterval.Week, TIME);
expect(result).toEqual(undefined);
expect(result).toBeUndefined();
});
it('Should return correct options when interval is month', () => {
const result = getTimeSeriesOptions(ETimeVariableInterval.Month, TIME);
Expand All @@ -23,11 +24,11 @@ describe('getTimeSeriesOptions tests', () => {
});
it('Should return undefined', () => {
const result = getTimeSeriesOptions(ETimeVariableInterval.Quarter, TIME);
expect(result).toEqual(undefined);
expect(result).toBeUndefined();
});
it('Should return undefined', () => {
const result = getTimeSeriesOptions(ETimeVariableInterval.HalfYear, TIME);
expect(result).toEqual(undefined);
expect(result).toBeUndefined();
});
it('Should return correct options when interval is year', () => {
const result = getTimeSeriesOptions(ETimeVariableInterval.Year, TIME);
Expand Down
7 changes: 6 additions & 1 deletion src/core/chartOptions/chartOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,12 @@ export const commonChartOptions = (view: View, locale: string, options?: IChartO
tooltip: {
formatter: getToolTipFormatterFunction(view, locale)
},
yAxis: [commonYAxisOptions]
yAxis: [commonYAxisOptions],
lang: {
accessibility: {
chartContainerLabel: view.header[locale] // Reads the title of the chart but omits the 'Highcharts interactive chart' part which is read by default and is redundant in our case
}
}
};
}

Expand Down
1 change: 1 addition & 0 deletions src/core/conversion/pxGrafDataConverter.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { describe, expect, it } from '@jest/globals';
import { convertPxGraphDataToChartOptions } from "./pxGrafDataConverter";
import { GROUP_HORIZONTAL_BAR_CHART_WITH_SELECTABLES } from "./fixtures/groupHorizontalBarChart";
import { GROUP_VERTICAL_BAR_CHART_WITH_SELECTABLES_PIVOTED } from "./fixtures/groupVerticalBarChart";
Expand Down
1 change: 1 addition & 0 deletions src/core/conversion/seriesBuilderUtilities.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { describe, expect, it } from '@jest/globals';
import { EVariableType } from "../types";
import { IVariableMeta } from "../types/queryVisualizationResponse";
import { TVariableSelections } from "../types/variableSelections";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { describe, expect, it } from '@jest/globals';
import { Translations, ArrayTranslations, GetAllLanguages, TTranslationPackage, AddTranslations } from '../translations'

const mockTranslationPackage: TTranslationPackage = {
Expand Down
1 change: 1 addition & 0 deletions src/core/conversion/utilityFunctions.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { describe, expect, it } from '@jest/globals';
import { cartesianProduct, compareScalarArrays } from './utilityFunctions';

describe('cartesian function', () => {
Expand Down
23 changes: 12 additions & 11 deletions src/core/conversion/viewUtils.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { describe, expect, it } from '@jest/globals';
import { ETimeVariableInterval, EVariableType, EVisualizationType, IContentComponent, IQueryVisualizationResponse, IVariableMeta, IVariableValueMeta, TMultiLanguageString } from '../types/queryVisualizationResponse';
import { TVariableSelections } from '../types/variableSelections';
import { ESeriesType, IDataSeries, View } from '../types/view';
Expand Down Expand Up @@ -219,20 +220,20 @@ describe('series metadata', () => {
// Value 1 in selection
const selectedValueCodes1: TVariableSelections = { [contentVariable.code]: [contentVariableValue1.code] };
const { series: rows1 } = buildSeries(pxGrafResponse, selectedValueCodes1);
expect(rows1.length).toEqual(1);
expect(rows1).toHaveLength(1);

const { series: series1 } = rows1[0];
expect(series1.length).toEqual(1);
expect(series1).toHaveLength(1);

expect(series1[0].precision).toBe(contentVariableValue1.contentComponent?.numberOfDecimals);

// Value 2 in selection
const selectedValueCodes2: TVariableSelections = { [contentVariable.code]: [contentVariableValue2.code] };
const { series: rows2 } = buildSeries(pxGrafResponse, selectedValueCodes2);
expect(rows2.length).toEqual(1);
expect(rows2).toHaveLength(1);

const { series: series2 } = rows2[0];
expect(series2.length).toEqual(1);
expect(series2).toHaveLength(1);

expect(series2[0].precision).toBe(contentVariableValue2.contentComponent?.numberOfDecimals);
});
Expand All @@ -259,10 +260,10 @@ describe('series metadata', () => {
const selectedValueCodes1: TVariableSelections = {};

const { series: rows } = buildSeries(pxGrafResponse, selectedValueCodes1);
expect(rows.length).toEqual(1);
expect(rows).toHaveLength(1);

const { series } = rows[0];
expect(series.length).toEqual(pxGrafResponse.data.length);
expect(series).toHaveLength(pxGrafResponse.data.length);

expect(series[0].precision).toEqual(contentVariable.values[0].contentComponent?.numberOfDecimals);
});
Expand Down Expand Up @@ -290,10 +291,10 @@ describe('series metadata', () => {
const selectedValueCodes1: TVariableSelections = {};

const { series: rows } = buildSeries(pxGrafResponse, selectedValueCodes1);
expect(rows.length).toEqual(1);
expect(rows).toHaveLength(1);

const { series } = rows[0];
expect(series.length).toEqual(pxGrafResponse.data.length);
expect(series).toHaveLength(pxGrafResponse.data.length);

expect(series[0].precision).toEqual(contentVariable.values[0].contentComponent?.numberOfDecimals);

Expand Down Expand Up @@ -324,16 +325,16 @@ describe('series metadata', () => {
const selectedValueCodes1: TVariableSelections = {};

const { series: rows } = buildSeries(pxGrafResponse, selectedValueCodes1);
expect(rows.length).toEqual(2);
expect(rows).toHaveLength(2);

// Row 1
const { series: series0 } = rows[0];
expect(series0.length).toEqual(1);
expect(series0).toHaveLength(1);
expect(series0[0].precision).toEqual(contentVariable.values[0].contentComponent?.numberOfDecimals);

// Row 2
const { series: series1 } = rows[1];
expect(series1.length).toEqual(1);
expect(series1).toHaveLength(1);
expect(series1[0].precision).toEqual(contentVariable.values[1].contentComponent?.numberOfDecimals);
});

Expand Down
1 change: 1 addition & 0 deletions src/core/highcharts/drawChart.test.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { beforeEach, describe, expect, it, jest } from '@jest/globals';
import * as Highcharts from "highcharts";
import { drawChart } from "./drawChart";
import { GROUP_VERTICAL_BAR_CHART_CHART_FIXTURE } from "../../react/components/chart/testFixtures/pxGrafResponses";
Expand Down
Loading
Loading