Skip to content

Commit

Permalink
test(spie-ui-e2e): add uto updater test and improve other tests
Browse files Browse the repository at this point in the history
  • Loading branch information
robsonos committed Dec 9, 2024
1 parent b16954b commit c9a17f8
Show file tree
Hide file tree
Showing 7 changed files with 364 additions and 40 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,20 @@ import {
mockSerialPortList,
} from '../fixtures/mocks/electron-api.mock';

describe('Serial Port component', () => {
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 display available serial ports in the dropdown', () => {
it('should show available serial ports in the dropdown', () => {
cy.get(
'app-connection-component [placeholder="Select Serial Port"]'
).click();
Expand Down Expand Up @@ -112,7 +116,10 @@ describe('Serial Port component', () => {
cy.get('app-connection-component ion-button [name="settings-outline"]')
.parent()
.click();
cy.get('ion-modal').should('be.visible');
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');
});
Expand Down
11 changes: 9 additions & 2 deletions apps/spie-ui-e2e/src/e2e/send.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,18 @@ import {
mockSerialPortList,
} from '../fixtures/mocks/electron-api.mock';

describe('Send component', () => {
describe('Send 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');
});

cy.connect(mockSerialPortList[0].path, 9600);
});

Expand Down Expand Up @@ -68,7 +72,10 @@ describe('Send component', () => {
cy.get('app-send-component ion-button [name="settings-outline"]')
.parent()
.click();
cy.get('ion-modal').should('be.visible');
cy.get('ion-modal ion-toolbar ion-title').should(
'contain',
'Advanced Send Settings'
);
cy.get('ion-modal ion-toolbar ion-button').click();
cy.get('ion-modal').should('not.be.visible');
});
Expand Down
29 changes: 19 additions & 10 deletions apps/spie-ui-e2e/src/e2e/terminal.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {
mockSerialPortList,
} from '../fixtures/mocks/electron-api.mock';

describe('Terminal component', () => {
describe('Terminal routine', () => {
const mockData =
'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.\n';

Expand All @@ -14,12 +14,16 @@ describe('Terminal component', () => {
win.electron = mockElectronAPI(win);
});

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

cy.connect(mockSerialPortList[0].path, 9600);
});

it('should display data on the terminal', () => {
cy.window().then((win) => {
win.onEventTrigger({
win.onSerialPortEventTrigger({
type: 'data',
data: mockData,
});
Expand All @@ -33,7 +37,7 @@ describe('Terminal component', () => {

it('should clear the terminal', () => {
cy.window().then((win) => {
win.onEventTrigger({
win.onSerialPortEventTrigger({
type: 'data',
data: mockData,
});
Expand All @@ -49,7 +53,7 @@ describe('Terminal component', () => {
it('should auto scroll when data is emitted', () => {
cy.window().then((win) => {
for (let index = 0; index < 10; index++) {
win.onEventTrigger({
win.onSerialPortEventTrigger({
type: 'data',
data: mockData,
});
Expand All @@ -67,14 +71,14 @@ describe('Terminal component', () => {

it('should clear the terminal with clear event', () => {
cy.window().then((win) => {
win.onEventTrigger({
win.onSerialPortEventTrigger({
type: 'data',
data: mockData,
});
});

cy.window().then((win) => {
win.onEventTrigger({
win.onSerialPortEventTrigger({
type: 'clear',
});
});
Expand All @@ -90,15 +94,18 @@ describe('Terminal component', () => {
cy.get('app-terminal-component ion-button [name="settings-outline"]')
.parent()
.click();
cy.get('ion-modal').should('be.visible');
cy.get('ion-modal ion-toolbar ion-title').should(
'contain',
'Advanced Terminal Settings'
);
cy.get('ion-modal ion-toolbar ion-button').click();
cy.get('ion-modal').should('not.be.visible');
});

it('should clear the terminal after changing encoding', () => {
cy.window().then((win) => {
for (let index = 0; index < 10; index++) {
win.onEventTrigger({
win.onSerialPortEventTrigger({
type: 'data',
data: mockData,
});
Expand All @@ -122,7 +129,7 @@ describe('Terminal component', () => {
it('should clear the terminal after changing show timestamps', () => {
cy.window().then((win) => {
for (let index = 0; index < 10; index++) {
win.onEventTrigger({
win.onSerialPortEventTrigger({
type: 'data',
data: mockData,
});
Expand Down Expand Up @@ -161,7 +168,7 @@ describe('Terminal component', () => {

cy.window().then((win) => {
for (let index = 0; index < 10; index++) {
win.onEventTrigger({
win.onSerialPortEventTrigger({
type: 'data',
data: mockData,
});
Expand All @@ -173,4 +180,6 @@ describe('Terminal component', () => {
expect(currentScrollTop).to.equal(initialScrollTop);
});
});

// TODO: PAUSE/CONTINUE
});
Loading

0 comments on commit c9a17f8

Please sign in to comment.