Skip to content

Commit acb624e

Browse files
committed
Merge branch 'stable'
2 parents 8edc169 + 2796385 commit acb624e

File tree

3 files changed

+28
-47
lines changed

3 files changed

+28
-47
lines changed

eform-client/cypress/e2e/d/device-users.add.spec.cy.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,7 @@ describe('Device users page - Should not add new device user', function () {
6767
cy.get('#newDeviceUserBtn', { timeout: 40000 }).should('be.visible').click();
6868
cy.wait(500);
6969
cy.get('#firstName').should('be.visible').type(name);
70-
cy.get('#lastName').should('be.visible').type('');
71-
70+
cy.get('#lastName').should('be.visible').clear();
7271
// Verify save button is disabled
7372
cy.get('#saveCreateBtn').should('be.disabled');
7473

@@ -81,7 +80,7 @@ describe('Device users page - Should not add new device user', function () {
8180

8281
cy.get('#newDeviceUserBtn', { timeout: 40000 }).should('be.visible').click();
8382
cy.wait(500);
84-
cy.get('#firstName').should('be.visible').type('');
83+
cy.get('#firstName').should('be.visible').clear();
8584
cy.get('#lastName').should('be.visible').type(lastName);
8685

8786
// Verify save button is disabled
@@ -94,8 +93,8 @@ describe('Device users page - Should not add new device user', function () {
9493
it('should NOT add device user without first and last names', () => {
9594
cy.get('#newDeviceUserBtn', { timeout: 40000 }).should('be.visible').click();
9695
cy.wait(500);
97-
cy.get('#firstName').should('be.visible').type('');
98-
cy.get('#lastName').should('be.visible').type('');
96+
cy.get('#firstName').should('be.visible').clear();
97+
cy.get('#lastName').should('be.visible').clear();
9998

10099
// Verify save button is disabled
101100
cy.get('#saveCreateBtn').should('be.disabled');

eform-client/cypress/e2e/d/device-users.delete.spec.cy.ts

Lines changed: 9 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -4,42 +4,37 @@ import { Guid } from 'guid-typescript';
44
import { expect } from 'chai';
55

66
describe('Device users page - Delete device user', function () {
7-
before(() => {
7+
beforeEach(() => {
88
cy.visit('http://localhost:4200');
99
loginPage.login();
1010
cy.intercept('POST', '**/api/device-users/index').as('loadDeviceUsers');
1111
deviceUsersPage.Navbar.goToDeviceUsersPage();
1212
cy.wait('@loadDeviceUsers', { timeout: 30000 });
13+
});
14+
15+
it('should not delete device user if cancel was clicked', () => {
1316

1417
// Create a test user to delete
1518
const firstName = Guid.create().toString();
1619
const lastName = Guid.create().toString();
1720
cy.get('#newDeviceUserBtn', { timeout: 10000 }).should('be.visible').click();
1821
cy.get('#firstName').should('be.visible').type(firstName);
1922
cy.get('#lastName').should('be.visible').type(lastName);
20-
21-
cy.intercept('POST', '**/api/device-users/create').as('createUser');
23+
24+
cy.intercept('PUT', '**/api/device-users/create').as('createUser');
2225
cy.get('#saveCreateBtn').should('be.visible').click();
2326
cy.wait('@createUser', { timeout: 30000 });
2427
cy.get('#newDeviceUserBtn').should('be.visible');
25-
});
26-
27-
it('should not delete device user if cancel was clicked', () => {
2828
// Ensure table is visible before counting rows
2929
cy.get('tbody > tr', { timeout: 10000 }).should('have.length.gt', 0);
30-
30+
3131
deviceUsersPage.rowNum().then((rowNumBeforeDelete) => {
3232
cy.get('#deviceUserId').should('be.visible');
3333

3434
// Click delete button on last row
3535
cy.get('#deleteDeviceUserBtn').last().should('be.visible').click();
3636
cy.get('#cancelDeleteBtn').should('be.visible').click();
3737

38-
// Navigate back to device users page
39-
cy.intercept('POST', '**/api/device-users/index').as('reloadList');
40-
deviceUsersPage.Navbar.goToDeviceUsersPage();
41-
cy.wait('@reloadList', { timeout: 30000 });
42-
4338
// Ensure table is visible before counting rows
4439
cy.get('tbody > tr', { timeout: 10000 }).should('have.length.gt', 0);
4540

@@ -51,38 +46,21 @@ describe('Device users page - Delete device user', function () {
5146
});
5247

5348
it('should delete device user successfully', () => {
54-
cy.intercept('POST', '**/api/device-users/index').as('loadDeviceUsers1');
55-
deviceUsersPage.Navbar.goToDeviceUsersPage();
56-
cy.wait('@loadDeviceUsers1', { timeout: 30000 });
57-
58-
// Ensure table is visible before counting rows
5949
cy.get('tbody > tr', { timeout: 10000 }).should('have.length.gt', 0);
6050

6151
deviceUsersPage.rowNum().then((rowNumBeforeDelete) => {
6252
cy.get('#deviceUserId').should('be.visible');
6353

6454
// Click delete button on last row
65-
cy.intercept('POST', '**/api/device-users/delete').as('deleteUser');
55+
cy.intercept('DELETE', '**/api/device-users/delete/*').as('deleteUser');
6656
cy.intercept('POST', '**/api/device-users/index').as('reloadAfterDelete');
6757
cy.get('#deleteDeviceUserBtn').last().should('be.visible').click();
6858
cy.get('#saveDeleteBtn').should('be.visible').click();
6959
cy.wait('@deleteUser', { timeout: 30000 });
7060
cy.wait('@reloadAfterDelete', { timeout: 30000 });
7161

72-
// Navigate back to device users page
73-
cy.intercept('POST', '**/api/device-users/index').as('loadDeviceUsers2');
74-
deviceUsersPage.Navbar.goToDeviceUsersPage();
75-
cy.wait('@loadDeviceUsers2', { timeout: 30000 });
76-
77-
// Ensure table is visible before counting rows
78-
cy.get('tbody > tr', { timeout: 10000 }).should('have.length.gt', 0);
62+
cy.get('tbody > tr', { timeout: 10000 }).should('have.length', 0);
7963

80-
// Verify count decreased
81-
deviceUsersPage.rowNum().then((rowNumAfterDelete) => {
82-
expect(rowNumBeforeDelete, 'User deleted incorrectly').to.equal(
83-
rowNumAfterDelete + 1
84-
);
85-
});
8664
});
8765
});
8866
});

eform-client/cypress/e2e/d/device-users.edit.spec.cy.ts

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,29 +4,29 @@ import { Guid } from 'guid-typescript';
44
import { expect } from 'chai';
55

66
describe('Device users page - Edit device user', function () {
7-
before(() => {
7+
beforeEach(() => {
88
cy.visit('http://localhost:4200');
99
loginPage.login();
1010
cy.intercept('POST', '**/api/device-users/index').as('loadDeviceUsers');
1111
deviceUsersPage.Navbar.goToDeviceUsersPage();
1212
cy.wait('@loadDeviceUsers', { timeout: 30000 });
13+
});
14+
15+
it('should edit device user\'s first name', () => {
1316

1417
// Create a test user
1518
const firstName = Guid.create().toString();
1619
const lastName = Guid.create().toString();
1720
cy.get('#newDeviceUserBtn', { timeout: 10000 }).should('be.visible').click();
1821
cy.get('#firstName').should('be.visible').type(firstName);
1922
cy.get('#lastName').should('be.visible').type(lastName);
20-
21-
cy.intercept('POST', '**/api/device-users/create').as('createUser');
23+
24+
cy.intercept('PUT', '**/api/device-users/create').as('createUser');
2225
cy.intercept('POST', '**/api/device-users/index').as('reloadDeviceUsers');
2326
cy.get('#saveCreateBtn').should('be.visible').click();
2427
cy.wait('@createUser', { timeout: 30000 });
2528
cy.wait('@reloadDeviceUsers', { timeout: 30000 });
2629
cy.get('#newDeviceUserBtn', { timeout: 10000 }).should('be.visible');
27-
});
28-
29-
it('should edit device user\'s first name', () => {
3030
const newName = Guid.create().toString();
3131

3232
cy.get('#deviceUserFirstName').should('be.visible');
@@ -37,11 +37,12 @@ describe('Device users page - Edit device user', function () {
3737

3838
// Click edit button on last row
3939
cy.get('#editDeviceUserBtn').last().should('be.visible').click();
40+
cy.wait(500);
4041
cy.get('#firstName').should('be.visible');
4142

4243
// Edit first name
4344
cy.get('#firstName').clear().type(newName);
44-
45+
4546
cy.intercept('POST', '**/api/device-users/update').as('updateUser');
4647
cy.intercept('POST', '**/api/device-users/index').as('reloadDeviceUsers');
4748
cy.get('#saveEditBtn').should('be.visible').click();
@@ -66,11 +67,12 @@ describe('Device users page - Edit device user', function () {
6667

6768
// Click edit button on last row
6869
cy.get('#editDeviceUserBtn').last().should('be.visible').click();
70+
cy.wait(500);
6971
cy.get('#firstName').should('be.visible');
7072

7173
// Edit last name
72-
cy.get('#lastName').clear().type(newSurname);
73-
74+
cy.get('#lastName').should('be.visible').clear().type(newSurname);
75+
7476
cy.intercept('POST', '**/api/device-users/update').as('updateUser');
7577
cy.intercept('POST', '**/api/device-users/index').as('reloadDeviceUsers');
7678
cy.get('#saveEditBtn').should('be.visible').click();
@@ -92,12 +94,13 @@ describe('Device users page - Edit device user', function () {
9294

9395
// Click edit button on last row
9496
cy.get('#editDeviceUserBtn').last().should('be.visible').click();
97+
cy.wait(500);
9598
cy.get('#firstName').should('be.visible');
9699

97100
// Edit both fields
98101
cy.get('#firstName').clear().type(newName);
99102
cy.get('#lastName').clear().type(newSurname);
100-
103+
101104
cy.intercept('POST', '**/api/device-users/update').as('updateUser');
102105
cy.intercept('POST', '**/api/device-users/index').as('reloadDeviceUsers');
103106
cy.get('#saveEditBtn').should('be.visible').click();
@@ -116,14 +119,15 @@ describe('Device users page - Edit device user', function () {
116119

117120
// Ensure table is visible before counting rows
118121
cy.get('tbody > tr', { timeout: 10000 }).should('have.length.gt', 0);
119-
122+
120123
// Get count and data before edit
121124
deviceUsersPage.rowNum().then((rowNumBeforeEdit) => {
122125
cy.get('#deviceUserFirstName').last().invoke('text').then((oldFirstName) => {
123126
cy.get('#deviceUserLastName').last().invoke('text').then((oldLastName) => {
124127

125128
// Click edit button on last row
126129
cy.get('#editDeviceUserBtn').last().should('be.visible').click();
130+
cy.wait(500);
127131
cy.get('#firstName').should('be.visible');
128132

129133
// Try to edit both fields

0 commit comments

Comments
 (0)