Skip to content

Commit

Permalink
Merge pull request #10 from robsonos/dev
Browse files Browse the repository at this point in the history
Merge dev into main
  • Loading branch information
robsonos authored Dec 25, 2024
2 parents 915648a + 0a33b8f commit fd1be12
Show file tree
Hide file tree
Showing 86 changed files with 8,370 additions and 4,763 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ on:
branches:
- main

env:
NX_CLOUD_ACCESS_TOKEN: ${{ secrets.NX_CLOUD_ACCESS_TOKEN }}

jobs:
cd:
runs-on: ubuntu-latest
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ on:
branches:
- dev

env:
NX_CLOUD_ACCESS_TOKEN: ${{ secrets.NX_CLOUD_ACCESS_TOKEN }}

jobs:
ci:
runs-on: ubuntu-latest
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ on:
release:
types: [created]

env:
NX_CLOUD_ACCESS_TOKEN: ${{ secrets.NX_CLOUD_ACCESS_TOKEN }}

jobs:
build:
runs-on: ${{ matrix.os }}
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,4 @@ Thumbs.db
*.env*

# act
.actrc.*
.act*
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
</p>
<p align="center">
<img src="https://img.shields.io/maintenance/yes/2024?style=flat-square"/>
<a href="https://github.com/robsonos/spie/actions/workflows/ci.yaml">
<a href="https://github.com/robsonos/spie/actions/workflows/ci.yml">
<img
alt="GitHub Workflow Status (with event)"
src="https://img.shields.io/github/actions/workflow/status/robsonos/spie/ci.yml"/>
Expand Down Expand Up @@ -35,10 +35,10 @@ The repository provides:
| Package | version |
| -------- | ------- |
| nodejs | 22.x.x |
| angular | 18.2.x |
| angular | 19.x.x |
| ionic | 8.x.x |
| electron | 31.x.x |
| nx | 19.8.10 |
| electron | 33.3.x |
| nx | 20.2.2 |

## Index

Expand Down Expand Up @@ -199,7 +199,7 @@ Output files are located in `dist\executables`

### Known issues

