Skip to content

Commit

Permalink
fix(tests): cleanup tests from devwork
Browse files Browse the repository at this point in the history
  • Loading branch information
jmbuss committed Jul 8, 2022
1 parent ff565fc commit 18f270e
Show file tree
Hide file tree
Showing 17 changed files with 113 additions and 45 deletions.
2 changes: 1 addition & 1 deletion lerna.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "1.4.0",
"version": "1.5.0",
"packages": [
"packages/*"
],
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 4 additions & 4 deletions packages/components/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"publishConfig": {
"access": "public"
},
"version": "1.4.0",
"version": "1.5.0",
"description": "IoT App Kit Components",
"main": "dist/index.cjs.js",
"module": "dist/custom-elements/index.js",
Expand Down Expand Up @@ -41,9 +41,9 @@
"@awsui/collection-hooks": "^1.0.0",
"@awsui/components-react": "^3.0.0",
"@awsui/design-tokens": "^3.0.0",
"@iot-app-kit/core": "^1.4.0",
"@iot-app-kit/related-table": "^1.4.0",
"@iot-app-kit/source-iotsitewise": "^1.4.0",
"@iot-app-kit/core": "^1.5.0",
"@iot-app-kit/related-table": "^1.5.0",
"@iot-app-kit/source-iotsitewise": "^1.5.0",
"@stencil/core": "^2.7.0",
"@synchro-charts/core": "^5.0.0",
"styled-components": "^5.3.0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,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';
import { mockGetAssetModelSummary } from '../../testing/mocks/mockGetAssetModelSummary';

const SECOND_IN_MS = 1000;

Expand All @@ -25,11 +26,15 @@ describe('bar chart', () => {
});

cy.intercept(`/assets/${assetId}`, (req) => {
req.reply(mockGetAssetSummary({ assetModelId, id: assetId }));
req.reply(mockGetAssetSummary({ assetModelId, assetId }));
});

cy.intercept(`/asset-models/${assetModelId}`, (req) => {
req.reply(mockGetAssetModelSummary({ assetModelId }));
});
});

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

cy.wait(SECOND_IN_MS * 2);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { renderChart, testChartContainerClassNameSelector } from '../../testing/renderChart';
import { mockGetAggregatedOrRawResponse } from '../../testing/mocks/mockGetAggregatedOrRawResponse';
import { mockGetAssetSummary } from '../../testing/mocks/mockGetAssetSummaries';
import { mockGetAssetModelSummary } from '../../testing/mocks/mockGetAssetModelSummary';

const SECOND_IN_MS = 1000;

Expand Down Expand Up @@ -52,7 +53,11 @@ describe('handles gestures', () => {
});

cy.intercept(`/assets/${assetId}`, (req) => {
req.reply(mockGetAssetSummary({ assetModelId, id: assetId }));
req.reply(mockGetAssetSummary({ assetModelId, assetId }));
});

cy.intercept(`/asset-models/${assetModelId}`, (req) => {
req.reply(mockGetAssetModelSummary({ assetModelId }));
});
});

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { renderChart } from '../../testing/renderChart';
import { mockLatestValueResponse } from '../../testing/mocks/mockGetAggregatedOrRawResponse';
import { mockGetAssetSummary } from '../../testing/mocks/mockGetAssetSummaries';
import { mockGetAssetModelSummary } from '../../testing/mocks/mockGetAssetModelSummary';

const SECOND_IN_MS = 1000;

Expand All @@ -18,7 +19,11 @@ describe('kpi', () => {
});

cy.intercept(`/assets/${assetId}`, (req) => {
req.reply(mockGetAssetSummary({ assetModelId, id: assetId }));
req.reply(mockGetAssetSummary({ assetModelId, assetId }));
});

cy.intercept(`/asset-models/${assetModelId}`, (req) => {
req.reply(mockGetAssetModelSummary({ assetModelId }));
});
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,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';
import { mockGetAssetModelSummary } from '../../testing/mocks/mockGetAssetModelSummary';

const SECOND_IN_MS = 1000;

Expand Down Expand Up @@ -35,7 +36,11 @@ describe('line chart', () => {
});

cy.intercept(`/assets/${assetId}`, (req) => {
req.reply(mockGetAssetSummary({ assetModelId, id: assetId }));
req.reply(mockGetAssetSummary({ assetModelId, assetId }));
});

cy.intercept(`/asset-models/${assetModelId}`, (req) => {
req.reply(mockGetAssetModelSummary({ assetModelId }));
});
});

Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
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 @@ -25,13 +28,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 @@ -41,16 +44,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
Expand Up @@ -2,6 +2,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';
import { mockGetAssetModelSummary } from '../../testing/mocks/mockGetAssetModelSummary';

const SECOND_IN_MS = 1000;

Expand All @@ -25,7 +26,11 @@ describe('scatter chart', () => {
});

cy.intercept(`/assets/${assetId}`, (req) => {
req.reply(mockGetAssetSummary({ assetModelId, id: assetId }));
req.reply(mockGetAssetSummary({ assetModelId, assetId }));
});

cy.intercept(`/asset-models/${assetModelId}`, (req) => {
req.reply(mockGetAssetModelSummary({ assetModelId }));
});
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { renderChart } from '../../testing/renderChart';
import { mockLatestValueResponse } from '../../testing/mocks/mockGetAggregatedOrRawResponse';
import { mockGetAssetSummary } from '../../testing/mocks/mockGetAssetSummaries';
import { COMPARISON_OPERATOR } from '@synchro-charts/core';
import { mockGetAssetModelSummary } from '../../testing/mocks/mockGetAssetModelSummary';

