Some checks failed
App Prod-Parity E2E Dispatch / dispatch (push) Failing after 10s
CD Storybook UI / build (push) Failing after 3m25s
CD Storybook UI / dispatch (push) Has been skipped
CD deploy main / website-changed-files (push) Successful in 18m8s
CI Agent Skills / changed-files-check (push) Successful in 18m9s
CI Create App E2E minimal / changed-files-check (push) Successful in 24s
CI Create App / changed-files-check (push) Successful in 26s
CI Docs / changed-files-check (push) Successful in 26s
CI Emails / changed-files-check (push) Successful in 28s
CI Example App Hello World / changed-files-check (push) Successful in 23s
CI Front / changed-files-check (push) Has been skipped
CI Example App Postcard / changed-files-check (push) Successful in 27s
CI UI / changed-files-check (push) Has been skipped
CI Utils Test / changed-files-check (push) Successful in 45s
CI Twenty Apps / discover (push) Successful in 1m3s
CD deploy main / deploy-main (push) Failing after 3s
CI Agent Skills / agent-skills-validate (push) Has been skipped
CI Create App / create-app-test (lint) (push) Has been skipped
CI Emails / emails-test (push) Has been skipped
CI Front / front-task (lingui:compile) (push) Has been skipped
CI Front / front-task (lint) (push) Has been skipped
CI Example App Postcard / example-app-postcard (push) Has been skipped
CI UI / ui-task (lint) (push) Has been skipped
CI UI / ui-task (pack-size) (push) Has been skipped
CI UI / ui-task (size) (push) Has been skipped
CI UI / ui-task (test) (push) Has been skipped
CI UI / ui-task (typecheck) (push) Has been skipped
CI Utils Test / utils-test (push) Has been skipped
CI Twenty Apps / ${{ matrix.app.name }} (push) Has been skipped
CI Emails / ci-emails-status-check (push) Successful in 2s
CI Example App Hello World / ci-example-app-hello-world-status-check (push) Successful in 2s
CI Example App Postcard / ci-example-app-postcard-status-check (push) Successful in 3s
CI UI / ui-sb-test (push) Has been skipped
CI Utils Test / ci-utils-test-status-check (push) Successful in 2s
CI Twenty Apps / ci-twenty-apps-status-check (push) Successful in 2s
CI UI / ci-ui-status-check (push) Successful in 2s
CI Desktop / desktop (push) Failing after 1m8s
Push docs to Crowdin / Push documentation to Crowdin (push) Failing after 55s
Push translations to Crowdin / Extract and upload translations (push) Failing after 5s
Push website translations to Crowdin / Extract and upload website translations (push) Failing after 5s
CI Create App / create-app-test (test) (push) Has been skipped
CI Create App / create-app-test (typecheck) (push) Has been skipped
CI Docs / docs-lint (push) Has been skipped
CI Example App Hello World / example-app-hello-world (push) Has been skipped
CI Front / front-task (lingui:extract) (push) Has been skipped
CI Front / front-task (test) (push) Has been skipped
CI Front / front-task (typecheck) (push) Has been skipped
CI UI / ui-sb-build (push) Failing after 1m32s
CI Twenty Apps / ${{ matrix.app.name }} (${{ matrix.server-source }}) (push) Has been skipped
CI Agent Skills / agent-skills-publish (push) Has been skipped
CI Create App / ci-create-app-status-check (push) Successful in 2s
CI Agent Skills / agent-skills-remote-source (push) Has been skipped
CI Create App E2E minimal / create-app-e2e-minimal (push) Has been cancelled
CI E2E Main / e2e-test (push) Has been cancelled
CI Front / front-sb-build (push) Has been cancelled
CI Front / front-build (push) Has been cancelled
CI Create App E2E minimal / ci-create-app-e2e-minimal-status-check (push) Has been cancelled
CI E2E Main / ci-e2e-main-status-check (push) Has been cancelled
CI E2E Main / notify-main-ci-failure (push) Has been cancelled
CI E2E Main / qa-scout-comment (push) Has been cancelled
CI Front / front-sb-test (push) Has been cancelled
CI Front / front-sb-screenshots (push) Has been cancelled
CI Front / ci-front-status-check (push) Has been cancelled
DPA Sub-Processor Sync / sync-subprocessors (push) Failing after 3s
AI Catalog Sync / sync-catalog (push) Failing after 2s
217 lines
8.6 KiB
TypeScript
217 lines
8.6 KiB
TypeScript
import { AggregateOperations } from 'twenty-shared/types';
|
|
|
|
import { type AggregateChartConfigurationDTO } from 'src/engine/metadata-modules/page-layout-widget/dtos/aggregate-chart-configuration.dto';
|
|
import { type BarChartConfigurationDTO } from 'src/engine/metadata-modules/page-layout-widget/dtos/bar-chart-configuration.dto';
|
|
import { type IframeConfigurationDTO } from 'src/engine/metadata-modules/page-layout-widget/dtos/iframe-configuration.dto';
|
|
import { type LineChartConfigurationDTO } from 'src/engine/metadata-modules/page-layout-widget/dtos/line-chart-configuration.dto';
|
|
import { type PieChartConfigurationDTO } from 'src/engine/metadata-modules/page-layout-widget/dtos/pie-chart-configuration.dto';
|
|
import { type StandaloneRichTextConfigurationDTO } from 'src/engine/metadata-modules/page-layout-widget/dtos/standalone-rich-text-configuration.dto';
|
|
import { AxisNameDisplay } from 'src/engine/metadata-modules/page-layout-widget/enums/axis-name-display.enum';
|
|
import { BarChartLayout } from 'src/engine/metadata-modules/page-layout-widget/enums/bar-chart-layout.enum';
|
|
import { ChartNumberFormat } from 'src/engine/metadata-modules/page-layout-widget/enums/chart-number-format.enum';
|
|
import { GraphOrderBy } from 'src/engine/metadata-modules/page-layout-widget/enums/graph-order-by.enum';
|
|
import { WidgetConfigurationType } from 'src/engine/metadata-modules/page-layout-widget/enums/widget-configuration-type.type';
|
|
|
|
// Hardcoded UUIDs for unit tests only (no DB lookup needed)
|
|
const UNIT_TEST_FIELD_METADATA_ID_1 = '20202020-1111-4111-a111-111111111111';
|
|
const UNIT_TEST_FIELD_METADATA_ID_2 = '20202020-2222-4222-a222-222222222222';
|
|
const UNIT_TEST_FIELD_METADATA_ID_3 = '20202020-3333-4333-a333-333333333333';
|
|
|
|
export const TEST_IFRAME_CONFIG: IframeConfigurationDTO = {
|
|
configurationType: WidgetConfigurationType.IFRAME,
|
|
url: 'https://example.com/dashboard',
|
|
};
|
|
|
|
export const TEST_IFRAME_CONFIG_ALTERNATIVE: IframeConfigurationDTO = {
|
|
configurationType: WidgetConfigurationType.IFRAME,
|
|
url: 'https://app.twenty.com/analytics',
|
|
};
|
|
|
|
export const TEST_STANDALONE_RICH_TEXT_CONFIG: StandaloneRichTextConfigurationDTO =
|
|
{
|
|
configurationType: WidgetConfigurationType.STANDALONE_RICH_TEXT,
|
|
body: {
|
|
blocknote:
|
|
'{"type":"doc","content":[{"type":"paragraph","content":[{"type":"text","text":"Hello world"}]}]}',
|
|
markdown: '# Hello world',
|
|
},
|
|
};
|
|
|
|
export const TEST_STANDALONE_RICH_TEXT_CONFIG_MINIMAL: StandaloneRichTextConfigurationDTO =
|
|
{
|
|
configurationType: WidgetConfigurationType.STANDALONE_RICH_TEXT,
|
|
body: {
|
|
blocknote:
|
|
'{"type":"doc","content":[{"type":"paragraph","content":[{"type":"text","text":"Simple text"}]}]}',
|
|
markdown: null,
|
|
},
|
|
};
|
|
|
|
export const INVALID_STANDALONE_RICH_TEXT_CONFIG_MISSING_BODY = {};
|
|
|
|
export const INVALID_STANDALONE_RICH_TEXT_CONFIG_BODY_WRONG_TYPE = {
|
|
body: 'not an object',
|
|
};
|
|
|
|
export const INVALID_STANDALONE_RICH_TEXT_CONFIG_INVALID_SUBFIELDS = {
|
|
configurationType: WidgetConfigurationType.STANDALONE_RICH_TEXT,
|
|
body: {
|
|
blocknote: 'valid',
|
|
markdown: 'valid',
|
|
invalidField: 'should not be here',
|
|
},
|
|
};
|
|
|
|
export const INVALID_IFRAME_CONFIG_BAD_URL = {
|
|
url: 'not-a-valid-url',
|
|
};
|
|
|
|
export const INVALID_IFRAME_CONFIG_EMPTY_URL = {
|
|
url: '',
|
|
};
|
|
|
|
export const INVALID_NUMBER_CHART_CONFIG_MISSING_FIELDS = {
|
|
configurationType: WidgetConfigurationType.AGGREGATE_CHART,
|
|
};
|
|
|
|
export const INVALID_NUMBER_CHART_CONFIG_BAD_UUID = {
|
|
configurationType: WidgetConfigurationType.AGGREGATE_CHART,
|
|
aggregateFieldMetadataId: 'not-a-uuid',
|
|
aggregateOperation: AggregateOperations.COUNT,
|
|
};
|
|
|
|
export const INVALID_VERTICAL_BAR_CHART_CONFIG_MISSING_GROUP_BY = {
|
|
configurationType: WidgetConfigurationType.BAR_CHART,
|
|
aggregateFieldMetadataId: UNIT_TEST_FIELD_METADATA_ID_1,
|
|
aggregateOperation: AggregateOperations.SUM,
|
|
};
|
|
|
|
export const INVALID_HORIZONTAL_BAR_CHART_CONFIG_MISSING_GROUP_BY = {
|
|
configurationType: WidgetConfigurationType.BAR_CHART,
|
|
aggregateFieldMetadataId: UNIT_TEST_FIELD_METADATA_ID_1,
|
|
aggregateOperation: AggregateOperations.SUM,
|
|
};
|
|
|
|
export const TEST_NUMBER_CHART_CONFIG: AggregateChartConfigurationDTO = {
|
|
configurationType: WidgetConfigurationType.AGGREGATE_CHART,
|
|
aggregateFieldMetadataId: UNIT_TEST_FIELD_METADATA_ID_1,
|
|
aggregateOperation: AggregateOperations.COUNT,
|
|
label: 'Total Records',
|
|
description: 'Count of all records',
|
|
numberFormat: ChartNumberFormat.SHORT,
|
|
displayDataLabel: true,
|
|
};
|
|
|
|
export const TEST_NUMBER_CHART_CONFIG_MINIMAL: AggregateChartConfigurationDTO =
|
|
{
|
|
configurationType: WidgetConfigurationType.AGGREGATE_CHART,
|
|
aggregateFieldMetadataId: UNIT_TEST_FIELD_METADATA_ID_1,
|
|
aggregateOperation: AggregateOperations.SUM,
|
|
displayDataLabel: false,
|
|
};
|
|
|
|
export const TEST_VERTICAL_BAR_CHART_CONFIG: BarChartConfigurationDTO = {
|
|
configurationType: WidgetConfigurationType.BAR_CHART,
|
|
layout: BarChartLayout.VERTICAL,
|
|
aggregateFieldMetadataId: UNIT_TEST_FIELD_METADATA_ID_1,
|
|
aggregateOperation: AggregateOperations.SUM,
|
|
primaryAxisGroupByFieldMetadataId: UNIT_TEST_FIELD_METADATA_ID_2,
|
|
primaryAxisOrderBy: GraphOrderBy.FIELD_ASC,
|
|
displayDataLabel: true,
|
|
axisNameDisplay: AxisNameDisplay.NONE,
|
|
color: 'red',
|
|
description: 'Monthly revenue breakdown',
|
|
omitNullValues: true,
|
|
rangeMin: 0,
|
|
rangeMax: 100000,
|
|
};
|
|
|
|
export const TEST_VERTICAL_BAR_CHART_CONFIG_MINIMAL: BarChartConfigurationDTO =
|
|
{
|
|
configurationType: WidgetConfigurationType.BAR_CHART,
|
|
layout: BarChartLayout.VERTICAL,
|
|
aggregateFieldMetadataId: UNIT_TEST_FIELD_METADATA_ID_1,
|
|
aggregateOperation: AggregateOperations.COUNT,
|
|
primaryAxisGroupByFieldMetadataId: UNIT_TEST_FIELD_METADATA_ID_2,
|
|
primaryAxisOrderBy: GraphOrderBy.VALUE_DESC,
|
|
displayDataLabel: false,
|
|
axisNameDisplay: AxisNameDisplay.NONE,
|
|
};
|
|
|
|
export const TEST_HORIZONTAL_BAR_CHART_CONFIG: BarChartConfigurationDTO = {
|
|
configurationType: WidgetConfigurationType.BAR_CHART,
|
|
layout: BarChartLayout.HORIZONTAL,
|
|
aggregateFieldMetadataId: UNIT_TEST_FIELD_METADATA_ID_1,
|
|
aggregateOperation: AggregateOperations.SUM,
|
|
primaryAxisGroupByFieldMetadataId: UNIT_TEST_FIELD_METADATA_ID_2,
|
|
primaryAxisOrderBy: GraphOrderBy.FIELD_ASC,
|
|
displayDataLabel: true,
|
|
axisNameDisplay: AxisNameDisplay.NONE,
|
|
color: 'blue',
|
|
description: 'Horizontal revenue breakdown',
|
|
omitNullValues: true,
|
|
rangeMin: 0,
|
|
rangeMax: 100000,
|
|
};
|
|
|
|
export const TEST_HORIZONTAL_BAR_CHART_CONFIG_MINIMAL: BarChartConfigurationDTO =
|
|
{
|
|
configurationType: WidgetConfigurationType.BAR_CHART,
|
|
layout: BarChartLayout.HORIZONTAL,
|
|
aggregateFieldMetadataId: UNIT_TEST_FIELD_METADATA_ID_1,
|
|
aggregateOperation: AggregateOperations.COUNT,
|
|
primaryAxisGroupByFieldMetadataId: UNIT_TEST_FIELD_METADATA_ID_2,
|
|
primaryAxisOrderBy: GraphOrderBy.VALUE_DESC,
|
|
displayDataLabel: false,
|
|
axisNameDisplay: AxisNameDisplay.NONE,
|
|
};
|
|
|
|
export const TEST_LINE_CHART_CONFIG: LineChartConfigurationDTO = {
|
|
configurationType: WidgetConfigurationType.LINE_CHART,
|
|
aggregateFieldMetadataId: UNIT_TEST_FIELD_METADATA_ID_1,
|
|
aggregateOperation: AggregateOperations.AVG,
|
|
primaryAxisGroupByFieldMetadataId: UNIT_TEST_FIELD_METADATA_ID_2,
|
|
primaryAxisOrderBy: GraphOrderBy.FIELD_ASC,
|
|
secondaryAxisGroupByFieldMetadataId: UNIT_TEST_FIELD_METADATA_ID_3,
|
|
secondaryAxisOrderBy: GraphOrderBy.FIELD_DESC,
|
|
displayDataLabel: true,
|
|
axisNameDisplay: AxisNameDisplay.NONE,
|
|
color: 'cyan',
|
|
description: 'Trend over time',
|
|
omitNullValues: false,
|
|
rangeMin: -100,
|
|
rangeMax: 100,
|
|
};
|
|
|
|
export const TEST_LINE_CHART_CONFIG_MINIMAL: LineChartConfigurationDTO = {
|
|
configurationType: WidgetConfigurationType.LINE_CHART,
|
|
aggregateFieldMetadataId: UNIT_TEST_FIELD_METADATA_ID_1,
|
|
aggregateOperation: AggregateOperations.MAX,
|
|
primaryAxisGroupByFieldMetadataId: UNIT_TEST_FIELD_METADATA_ID_2,
|
|
primaryAxisOrderBy: GraphOrderBy.VALUE_ASC,
|
|
displayDataLabel: false,
|
|
axisNameDisplay: AxisNameDisplay.NONE,
|
|
};
|
|
|
|
export const TEST_PIE_CHART_CONFIG: PieChartConfigurationDTO = {
|
|
configurationType: WidgetConfigurationType.PIE_CHART,
|
|
groupByFieldMetadataId: UNIT_TEST_FIELD_METADATA_ID_1,
|
|
aggregateFieldMetadataId: UNIT_TEST_FIELD_METADATA_ID_2,
|
|
aggregateOperation: AggregateOperations.SUM,
|
|
orderBy: GraphOrderBy.VALUE_DESC,
|
|
displayDataLabel: true,
|
|
displayLegend: true,
|
|
showCenterMetric: true,
|
|
color: 'yellow',
|
|
description: 'Distribution by category',
|
|
};
|
|
|
|
export const TEST_PIE_CHART_CONFIG_MINIMAL: PieChartConfigurationDTO = {
|
|
configurationType: WidgetConfigurationType.PIE_CHART,
|
|
groupByFieldMetadataId: UNIT_TEST_FIELD_METADATA_ID_1,
|
|
aggregateFieldMetadataId: UNIT_TEST_FIELD_METADATA_ID_2,
|
|
aggregateOperation: AggregateOperations.COUNT,
|
|
orderBy: GraphOrderBy.FIELD_ASC,
|
|
displayDataLabel: false,
|
|
};
|