Skip to content

Commit

Permalink
Code formating (project-chip#1404)
Browse files Browse the repository at this point in the history
* Code formating and API documentation update
- Ran npx prettier --write . with latest prettier package in zap project
- Update the API documentation by running npm run apidoc
- Fixing the env.test.js because prettier changed the line numbers of the code
  • Loading branch information
brdandu authored Aug 15, 2024
1 parent 7322283 commit 1fe79d8
Show file tree
Hide file tree
Showing 226 changed files with 13,934 additions and 9,731 deletions.
6 changes: 3 additions & 3 deletions cypress/e2e/attribute_validations/bitmap.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,17 @@ describe('Testing BITMAP type validation', () => {
() => {
cy.fixture('data').then((data) => {
cy.get(
`:nth-child(${data.bitmapinputpath}) > [style="min-width: 180px;"] > .q-field > .q-field__inner > .q-field__control > .q-field__control-container > input`
`:nth-child(${data.bitmapinputpath}) > [style="min-width: 180px;"] > .q-field > .q-field__inner > .q-field__control > .q-field__control-container > input`,
)
.clear({ force: true })
.type('test', { force: true })
})
}
},
)
it('check if validation works properly', () => {
cy.fixture('data').then((data) => {
cy.get(
`:nth-child(${data.bitmapinputpath}) > [style="min-width: 180px;"] > .q-field > .q-field__inner > .q-field__bottom > .q-field__messages > div`
`:nth-child(${data.bitmapinputpath}) > [style="min-width: 180px;"] > .q-field > .q-field__inner > .q-field__bottom > .q-field__messages > div`,
).should('exist')
})
})
Expand Down
8 changes: 4 additions & 4 deletions cypress/e2e/attribute_validations/boolean.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ describe('Testing BOOLEAN type validation', () => {
cy.gotoAttributePage(
data.endpoint1,
data.cluster1,
data.booleanclusterpath
data.booleanclusterpath,
)
})
})
Expand All @@ -26,17 +26,17 @@ describe('Testing BOOLEAN type validation', () => {
() => {
cy.fixture('data').then((data) => {
cy.get(
`:nth-child(${data.booleaninputpath}) > [style="min-width: 180px;"] > .q-field > .q-field__inner > .q-field__control > .q-field__control-container > input`
`:nth-child(${data.booleaninputpath}) > [style="min-width: 180px;"] > .q-field > .q-field__inner > .q-field__control > .q-field__control-container > input`,
)
.clear({ force: true })
.type('test', { force: true })
})
}
},
)
it('check if validation works properly', () => {
cy.fixture('data').then((data) => {
cy.get(
`:nth-child(${data.booleaninputpath}) > [style="min-width: 180px;"] > .q-field > .q-field__inner > .q-field__bottom > .q-field__messages > div`
`:nth-child(${data.booleaninputpath}) > [style="min-width: 180px;"] > .q-field > .q-field__inner > .q-field__bottom > .q-field__messages > div`,
).should('exist')
})
})
Expand Down
6 changes: 3 additions & 3 deletions cypress/e2e/attribute_validations/enum8.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,17 @@ describe('Testing ENUM8 type validation', () => {
() => {
cy.fixture('data').then((data) => {
cy.get(
`:nth-child(${data.enum8inputpath}) > [style="min-width: 180px;"] > .q-field > .q-field__inner > .q-field__control > .q-field__control-container > input`
`:nth-child(${data.enum8inputpath}) > [style="min-width: 180px;"] > .q-field > .q-field__inner > .q-field__control > .q-field__control-container > input`,
)
.clear({ force: true })
.type('test', { force: true })
})
}
},
)
it('check if validation works properly', () => {
cy.fixture('data').then((data) => {
cy.get(
`:nth-child(${data.enum8inputpath}) > [style="min-width: 180px;"] > .q-field > .q-field__inner > .q-field__bottom > .q-field__messages > div`
`:nth-child(${data.enum8inputpath}) > [style="min-width: 180px;"] > .q-field > .q-field__inner > .q-field__bottom > .q-field__messages > div`,
).should('exist')
})
})
Expand Down
8 changes: 4 additions & 4 deletions cypress/e2e/attribute_validations/int16.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,22 +22,22 @@ describe('Testing INT16U type validation', () => {
() => {
cy.fixture('data').then((data) => {
cy.get(
`:nth-child(${data.int16inputpath}) > [style="min-width: 180px;"] > .q-field > .q-field__inner > .q-field__control > .q-field__control-container > input`
`:nth-child(${data.int16inputpath}) > [style="min-width: 180px;"] > .q-field > .q-field__inner > .q-field__control > .q-field__control-container > input`,
)
.clear({ force: true })
.type('test', { force: true })
})
}
},
)
it(
'check if validation works properly',
{ retries: { runMode: 2, openMode: 2 } },
() => {
cy.fixture('data').then((data) => {
cy.get(
`:nth-child(${data.int16inputpath}) > [style="min-width: 180px;"] > .q-field > .q-field__inner > .q-field__bottom > .q-field__messages > div`
`:nth-child(${data.int16inputpath}) > [style="min-width: 180px;"] > .q-field > .q-field__inner > .q-field__bottom > .q-field__messages > div`,
).should('exist')
})
}
},
)
})
6 changes: 3 additions & 3 deletions cypress/e2e/attribute_validations/int8.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@ describe('Testing INT8U type validation', () => {
{ retries: { runMode: 2, openMode: 2 } },
() => {
cy.get(
':nth-child(1) > [style="min-width: 180px;"] > .q-field > .q-field__inner > .q-field__control > .q-field__control-container > input'
':nth-child(1) > [style="min-width: 180px;"] > .q-field > .q-field__inner > .q-field__control > .q-field__control-container > input',
)
.clear({ force: true })
.type('test', { force: true })
}
},
)
it('check if validation works properly', () => {
cy.get(
':nth-child(1) > [style="min-width: 180px;"] > .q-field > .q-field__inner > .q-field__bottom > .q-field__messages > div'
':nth-child(1) > [style="min-width: 180px;"] > .q-field > .q-field__inner > .q-field__bottom > .q-field__messages > div',
).should('exist')
})
})
10 changes: 5 additions & 5 deletions cypress/e2e/attributes/check-required-attributes.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,17 @@ describe('Testing disabling enabled attributes', () => {
{ retries: { runMode: 2, openMode: 2 } },
() => {
cy.get(
'.attribute_table_body:first > :nth-child(2) > .q-mt-xs > .q-toggle__inner '
'.attribute_table_body:first > :nth-child(2) > .q-mt-xs > .q-toggle__inner ',
).click()
cy.get(
'.attribute_table_body:first > :nth-child(2) > .q-mt-xs > .q-toggle__inner'
'.attribute_table_body:first > :nth-child(2) > .q-mt-xs > .q-toggle__inner',
).should('be.visible')
cy.get(
'.attribute_table_body:first > :nth-child(2) > .q-mt-xs > .q-toggle__inner'
'.attribute_table_body:first > :nth-child(2) > .q-mt-xs > .q-toggle__inner',
).click()
cy.contains(
'.attribute_table_body:first > :nth-child(2) > .q-mt-xs > .q-toggle__inner'
'.attribute_table_body:first > :nth-child(2) > .q-mt-xs > .q-toggle__inner',
).should('not.exist')
}
},
)
})
4 changes: 2 additions & 2 deletions cypress/e2e/attributes/check-search.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@ describe('Testing attribute search', () => {
.should('contain', data.attribute1)
.and('contain', data.attribute2)
})
}
},
)
it('Search for application', () => {
cy.fixture('data').then((data) => {
cy.get(
'.col-auto > .q-field > .q-field__inner > .q-field__control > .q-field__control-container > input'
'.col-auto > .q-field > .q-field__inner > .q-field__control > .q-field__control-container > input',
)
.clear({ force: true })
.type(data.searchString1, { force: true })
Expand Down
2 changes: 1 addition & 1 deletion cypress/e2e/clusters/cluster-filter.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,6 @@ describe('Testing cluster filters', () => {
cy.fixture('data').then((data) => {
cy.get('tbody').children().contains(data.cluster2).should('not.exist')
})
}
},
)
})
4 changes: 2 additions & 2 deletions cypress/e2e/clusters/cluster-search.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,12 @@ describe('Testing cluster search', () => {
cy.dataCy('cluster-general').children().children().eq(0).click()
cy.dataCy('cluster-general').should(
'have.class',
'q-expansion-item--collapsed'
'q-expansion-item--collapsed',
)
cy.dataCy('cluster-general').children().children().eq(0).click()
cy.dataCy('cluster-general').should(
'have.class',
'q-expansion-item--expanded'
'q-expansion-item--expanded',
)
cy.dataCy('cluster-btn-closeall').click()
cy.get('[data-test=Cluster').each(($row) => {
Expand Down
2 changes: 1 addition & 1 deletion cypress/e2e/clusters/dimmable-light.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,5 @@ describe(
.type(data.cluster4)
})
})
}
},
)
2 changes: 1 addition & 1 deletion cypress/e2e/endpoints/edit-endpoint.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,6 @@ describe('Testing Editing endpoints', () => {
cy.fixture('data').then((data) => {
cy.get('aside').children().should('contain', data.endpoint2)
})
}
},
)
})
4 changes: 2 additions & 2 deletions cypress/e2e/theme/theme.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ describe('Check theme functionality', () => {
cy.wait(500)
cy.get('#darkTheme').find('input').uncheck({ force: true })
cy.get('body').should('have.class', 'body--light')
}
},
)