const SECOND_IN_MS = 1000;

Expand All @@ -19,7 +20,11 @@ describe('status grid', () => {
});

cy.intercept(`/assets/${assetId}`, (req) => {
req.reply(mockGetAssetSummary({ assetModelId, id: assetId }));
req.reply(mockGetAssetSummary({ assetModelId, assetId }));
});

cy.intercept(`/asset-models/${assetModelId}`, (req) => {
req.reply(mockGetAssetModelSummary({ assetModelId }));
});
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { renderChart } from '../../testing/renderChart';
import { mockGetAggregatedOrRawResponse } from '../../testing/mocks/mockGetAggregatedOrRawResponse';
import { mockGetAssetSummary } from '../../testing/mocks/mockGetAssetSummaries';
import { COMPARISON_OPERATOR } from '@synchro-charts/core';
import { mockGetAssetModelSummary } from '../../testing/mocks/mockGetAssetModelSummary';

const SECOND_IN_MS = 1000;

Expand Down Expand Up @@ -35,7 +36,11 @@ describe('status timeline', () => {
});

cy.intercept(`/assets/${assetId}`, (req) => {
req.reply(mockGetAssetSummary({ assetModelId, id: assetId }));
req.reply(mockGetAssetSummary({ assetModelId, assetId }));
});

cy.intercept(`/asset-models/${assetModelId}`, (req) => {
req.reply(mockGetAssetModelSummary({ assetModelId }));
});
});

Expand Down
23 changes: 23 additions & 0 deletions packages/components/src/testing/mocks/mockGetAssetModelSummary.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { DescribeAssetModelResponse } from '@aws-sdk/client-iotsitewise';

export const mockGetAssetModelSummary = (
assetSummary: Partial<DescribeAssetModelResponse> = {}
): DescribeAssetModelResponse => ({
assetModelId: 'some-asset-model-id',
assetModelName: 'some-asset-model-name',
assetModelDescription: undefined,
assetModelCreationDate: undefined,
assetModelLastUpdateDate: undefined,
assetModelStatus: undefined,
assetModelHierarchies: [],
assetModelArn: undefined,
assetModelProperties: [
{
dataType: 'DOUBLE',
id: 'some-property-id',
name: 'Asset Name',
type: undefined,
},
],
...assetSummary,
});
25 changes: 16 additions & 9 deletions packages/components/src/testing/mocks/mockGetAssetSummaries.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,20 @@
import { AssetSummary } from '@aws-sdk/client-iotsitewise';
import { DescribeAssetResponse } from '@aws-sdk/client-iotsitewise';

export const mockGetAssetSummary = (assetSummary: Partial<AssetSummary> = {}): AssetSummary => ({
id: 'some-asset-id',
name: 'some-asset-summary-name',
export const mockGetAssetSummary = (assetSummary: Partial<DescribeAssetResponse> = {}): DescribeAssetResponse => ({
assetId: 'some-asset-id',
assetName: 'some-asset-summary-name',
assetModelId: 'some-asset-model-id',
creationDate: undefined,
lastUpdateDate: undefined,
status: undefined,
hierarchies: [],
arn: undefined,
assetCreationDate: undefined,
assetLastUpdateDate: undefined,
assetStatus: undefined,
assetHierarchies: [],
assetArn: undefined,
assetProperties: [
{
id: 'some-property-id',
name: 'Asset Name',
dataType: 'DOUBLE',
},
],
...assetSummary,
});
2 changes: 1 addition & 1 deletion packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"publishConfig": {
"access": "public"
},
"version": "1.4.0",
"version": "1.5.0",
"description": "IoT Application Kit core",
"main": "./dist/index.cj.js",
"module": "./dist/index.js",
Expand Down
4 changes: 2 additions & 2 deletions packages/react-components/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"access": "public"
},
"sideEffects": false,
"version": "1.4.0",
"version": "1.5.0",
"description": "React specific wrapper for IoT Application Kit",
"author": {
"name": "Amazon Web Services",
Expand Down Expand Up @@ -41,7 +41,7 @@
"typescript": "^3.3.4000"
},
"dependencies": {
"@iot-app-kit/components": "^1.4.0"
"@iot-app-kit/components": "^1.5.0"
},
"peerDependencies": {
"react": "^17.0.2",
Expand Down
2 changes: 1 addition & 1 deletion packages/related-table/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"publishConfig": {
"access": "public"
},
"version": "1.4.0",
"version": "1.5.0",
"description": "IoT Application Kit - Related Table component",
"license": "Apache-2.0",
"main": "dist/index.js",
Expand Down
4 changes: 2 additions & 2 deletions packages/source-iotsitewise/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"publishConfig": {
"access": "public"
},
"version": "1.4.0",
"version": "1.5.0",
"description": "AWS IoT SiteWise source for IoT Application Kit",
"homepage": "https://github.com/awslabs/iot-app-kit#readme",
"license": "Apache-2.0",
Expand Down Expand Up @@ -38,7 +38,7 @@
},
"dependencies": {
"@aws-sdk/client-iotsitewise": "^3.39.0",
"@iot-app-kit/core": "^1.4.0",
"@iot-app-kit/core": "^1.5.0",
"@rollup/plugin-typescript": "^8.3.0",
"@synchro-charts/core": "^5.0.0",
"flush-promises": "^1.0.2",
Expand Down

0 comments on commit 18f270e

Please sign in to comment.