Skip to content

Commit

Permalink
add testing for new props
Browse files Browse the repository at this point in the history
  • Loading branch information
jmbuss committed Jul 6, 2022
1 parent 66e8136 commit d59925f
Show file tree
Hide file tree
Showing 8 changed files with 269 additions and 24 deletions.
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import { renderChart } from '../../testing/renderChart';
import { mockGetAggregatedOrRawResponse } from '../../testing/mocks/mockGetAggregatedOrRawResponse';
import { mockGetAssetSummary } from '../../testing/mocks/mockGetAssetSummaries';
import { ScaleConfig, ScaleType } from '@synchro-charts/core';

const SECOND_IN_MS = 1000;

const snapshotOptions = {
clip: { x: 0, y: 0, width: 400, height: 500 },
};

describe.skip('bar chart', () => {
describe('bar chart', () => {
const assetId = 'some-asset-id';
const assetModelId = 'some-asset-model-id';

Expand All @@ -28,11 +29,51 @@ describe.skip('bar chart', () => {
});
});

it('renders', () => {
it.skip('renders', () => {
renderChart({ chartType: 'iot-bar-chart', settings: { resolution: '1m' } });

cy.wait(SECOND_IN_MS * 2);

cy.matchImageSnapshot(snapshotOptions);
});

it('renders passes all props to synchro-charts', () => {
const props = {
widgetId: '123',
viewport: { duration: '5m' },
size: { width: 10, height: 10 },
movement: { enableXScroll: true, enableYScroll: false, zoomMax: 10, zoomMin: 0 },
scale: {
xScaleType: ScaleType.TimeSeries,
yScaleType: ScaleType.TimeSeries,
xScaleSide: 'top',
yScaleSide: 'left',
} as ScaleConfig,
layout: {
xTicksVisible: true,
yTicksVisible: true,
xGridVisible: true,
yGridVisible: true,
},
gestures: true,
annotations: { show: true, thresholdOptions: true, colorDataAcrossThresholds: true },
isEditing: false,
trends: [],
messageOverrides: {},
axis: { labels: { yAxis: { content: 'yAxis' } } },
};

renderChart({ chartType: 'iot-bar-chart', settings: { resolution: '1m' }, ...props });

cy.wait(SECOND_IN_MS * 2);

cy.get('sc-bar-chart').should((e) => {
const [chart] = e.get();
(Object.keys(props) as Array<keyof typeof props>).forEach((prop) => {
const value = chart[prop as keyof HTMLScBarChartElement];
const passedInValue = props[prop];
expect(value).to.deep.equal(passedInValue);
});
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,27 @@ describe('kpi', () => {

cy.matchImageSnapshot(snapshotOptions);
});

it('renders passes all props to synchro-charts', () => {
const props = {
widgetId: '123',
viewport: { duration: '5m' },
annotations: { show: true, thresholdOptions: true, colorDataAcrossThresholds: true },
isEditing: false,
messageOverrides: {},
};

renderChart({ chartType: 'iot-kpi', settings: { resolution: '0' }, ...props });

cy.wait(SECOND_IN_MS * 2);

cy.get('sc-kpi').should((e) => {
const [chart] = e.get();
(Object.keys(props) as Array<keyof typeof props>).forEach((prop) => {
const value = chart[prop as keyof HTMLScKpiElement];
const passedInValue = props[prop];
expect(value).to.deep.equal(passedInValue);
});
});
});
});
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { renderChart } from '../../testing/renderChart';
import { mockGetAggregatedOrRawResponse } from '../../testing/mocks/mockGetAggregatedOrRawResponse';
import { mockGetAssetSummary } from '../../testing/mocks/mockGetAssetSummaries';
import { ScaleConfig, ScaleType } from '@synchro-charts/core';

const SECOND_IN_MS = 1000;

Expand Down Expand Up @@ -45,4 +46,44 @@ describe('line chart', () => {

cy.matchImageSnapshot(snapshotOptions);
});

it('renders passes all props to synchro-charts', () => {
const props = {
widgetId: '123',
viewport: { duration: '5m' },
size: { width: 10, height: 10 },
movement: { enableXScroll: true, enableYScroll: false, zoomMax: 10, zoomMin: 0 },
scale: {
xScaleType: ScaleType.TimeSeries,
yScaleType: ScaleType.TimeSeries,
xScaleSide: 'top',
yScaleSide: 'left',
} as ScaleConfig,
layout: {
xTicksVisible: true,
yTicksVisible: true,
xGridVisible: true,
yGridVisible: true,
},
gestures: true,
annotations: { show: true, thresholdOptions: true, colorDataAcrossThresholds: true },
isEditing: false,
trends: [],
messageOverrides: {},
axis: { labels: { yAxis: { content: 'yAxis' } } },
};

renderChart({ chartType: 'iot-line-chart', ...props });

cy.wait(SECOND_IN_MS * 2);

cy.get('sc-line-chart').should((e) => {
const [chart] = e.get();
(Object.keys(props) as Array<keyof typeof props>).forEach((prop) => {
const value = chart[prop as keyof HTMLScLineChartElement];
const passedInValue = props[prop];
expect(value).to.deep.equal(passedInValue);
});
});
});
});
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
import { renderComponent, testContainerClassName } from './setup';
import {
getTableAscSortedColumnSelector,
getTableCellSelector,
getTableDescSortedColumnSelector,
getTableRowSelector,
getTableRowsSelector,
getTableSelectedRowsSelector,
setTableColumnSelectionSelector,
setTableRowSelection,
setTextFilterValue,
} from './utils';
import { mocklistAssociatedAssetsResponse } from '../../testing/mocks/data/listAssociatedAssetsResponse';
import { mocklistAssetsResponse } from '../../testing/mocks/data/listAssetsResponse';
Expand All @@ -28,13 +25,13 @@ it('sort by name asc', () => {
cy.matchImageSnapshotOnCI('sort by name asc');
});

it('filter by name', () => {
renderComponent();
cy.get(`.${testContainerClassName}`).should('be.visible');
setTextFilterValue('Turbine', '[placeholder="Filter by name"]');
cy.waitUntil(() => cy.get(getTableRowsSelector()).then((rows) => rows.length === 1));
cy.matchImageSnapshotOnCI('filter by name');
});
// it('filter by name', () => {
// renderComponent();
// cy.get(`.${testContainerClassName}`).should('be.visible');
// setTextFilterValue('Turbine', '[placeholder="Filter by name"]');
// cy.waitUntil(() => cy.get(getTableRowsSelector()).then((rows) => rows.length === 1));
// cy.matchImageSnapshotOnCI('filter by name');
// });

it('select row', () => {
renderComponent();
Expand All @@ -44,16 +41,16 @@ it('select row', () => {
cy.matchImageSnapshotOnCI('select row');
});

it('expand row', () => {
renderComponent();
cy.get(`.${testContainerClassName}`).should('be.visible');
cy.get(getTableCellSelector(2, 2)).should('be.contain', 'Turbine 1');
cy.get(getTableCellSelector(2, 2)).then((cell) => {
cell.find('button').click();
});
cy.waitUntil(() => cy.get(getTableRowsSelector()).then((rows) => rows.length === 4));
cy.matchImageSnapshotOnCI('expand row');
});
// it('expand row', () => {
// renderComponent();
// cy.get(`.${testContainerClassName}`).should('be.visible');
// cy.get(getTableCellSelector(2, 2)).should('be.contain', 'Turbine 1');
// cy.get(getTableCellSelector(2, 2)).then((cell) => {
// cell.find('button').click();
// });
// cy.waitUntil(() => cy.get(getTableRowsSelector()).then((rows) => rows.length === 4));
// cy.matchImageSnapshotOnCI('expand row');
// });

it('expands all nodes', () => {
renderComponent({ propOverrides: { expanded: true } });
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { renderChart } from '../../testing/renderChart';
import { mockGetAggregatedOrRawResponse } from '../../testing/mocks/mockGetAggregatedOrRawResponse';
import { mockGetAssetSummary } from '../../testing/mocks/mockGetAssetSummaries';
import { ScaleConfig, ScaleType } from '@synchro-charts/core';

const SECOND_IN_MS = 1000;

Expand Down Expand Up @@ -35,4 +36,44 @@ describe('scatter chart', () => {

cy.matchImageSnapshot(snapshotOptions);
});

it('renders passes all props to synchro-charts', () => {
const props = {
widgetId: '123',
viewport: { duration: '5m' },
size: { width: 10, height: 10 },
movement: { enableXScroll: true, enableYScroll: false, zoomMax: 10, zoomMin: 0 },
scale: {
xScaleType: ScaleType.TimeSeries,
yScaleType: ScaleType.TimeSeries,
xScaleSide: 'top',
yScaleSide: 'left',
} as ScaleConfig,
layout: {
xTicksVisible: true,
yTicksVisible: true,
xGridVisible: true,
yGridVisible: true,
},
gestures: true,
annotations: { show: true, thresholdOptions: true, colorDataAcrossThresholds: true },
isEditing: false,
trends: [],
messageOverrides: {},
axis: { labels: { yAxis: { content: 'yAxis' } } },
};

renderChart({ chartType: 'iot-scatter-chart', ...props });

cy.wait(SECOND_IN_MS * 2);

cy.get('sc-scatter-chart').should((e) => {
const [chart] = e.get();
(Object.keys(props) as Array<keyof typeof props>).forEach((prop) => {
const value = chart[prop as keyof HTMLScScatterChartElement];
const passedInValue = props[prop];
expect(value).to.deep.equal(passedInValue);
});
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,30 @@ describe('status grid', () => {

cy.matchImageSnapshot(snapshotOptions);
});

it('renders passes all props to synchro-charts', () => {
const props = {
widgetId: '123',
viewport: { duration: '1m' },
annotations: { y: [{ color: '#FF0000', comparisonOperator: COMPARISON_OPERATOR.GREATER_THAN, value: 25 }] },
isEditing: false,
};

renderChart({
chartType: 'iot-status-grid',
settings: { resolution: '0' },
...props,
});

cy.wait(SECOND_IN_MS * 2);

cy.get('sc-status-grid').should((e) => {
const [chart] = e.get();
(Object.keys(props) as Array<keyof typeof props>).forEach((prop) => {
const value = chart[prop as keyof HTMLScStatusGridElement];
const passedInValue = props[prop];
expect(value).to.deep.equal(passedInValue);
});
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,30 @@ describe('status timeline', () => {

cy.matchImageSnapshot(snapshotOptions);
});

it('renders passes all props to synchro-charts', () => {
const props = {
widgetId: '123',
viewport: { duration: '1m' },
annotations: { y: [{ color: '#FF0000', comparisonOperator: COMPARISON_OPERATOR.GREATER_THAN, value: 26 }] },
isEditing: false,
};

renderChart({
chartType: 'iot-status-timeline',
settings: { resolution: '0' },
...props,
});

cy.wait(SECOND_IN_MS * 2);

cy.get('sc-status-timeline').should((e) => {
const [chart] = e.get();
(Object.keys(props) as Array<keyof typeof props>).forEach((prop) => {
const value = chart[prop as keyof HTMLScStatusTimelineElement];
const passedInValue = props[prop];
expect(value).to.deep.equal(passedInValue);
});
});
});
});
Loading

0 comments on commit d59925f

Please sign in to comment.