-
Notifications
You must be signed in to change notification settings - Fork 60
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: backfill component integration tests (#66)
* backfill components integration tests * remove unfinished components * add iot webgl context Co-authored-by: Norbert Nader <[email protected]>
- Loading branch information
1 parent
f21b230
commit ac16b08
Showing
21 changed files
with
269 additions
and
175 deletions.
There are no files selected for viewing
Binary file added
BIN
+14.1 KB
...ion/iot-bar-chart/iot-bar-chart.spec.component.ts/bar chart -- renders.snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+8.12 KB
...snapshots/integration/iot-kpi/iot-kpi.spec.component.ts/kpi -- renders.snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+12 KB
.../iot-line-chart/iot-line-chart.spec.component.ts/line chart -- renders.snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+12 KB
...ter-chart/iot-scatter-chart.spec.component.ts/scatter chart -- renders.snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+3.76 KB
...t-status-grid/iot-status-grid.spec.component.ts/status grid -- renders.snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+8.95 KB
...eline/iot-status-timeline.spec.component.ts/status timeline -- renders.snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 0 additions & 56 deletions
56
packages/components/src/components/iot-table/iot-table.spec.ts
This file was deleted.
Oops, something went wrong.
83 changes: 0 additions & 83 deletions
83
packages/components/src/components/iot-table/iot-table.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,83 +0,0 @@ | ||
import { Component, Prop, h, State, Listen, Watch } from '@stencil/core'; | ||
import { Annotations, DataStream as SynchroChartsDataStream, MinimalViewPortConfig } from '@synchro-charts/core'; | ||
import { | ||
StyleSettingsMap, | ||
SiteWiseTimeSeriesDataProvider, | ||
IoTAppKit, | ||
TimeSeriesQuery, | ||
TimeSeriesDataRequestSettings, | ||
composeSiteWiseProviders, | ||
} from '@iot-app-kit/core'; | ||
|
||
@Component({ | ||
tag: 'iot-table', | ||
shadow: false, | ||
}) | ||
export class IotTable { | ||
@Prop() appKit!: IoTAppKit; | ||
|
||
@Prop() annotations: Annotations; | ||
|
||
@Prop() queries!: TimeSeriesQuery<SiteWiseTimeSeriesDataProvider>[]; | ||
|
||
@Prop() viewport!: MinimalViewPortConfig; | ||
|
||
@Prop() settings: TimeSeriesDataRequestSettings = {}; | ||
|
||
@Prop() widgetId: string; | ||
|
||
@Prop() styleSettings: StyleSettingsMap | undefined; | ||
|
||
@State() provider: SiteWiseTimeSeriesDataProvider; | ||
|
||
private defaultSettings: TimeSeriesDataRequestSettings = { | ||
fetchMostRecentBeforeEnd: true, | ||
}; | ||
|
||
buildProvider() { | ||
this.provider = composeSiteWiseProviders( | ||
this.queries.map((query) => | ||
query.build(this.appKit.session(this.widgetId), { | ||
viewport: this.viewport, | ||
settings: { | ||
...this.defaultSettings, | ||
...this.settings, | ||
}, | ||
}) | ||
) | ||
); | ||
} | ||
|
||
componentWillLoad() { | ||
this.buildProvider(); | ||
} | ||
|
||
@Watch('queries') | ||
@Watch('settings') | ||
@Watch('viewport') | ||
private onPropUpdate() { | ||
this.buildProvider(); | ||
} | ||
|
||
@Listen('dateRangeChange') | ||
private handleDateRangeChange({ detail: [start, end, lastUpdatedBy] }: { detail: [Date, Date, string | undefined] }) { | ||
this.provider.updateViewport({ start, end, lastUpdatedBy }); | ||
} | ||
|
||
render() { | ||
return ( | ||
<iot-time-series-connector | ||
provider={this.provider} | ||
styleSettings={this.styleSettings} | ||
renderFunc={({ dataStreams }) => ( | ||
<sc-table | ||
dataStreams={dataStreams as SynchroChartsDataStream[]} | ||
annotations={this.annotations} | ||
viewport={this.provider.input.request.viewport} | ||
widgetId={this.widgetId} | ||
/> | ||
)} | ||
/> | ||
); | ||
} | ||
} | ||
11 changes: 11 additions & 0 deletions
11
packages/components/src/components/iot-webgl-context/iot-webgl-context.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { Component, h } from '@stencil/core'; | ||
|
||
@Component({ | ||
tag: 'iot-webgl-context', | ||
shadow: false, | ||
}) | ||
export class IotWebglContext { | ||
render() { | ||
return <sc-webgl-context />; | ||
} | ||
} |
38 changes: 38 additions & 0 deletions
38
packages/components/src/integration/iot-bar-chart/iot-bar-chart.spec.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import { renderChart } from '../../testing/renderChart'; | ||
import { mockGetAggregatedOrRawResponse } from '../../testing/mocks/mockGetAggregatedOrRawResponse'; | ||
import { mockGetAssetSummary } from '../../testing/mocks/mockGetAssetSummaries'; | ||
|
||
const SECOND_IN_MS = 1000; | ||
|
||
const snapshotOptions = { | ||
clip: { x: 0, y: 0, width: 400, height: 500 }, | ||
}; | ||
|
||
describe('bar chart', () => { | ||
const assetId = 'some-asset-id'; | ||
const assetModelId = 'some-asset-model-id'; | ||
|
||
before(() => { | ||
cy.intercept('/properties/aggregates?*', (req) => { | ||
req.reply( | ||
mockGetAggregatedOrRawResponse({ | ||
startDate: new Date(req.query.startDate), | ||
endDate: new Date(req.query.endDate), | ||
resolution: req.query.resolution as string, | ||
}) | ||
); | ||
}); | ||
|
||
cy.intercept(`/assets/${assetId}`, (req) => { | ||
req.reply(mockGetAssetSummary({ assetModelId, id: assetId })); | ||
}); | ||
}); | ||
|
||
it('renders', () => { | ||
renderChart({ chartType: 'iot-bar-chart', settings: { resolution: '1m' } }); | ||
|
||
cy.wait(SECOND_IN_MS * 2); | ||
|
||
cy.matchImageSnapshot(snapshotOptions); | ||
}); | ||
}); |
32 changes: 32 additions & 0 deletions
32
packages/components/src/integration/iot-kpi/iot-kpi.spec.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { renderChart } from '../../testing/renderChart'; | ||
import { mockLatestValueResponse } from '../../testing/mocks/mockGetAggregatedOrRawResponse'; | ||
import { mockGetAssetSummary } from '../../testing/mocks/mockGetAssetSummaries'; | ||
|
||
const SECOND_IN_MS = 1000; | ||
|
||
const snapshotOptions = { | ||
clip: { x: 0, y: 0, width: 400, height: 500 }, | ||
}; | ||
|
||
describe('kpi', () => { | ||
const assetId = 'some-asset-id'; | ||
const assetModelId = 'some-asset-model-id'; | ||
|
||
before(() => { | ||
cy.intercept('/properties/latest?*', (req) => { | ||
req.reply(mockLatestValueResponse()); | ||
}); | ||
|
||
cy.intercept(`/assets/${assetId}`, (req) => { | ||
req.reply(mockGetAssetSummary({ assetModelId, id: assetId })); | ||
}); | ||
}); | ||
|
||
it('renders', () => { | ||
renderChart({ chartType: 'iot-kpi', settings: { resolution: '0' }, viewport: { duration: '1m' } }); | ||
|
||
cy.wait(SECOND_IN_MS * 2); | ||
|
||
cy.matchImageSnapshot(snapshotOptions); | ||
}); | ||
}); |
38 changes: 38 additions & 0 deletions
38
packages/components/src/integration/iot-line-chart/iot-line-chart.spec.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import { renderChart } from '../../testing/renderChart'; | ||
import { mockGetAggregatedOrRawResponse } from '../../testing/mocks/mockGetAggregatedOrRawResponse'; | ||
import { mockGetAssetSummary } from '../../testing/mocks/mockGetAssetSummaries'; | ||
|
||
const SECOND_IN_MS = 1000; | ||
|
||
const snapshotOptions = { | ||
clip: { x: 0, y: 0, width: 400, height: 500 }, | ||
}; | ||
|
||
describe('line chart', () => { | ||
const assetId = 'some-asset-id'; | ||
const assetModelId = 'some-asset-model-id'; | ||
|
||
before(() => { | ||
cy.intercept('/properties/aggregates?*', (req) => { | ||
req.reply( | ||
mockGetAggregatedOrRawResponse({ | ||
startDate: new Date(req.query.startDate), | ||
endDate: new Date(req.query.endDate), | ||
resolution: req.query.resolution as string, | ||
}) | ||
); | ||
}); | ||
|
||
cy.intercept(`/assets/${assetId}`, (req) => { | ||
req.reply(mockGetAssetSummary({ assetModelId, id: assetId })); | ||
}); | ||
}); | ||
|
||
it('renders', () => { | ||
renderChart({ chartType: 'iot-line-chart' }); | ||
|
||
cy.wait(SECOND_IN_MS * 2); | ||
|
||
cy.matchImageSnapshot(snapshotOptions); | ||
}); | ||
}); |
Oops, something went wrong.