- Serial data may be delivered in more than one .on('data') event. This means data received by the serialport library might arrive in multiple packets. For details, see [node-serialport/issues/659](https://github.com/serialport/node-serialport/issues/659) for more information. This is not a problem in most cases, but things may start looking strange if you are trying to monitor data at a fast rate. A good way to demonstrate the issues is to send data every `5ms`, `115200` baud rate and with `show timestamps`. You will notice that every so often there is a "broken" message. If you are developing your own application, I would recommend having a specific line terminator and use one of the [parsers](https://serialport.io/docs/api-parsers-overview) available.
- Serial data may be delivered in more than one `.on('data')` event. This means data received by the serialport library might arrive in multiple packets. For details, see [node-serialport/issues/659](https://github.com/serialport/node-serialport/issues/659) for more information. This is not a problem in most cases, but things may start looking strange if you are trying to monitor data at a fast rate. A good way to demonstrate the issues is to send data every `5ms`, `115200` baud rate and with `show timestamps`. You will notice that every so often there is a "broken" message. If you are developing your own application, I would recommend having a specific line terminator and use one of the [parsers](https://serialport.io/docs/api-parsers-overview) available.

### Limitations

Expand Down
160 changes: 160 additions & 0 deletions apps/spie-ui-e2e/src/e2e/connect.cy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,160 @@
import {
mockElectronAPI,
mockSerialPortList,
} from '../fixtures/mocks/electron-api.mock';

describe('Connect routine', () => {
beforeEach(() => {
cy.visit('/');

cy.on('window:before:load', (win) => {
win.electron = mockElectronAPI(win);
});

cy.window().should((win) => {
expect(win.onSerialPortEventTrigger).to.be.a('function');
});
});

it('should show available serial ports in the dropdown', () => {
cy.get(
'app-connection-component [placeholder="Select Serial Port"]'
).click();
cy.get('ion-alert .alert-radio-button').should(
'have.length',
mockSerialPortList.length
);

mockSerialPortList.forEach((item, index) => {
cy.get('ion-alert .alert-radio-button')
.eq(index)
.should('contain.text', item.path);
});
});

it('should allow selecting a serial port', () => {
const expectedPath = mockSerialPortList[0].path;

cy.get(
'app-connection-component [placeholder="Select Serial Port"]'
).selectDropdownOption(expectedPath);

cy.get('app-connection-component [placeholder="Select Serial Port"]')
.shadow()
.find('.select-text')
.should('contain', expectedPath);
});

it('should allow selecting a baud rate', () => {
const expectedBaudRate = 115200;

cy.get(
'app-connection-component [placeholder="Select Baud Rate"]'
).selectDropdownOption(expectedBaudRate);

cy.get('app-connection-component [placeholder="Select Baud Rate"]')
.shadow()
.find('.select-text')
.should('contain', expectedBaudRate);
});

it('should disable the Connect button when no serial port is selected', () => {
cy.get('app-connection-component ion-button')
.contains('Connect')
.should('have.class', 'button-disabled');
});

it('should enable the Connect button after selecting a port', () => {
const expectedPath = mockSerialPortList[0].path;

cy.get(
'app-connection-component [placeholder="Select Serial Port"]'
).selectDropdownOption(expectedPath);
cy.get('app-connection-component ion-button')
.contains('Connect')
.should('not.have.class', 'button-disabled');
});

it('should correctly call the IPC open and close methods', () => {
cy.connect(mockSerialPortList[0].path, 9600);

cy.get('app-connection-component ion-button')
.contains('Disconnect')
.should('be.visible');

cy.disconnect();

cy.window().then((win) => {
cy.wrap(win.electron.serialPort.close).should('have.been.calledOnce');
});

cy.get('app-connection-component ion-button')
.contains('Connect')
.should('be.visible');
});

it('should reconnect when baud rate changes', () => {
cy.connect(mockSerialPortList[0].path, 9600);

cy.get(
'app-connection-component [placeholder="Select Baud Rate"]'
).selectDropdownOption(115200);

cy.window().then((win) => {
cy.wrap(win.electron.serialPort.open).should(
'have.been.calledWith',
Cypress.sinon.match.has('baudRate', 115200)
);
});

cy.get('app-connection-component ion-button')
.contains('Disconnect')
.should('be.visible');
});

it('should open and close the advanced modal', () => {
cy.get('app-connection-component ion-button [name="settings-outline"]')
.parent()
.click();
cy.get('ion-modal ion-toolbar ion-title').should(
'contain',
'Advanced Connection Settings'
);
cy.get('ion-modal ion-toolbar ion-button').click();
cy.get('ion-modal').should('not.be.visible');
});

it('should reconnect after changing advanced settings', () => {
cy.connect(mockSerialPortList[0].path, 9600);

cy.get('app-connection-component ion-button [name="settings-outline"]')
.parent()
.click();

cy.getAdvancedModalCheckboxElement(
'connection-advanced-modal',
'HUPCL'
).click();

cy.getAdvancedModalSelectElement(
'connection-advanced-modal',
'Data Bits'
).selectDropdownOption('5');

cy.window().then((win) => {
setTimeout(() => {
cy.wrap(win.electron.serialPort.close).should('have.been.calledTwice');
cy.wrap(win.electron.serialPort.open).should(
'have.been.calledWith',
Cypress.sinon.match.has('hupcl', false),
Cypress.sinon.match.has('dataBits', 5)
);
cy.wrap(win.electron.serialPort.close).should('have.been.calledOnce');

cy.get('app-connection-component ion-button')
.contains('Disconnect')
.should('be.visible');
}, 500);
});
});
});
Loading

0 comments on commit fd1be12

Please sign in to comment.