it(
Expand All @@ -33,7 +33,7 @@ describe('Check theme functionality', () => {
cy.wait(500)
cy.get('#darkTheme').find('input').check({ force: true })
cy.get('body').should('have.class', 'body--dark')
}
},
)

it('RendererApi: set light theme', () => {
Expand Down
6 changes: 3 additions & 3 deletions cypress/e2e/ui/notification-panel.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ describe('Check notification panel functionality', () => {
cy.get('#NotificationPanel')
.parent()
.should('not.have.class', ' q-layout--prevent-focus')
}
},
)
it('Check active status on navbar', () => {
cy.get('#Notifications').should('have.class', 'navmenu-item--active')
Expand All @@ -36,7 +36,7 @@ describe('Check notification panel functionality', () => {
cy.get('#NotificationPanel')
.parent()
.should('have.class', 'q-layout--prevent-focus')
}
},
)
it(
'Open notification panel and open preview panel',
Expand All @@ -51,6 +51,6 @@ describe('Check notification panel functionality', () => {
cy.get('#NotificationPanel')
.parent()
.should('have.class', 'q-layout--prevent-focus')
}
},
)
})
2 changes: 1 addition & 1 deletion cypress/support/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Cypress.Commands.add('gotoAttributePage', (endpoint, cluster, nth = 0) => {
cy.get('div').contains(cluster).click({ force: true })
cy.wait(1000)
cy.get(
`#${cluster} > .q-expansion-item__container > .q-expansion-item__content > .q-card > .q-card__section > .row > .q-table__container > .q-table__middle > .q-table > tbody > :nth-child(1) > :nth-child(7) > .q-btn `
`#${cluster} > .q-expansion-item__container > .q-expansion-item__content > .q-card > .q-card__section > .row > .q-table__container > .q-table__middle > .q-table > tbody > :nth-child(1) > :nth-child(7) > .q-btn `,
)
.eq(nth)
.click({ force: true })
Expand Down
16 changes: 13 additions & 3 deletions docs/ZAP-on-Windows.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,26 @@ In desktop search bar, input `Windows Powershell` and run as administrator. Run
Install from https://chocolatey.org/install

Check if installed properly:

```
choco -v
```

Install pkgconfiglite package:

```
choco install pkgconfiglite
```

### 3. Install Node if you have not:

```
choco install nodejs-lts
```
*the version has to be 18 to pass version check test, after install, check with `node -v`

*if you install Node already, and fail some tests similar to `cannot find Node`, reinstall Node with chocolatey again
\*the version has to be 18 to pass version check test, after install, check with `node -v`

\*if you install Node already, and fail some tests similar to `cannot find Node`, reinstall Node with chocolatey again

### 4. Follow the instruction page for other installation details

Expand All @@ -36,13 +41,15 @@ https://github.com/project-chip/zap/blob/master/docs/development-instructions.md
### 1. sqlite3

When running ZAP (eg. `npm run zap`), if you see an error about `sqlite3.node` in a pop up window, run:

```
npm rebuild sqlite3
```

### 2. electron-builder:

When doing npm install, in post-install, if there is an error on the following command, related to `electron-builder install-app-deps`, `npx electron-rebuild canvas failed` or `node-pre-gyp`, it is because the current `canvas` version is not compatible with Windows, and the installation error will not cause a failure in running ZAP. node-canvas is working on the solution now and the issue will be solved in near future.

```
"postinstall": "electron-builder install-app-deps && husky install && npm rebuild canvas --update-binary && npm run version-stamp"
```
Expand All @@ -52,20 +59,23 @@ When doing npm install, in post-install, if there is an error on the following c
### 1. Exceed Timeout

If 'npm run test' fails due to `Exceeded timeout of 1500 ms for a test. Use jest.setTimeout(newTimeout) to increase the timeout value, if this is a long-running test.`, set the following environment variables to increase timeouts for all tests.

```
$env:ZAP_TEST_TIMEOUT = 50000000; $env:ZAP_TEST_TIMEOUT_SHORT = 50000000; $env:ZAP_TEST_TIMEOUT_MEDIUM = 50000000; $env:ZAP_TEST_TIMEOUT_LONG = 50000000
```

### 2. Test Suite failed to run (Canvas not found)

If 'npm run test' fails due to `Test suite failed to run. Cannot find module '../build/Release/canvas.node'` or `\zap\node_modules\canvas\build\Release\canvas.node is not a valid Win32 application.`, rebuild canvas:

```
npm rebuild canvas --update-binary
```

### 3. get index.html or other server issue

If `npm run test` fails due to `get index.html request failed with status code 404` in unit tests or having server connection issues in e2e-ci tests, run:

```
npm run build
```
Expand All @@ -74,4 +84,4 @@ npm run build

Check if node version is v18, and try to install it with Chocolatey

Also, you can check the faq doc for other known issues: https://github.com/project-chip/zap/blob/master/docs/faq.md
Also, you can check the faq doc for other known issues: https://github.com/project-chip/zap/blob/master/docs/faq.md
17 changes: 11 additions & 6 deletions docs/access.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ these features to the required and supported access control SDK features. ZAP ge

ZAP access control defines three base terms:

1. **operation** : it's something that can be done. Example: read, write, invoke.
2. **role**: it's a privilege of an actor. Such as "View privilege", "Administrative rol", etc.
3. **modifiers**: special access control conditions, such as _fabric sensitive_ data or _fabric scoped_ data.
1. **operation** : it's something that can be done. Example: read, write, invoke.
2. **role**: it's a privilege of an actor. Such as "View privilege", "Administrative rol", etc.
3. **modifiers**: special access control conditions, such as _fabric sensitive_ data or _fabric scoped_ data.

The base terms are defined in the metadata XML under a top tag `<accessControl>`. Example of access control base term definitions:

Expand All @@ -36,12 +36,14 @@ Each individual access condition can be defined with an access triplet in the XM
Access triplet is a combination of an _operation_, _role_ and _modifier_. They are optional, so you can only have one of these. A missing part of triplet generally means permissivenes, but that's implementation specific for the given SDK. An entity, that defines it's access can have one or more access triplets.

Example:

```
<attribute side="server" code="0x0000" define="AT1" type="INT64U" writable="false" optional="true">
<description>at1</description>
<access op="write" role="manage" modifier="fabric-scoped"/>
</attribute>
```

This is a definition of an attribute that has an access triplet, declaring it allows _write_ operation by a _manage_ role, with _fabric-scoped_ modifier applied.

## Default permissions
Expand All @@ -51,6 +53,7 @@ ZCL entities can define their own individual permissions. However, there is also
Default permissions are declared via a `<defaultAccess>` tag at the toplevel of the XML.

Example:

```
<defaultAccess type="command">
<access op="invoke"/>
Expand All @@ -70,10 +73,12 @@ Example:

The basic template helper to use is the `{{#access}} ... {{/access}}` iterator. This iterator iterates over all the given access triplets.
It supports 2 options:
* `entity="attribute/command/event"` - if the entity can't be determined from context, this sets the entity type.
* `includeDefault="true/false"` - determines if default values are included or not.

- `entity="attribute/command/event"` - if the entity can't be determined from context, this sets the entity type.
- `includeDefault="true/false"` - determines if default values are included or not.

Example:

```
{{#zcl_clusters}}
Cluster: {{name}} [{{code}}]
Expand All @@ -97,4 +102,4 @@ Cluster: {{name}} [{{code}}]
{{/zcl_events}}
{{/zcl_clusters}}
```
```
Loading

0 comments on commit 1fe79d8

Please sign in to comment.