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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
The diff you're trying to view is too large. We only load the first 3000 changed files.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -59,3 +59,8 @@ typings/

# next.js build output
.next

allure-report
.build
.idea
.DS_Store
1 change: 1 addition & 0 deletions CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Code of Conduct
36 changes: 36 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Contributing
When contributing to this repository, please first discuss the change you wish to make with the team if the change is not reflected into a `JIRA` or `GITHUB` task.

## Branch name
Type: (feature, fix, test, docs, refactor, style, chore)
- **[type]/[JIRA_OR_ISSUE_KEY]-[short_description_or_full_task_name]**

##### E.g.
- fix/CH5C-512-update-wct-tests-for-ch5-list

## Commit messages
Commit messages should follow Semantic Commit Messages rules. [Read more about Semantic Commit Messages](https://gist.github.com/joshbuchea/6f47e86d2510bce28f8e7f42ae84c716).

- **\[type]\(scope?): [commit_description]**

##### Notes:
- the body of the commit message can contain additional info, jira task link, PR link, and so on.
- use present tense in the commit message

## Pull Requests
When opening a new pull request please take into account the following steps:
- the Pull Request is concise, and doesn't contain other out of the scope changes
- it should have at least two Reviewers
- it should have at least one Assignee
- if the PR will be merged at the next release the `release` label should be added
- use appropriate labels if they are available

## Contributing to the projects
- When adding or updating a feature, fixing an issue, writing documentation or making any kind of changes in the source code, if applicable, make sure unit or wct tests are created or updated accordingly.
- Because of the nature of the project, for UI components, WCT Tests are preferred over unit tests.
They are located inside the crestron-components-lib/wct_tests folder, while unit tests should be written in the corresponding folder.
- Additionally, if new attributes are added for ch5-components, make sure to document them in the showcase application and add them to the vs code extension schema, by updating the interfaces in
crestron-components-lib/_interfaces and running the metadata generator (check the corresponding [readme](crestron-metadata-generator/README.md)).

## Resources
- Work In Progress
2 changes: 2 additions & 0 deletions GOVERNANCE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Governance
This document defines governance policies for the Crestron Components Library project.
10 changes: 10 additions & 0 deletions LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
Copyright (C) 2018 to the present, Crestron Electronics, Inc.
All rights reserved.
No part of this software may be reproduced in any form, machine
or natural, without the express written consent of Crestron Electronics.
Use of this source code is subject to the terms of the Crestron Software
Development Tools License Agreement under which you licensed this source code.

If you did not accept the terms of the license agreement,
you are not authorized to use this software. For the terms of the license,
please see the license agreement between you and Crestron at http://www.crestron.com/sla.
29 changes: 27 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,27 @@
# CH5ComponentLibrary
Crestron HTML5 Javascript Component Library
<p align="center">
<img src="https://kenticoprod.azureedge.net/kenticoblob/crestron/media/crestron/generalsiteimages/crestron-logo.png">
</p>

# CH5 - Creston Components library (CrComLib) - Getting Started

#### Continuous Integration and Deployment Status - CH5 Library Only

| DEV NIGHTLY - latest-dev | Status |
| ------ | ----------- |
| Build Pipeline |![Build status](https://dev.azure.com/crestron-mobile-devops/MobileApps/_apis/build/status/Blackbird/CoreBuild/CH5ComponentLibrary?branchName=dev)
| Release Pipeline | ![Deployment status](https://vsrm.dev.azure.com/crestron-mobile-devops/_apis/public/Release/badge/0403b700-ab40-43cd-9990-961924c561bc/38/93) |
| NPM | ![npm (tag)](https://img.shields.io/npm/v/@crestron/ch5-crcomlib/latest-dev) |

| MASTER-QE - latest-qe | Status |
| ------ | ----------- |
| Build Pipeline |![Build status](https://dev.azure.com/crestron-mobile-devops/MobileApps/_apis/build/status/Blackbird/CoreBuild/CH5ComponentLibrary?branchName=master)
| Release Pipeline | ![Deployment status](https://vsrm.dev.azure.com/crestron-mobile-devops/_apis/public/Release/badge/0403b700-ab40-43cd-9990-961924c561bc/38/94) |
| NPM | ![npm (tag)](https://img.shields.io/npm/v/@crestron/ch5-crcomlib/latest-qe) |

#### For further details and setup guides, please consult the README in each project.
- [CH5 Component Library](./crestron-components-lib/README.md)
- [CH5 Component Library Use Case Tests](./crestron-components-lib-tests/README.md)
- [CH5 Component SASS](./crestron-components-sass/README.md)
- [CH5 Metadata Generator](./crestron-metadata-generator/README.md)
- [Showcase Application](./showcase-app/README.md)
- [Showcase Application Automated Tests](./showcase-app-automated-tests/README.md)
11 changes: 11 additions & 0 deletions crestron-components-lib-tests/LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# License
Copyright (C) 2018 to the present, Crestron Electronics, Inc.
All rights reserved.
No part of this software may be reproduced in any form, machine
or natural, without the express written consent of Crestron Electronics.
Use of this source code is subject to the terms of the Crestron Software License Agreement
under which you licensed this source code.

If you did not accept the terms of the license agreement,
you are not authorized to use this software. For the terms of the license,
please see the license agreement between you and Crestron at http://www.crestron.com/sla.
26 changes: 26 additions & 0 deletions crestron-components-lib-tests/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<p align="center">
<img src="https://kenticoprod.azureedge.net/kenticoblob/crestron/media/crestron/generalsiteimages/crestron-logo.png">
</p>

# Creston Components library Unit Tests

- Tests are written in typescript
- Uses mocha, chai and ts-node

## Requirements

- Node and npm versions:
- node v8.11.1
- npm v5.6.0 ( npm is not being used, yarn is used instead )
- Yarn v1.6.0 (https://yarnpkg.com/lang/en/docs/install)
- Global packages:
- typescript 2.8.3

### Running the tests

- ```yarn install```
- ```yarn run test``` - runs all tests from src folder

### Running the tests in Webstorm

- add:``` --require src/tests/dom-mock.js --require ts-node/register``` to extra Mocha options from the edit configuration menu
23 changes: 23 additions & 0 deletions crestron-components-lib-tests/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"name": "crestron-components-lib-tests",
"version": "1.0.0",
"main": "index.js",
"license": "SEE LICENSE IN LICENSE.txt",
"devDependencies": {
"@types/chai": "^4.1.7",
"@types/mocha": "^5.2.6",
"@types/node": "^12.11.1",
"chai": "^4.2.0",
"jsdom": "^15.1.1",
"jsdom-global": "^3.0.2",
"mocha": "^6.1.3",
"npm-run-all": "^4.1.5",
"rimraf": "^2.6.3",
"ts-node": "^8.1.0",
"typescript": "^3.4.3"
},
"scripts": {
"clean": "rimraf ./allure-results && rimraf ./build",
"test": "npm-run-all clean && tsc -p tsconfig.json && mocha --require src/tests/dom-mock.js --require ts-node/register src/tests/**/*.ts"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,159 @@
// Copyright (C) 2018 to the present, Crestron Electronics, Inc.
// All rights reserved.
// No part of this software may be reproduced in any form, machine
// or natural, without the express written consent of Crestron Electronics.
// Use of this source code is subject to the terms of the Crestron Software License Agreement
// under which you licensed this source code.

import { expect } from 'chai';
import { Ch5SignalFactory, publishEvent } from '../../../../crestron-components-lib/src/ch5-core';
import { Ch5Resync } from "../../../../crestron-components-lib/src/ch5-resync/ch5-resync";
import { ICh5StatesAtDefaultValueModel } from "../../../../crestron-components-lib/src/ch5-resync/models/ch5-states-at-default-value-model";
import { Ch5ResyncTestUtilities } from "../../utilities/ch5-resync-test-utilities";
import { IResynchronizationRequestModel } from "../../../../crestron-components-lib/src/ch5-resync/models/resynchronization-request-model";

let ch5SignalFactory;
let ch5ResyncInstance;

describe('Ch5 Resync Single CCS Resync - Business logic miscellaneous tests', () => {

beforeEach(() => {
ch5SignalFactory = Ch5SignalFactory.getInstance();
ch5ResyncInstance = Ch5Resync.Instance;
ch5ResyncInstance._statesAtDefaultValue = [];
});

it('On EndOfUpdate if an event / state does not exist will move to the next one', () => {
ch5ResyncInstance._statesAtDefaultValue.push({
name: 'state_does_not_exist',
type: 'boolean'
} as ICh5StatesAtDefaultValueModel);
publishEvent('string', 'next_state', true);
ch5ResyncInstance._statesAtDefaultValue.push({
name: 'next_state',
type: 'string'
} as ICh5StatesAtDefaultValueModel);

ch5ResyncInstance.setRemainingStatesToDefaultValue();

const modifiedStringState = ch5SignalFactory.getStringSignal('next_state', false);
expect(modifiedStringState.value).to.equal('');
const stateNotFound = ch5SignalFactory.getStringSignal('state_does_not_exist', false);
expect(stateNotFound).to.equal(null);
});

it('On ClearAll will not add Csig.State_Synchronization event to _statesAtDefaultValue', () => {
publishEvent(Ch5ResyncTestUtilities.resyncEventType, Ch5ResyncTestUtilities.resyncEventName, Ch5ResyncTestUtilities.resyncEventValueOnClearRange);

expect(ch5ResyncInstance._statesAtDefaultValue.map(x => x.name).indexOf('Csig.State_Synchronization')).to.equal(-1);
});

it('On ClearRange will not add Csig.State_Synchronization event to _statesAtDefaultValue', () => {
publishEvent(Ch5ResyncTestUtilities.resyncEventType, Ch5ResyncTestUtilities.resyncEventName, Ch5ResyncTestUtilities.resyncEventValueOnClearAll);

expect(ch5ResyncInstance._statesAtDefaultValue.map(x => x.name).indexOf('Csig.State_Synchronization')).to.equal(-1);
});

it('On ClearRange will update _statesAtDefaultValue with received [BOOLEAN] signals', () => {
ch5ResyncInstance.onReceiveClearRange(Ch5ResyncTestUtilities.clearRangeDataModel(), ['Csig']);

expect(ch5ResyncInstance._statesAtDefaultValue.filter(x => x.type === 'boolean').length).to.equal(33);
expect(ch5ResyncInstance._statesAtDefaultValue.map(x => x.name).indexOf('boolean_toggle_element')).to.be.greaterThan(-1);
expect(ch5ResyncInstance._statesAtDefaultValue.map(x => x.name).indexOf('some_random_element')).to.be.greaterThan(-1);
expect(ch5ResyncInstance._statesAtDefaultValue.map(x => x.name).indexOf('fb10')).to.be.greaterThan(-1);
expect(ch5ResyncInstance._statesAtDefaultValue.map(x => x.name).indexOf('fb40')).to.be.greaterThan(-1);
});

it('On ClearRange will update _statesAtDefaultValue with received [NUMBER] signals', () => {
ch5ResyncInstance.onReceiveClearRange(Ch5ResyncTestUtilities.clearRangeDataModel(), ['Csig']);

expect(ch5ResyncInstance._statesAtDefaultValue.filter(x => x.type === 'number').length).to.equal(13);
expect(ch5ResyncInstance._statesAtDefaultValue.map(x => x.name).indexOf('numeric_input_element')).to.be.greaterThan(-1);
expect(ch5ResyncInstance._statesAtDefaultValue.map(x => x.name).indexOf('some_random_element')).to.be.greaterThan(-1);
expect(ch5ResyncInstance._statesAtDefaultValue.map(x => x.name).indexOf('fb20')).to.be.greaterThan(-1);
expect(ch5ResyncInstance._statesAtDefaultValue.map(x => x.name).indexOf('fb30')).to.be.greaterThan(-1);
});

it('On ClearRange will update _statesAtDefaultValue with received [STRING] signals', () => {
ch5ResyncInstance.onReceiveClearRange(Ch5ResyncTestUtilities.clearRangeDataModel(), ['Csig']);

expect(ch5ResyncInstance._statesAtDefaultValue.filter(x => x.type === 'string').length).to.equal(43);
expect(ch5ResyncInstance._statesAtDefaultValue.map(x => x.name).indexOf('string_input_element')).to.be.greaterThan(-1);
expect(ch5ResyncInstance._statesAtDefaultValue.map(x => x.name).indexOf('some_random_element')).to.be.greaterThan(-1);
expect(ch5ResyncInstance._statesAtDefaultValue.map(x => x.name).indexOf('fb30')).to.be.greaterThan(-1);
expect(ch5ResyncInstance._statesAtDefaultValue.map(x => x.name).indexOf('fb70')).to.be.greaterThan(-1);
});

it('On ClearRange will not add join states if both joinLow and joinHigh are equal to 0', () => {
const model = Ch5ResyncTestUtilities.clearRangeDataModel();
model.boolean.joinLow = 0;
model.boolean.joinHigh = 0;
model.numeric.joinLow = 0;
model.numeric.joinHigh = 0;
model.string.joinLow = 0;
model.string.joinHigh = 0;

ch5ResyncInstance.onReceiveClearRange(model, ['boolean_toggle_element', 'some_random_element']);

expect(ch5ResyncInstance._statesAtDefaultValue.filter(x => x.type === 'boolean').length).to.equal(0);
expect(ch5ResyncInstance._statesAtDefaultValue.filter(x => x.type === 'number').length).to.equal(1);
expect(ch5ResyncInstance._statesAtDefaultValue.filter(x => x.type === 'string').length).to.equal(1);
});

it('On ClearRange if no stateNames are provided for a given event type can still compute its joins and move to the next event type', () => {
const model = Ch5ResyncTestUtilities.clearRangeDataModel();
model.boolean.stateNames = [];

ch5ResyncInstance.onReceiveClearRange(model, []);

expect(ch5ResyncInstance._statesAtDefaultValue.filter(x => x.type === 'boolean').length).to.equal(31);
expect(ch5ResyncInstance._statesAtDefaultValue.filter(x => x.type === 'string').length).to.equal(43);
expect(ch5ResyncInstance._statesAtDefaultValue.map(x => x.name).indexOf('string_input_element')).to.be.greaterThan(-1);
expect(ch5ResyncInstance._statesAtDefaultValue.map(x => x.name).indexOf('some_random_element')).to.be.greaterThan(-1);
expect(ch5ResyncInstance._statesAtDefaultValue.map(x => x.name).indexOf('fb30')).to.be.greaterThan(-1);
expect(ch5ResyncInstance._statesAtDefaultValue.map(x => x.name).indexOf('fb70')).to.be.greaterThan(-1);
});

it('On ClearRange will not add any state of type object to _statesAtDefaultValue', () => {
const model = Ch5ResyncTestUtilities.clearRangeDataModel();
model.boolean.stateNames = [];

ch5ResyncInstance.onReceiveClearRange(model, []);

expect(ch5ResyncInstance._statesAtDefaultValue.filter(x => x.type === 'object').length).to.equal(0);
});

it('On ClearAll will exclude states based on excludePrefixes', () => {
const onClearAll: IResynchronizationRequestModel = {
id: "Mock_ID",
state: "ClearAll",
value: {excludePrefixes: ["test_state"]}
};

publishTestSignals();
publishEvent('object', 'different_key_test_state_object_rcb', {"rcb": {"value": 33, "time": 500}});
publishEvent(Ch5ResyncTestUtilities.resyncEventType, Ch5ResyncTestUtilities.resyncEventName, onClearAll);

expect(ch5ResyncInstance._statesAtDefaultValue.map(x => x.name).indexOf('test_state_boolean')).to.equal(-1);
expect(ch5ResyncInstance._statesAtDefaultValue.map(x => x.name).indexOf('test_state_string')).to.equal(-1);
expect(ch5ResyncInstance._statesAtDefaultValue.map(x => x.name).indexOf('test_state_numeric')).to.equal(-1);
expect(ch5ResyncInstance._statesAtDefaultValue.map(x => x.name).indexOf('test_state_object_rcb')).to.equal(-1);
expect(ch5ResyncInstance._statesAtDefaultValue.map(x => x.name).indexOf('different_key_test_state_object_rcb')).to.be.greaterThan(-1);
});

it('On ClearRange will exclude states based on excludePrefixes', () => {
ch5ResyncInstance.onReceiveClearRange(Ch5ResyncTestUtilities.clearRangeDataModel(), ['boolean_toggle_element', 'some_random_element', 'umeric_input_element']);

expect(ch5ResyncInstance._statesAtDefaultValue.map(x => x.name).indexOf('boolean_toggle_element')).to.be.equal(-1);
expect(ch5ResyncInstance._statesAtDefaultValue.map(x => x.name).indexOf('some_random_element')).to.be.equal(-1);
expect(ch5ResyncInstance._statesAtDefaultValue.map(x => x.name).indexOf('numeric_input_element')).to.be.greaterThan(-1);
});
});

// Utilities:
function publishTestSignals() {
publishEvent('boolean', 'test_state_boolean', true);
publishEvent('string', 'test_state_string', 'random_string');
publishEvent('numeric', 'test_state_numeric', 50);
publishEvent('object', 'test_state_object_rcb', {"rcb": {"value": 33, "time": 500}});
}
Loading