Skip to content

Commit f7d42b7

Browse files
Merge pull request #1013 from fossa-app/feat-employee-manager
feat: Add employee manager field in views, forms and catalogs
2 parents fe408e9 + 31375eb commit f7d42b7

17 files changed

Lines changed: 315 additions & 57 deletions

cypress/e2e/Branch/BranchCatalog.cy.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import {
2727
interceptFetchBranchesByIdsRequest,
2828
interceptFetchCompanySettingsRequest,
2929
interceptFetchDepartmentsByIdsRequest,
30+
interceptFetchEmployeesByIdsRequest,
3031
} from 'support/interceptors';
3132

3233
const branchAdminRoutes = [ROUTES.newBranch.path, `${ROUTES.branches.path}/edit/222222222222`];
@@ -195,6 +196,7 @@ describe('Branch Catalog Tests', () => {
195196
);
196197
interceptFetchBranchesByIdsRequest();
197198
interceptFetchDepartmentsByIdsRequest();
199+
interceptFetchEmployeesByIdsRequest();
198200

199201
getLinearLoader(Module.branchManagement, SubModule.branchCatalog, 'table').should('not.exist');
200202
cy.wait('@fetchMultipleBranchesRequest');

cypress/e2e/Branch/BranchManagement.cy.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ import {
3838
interceptFetchDepartmentsByIdsRequest,
3939
interceptFetchDepartmentsRequest,
4040
interceptFetchEmployeeByIdRequest,
41+
interceptFetchEmployeesByIdsRequest,
4142
interceptFetchEmployeesRequest,
4243
interceptFetchProfileRequest,
4344
interceptFetchSystemLicenseRequest,
@@ -459,6 +460,7 @@ describe('Branch Management Tests', () => {
459460

460461
it('should reset the form when navigating to an employee page and back to the branch creation page', () => {
461462
interceptFetchEmployeeByIdRequest('333333333335');
463+
interceptFetchEmployeeByIdRequest('333333333333');
462464
interceptFetchBranchByIdRequest('222222222222');
463465
interceptFetchDepartmentByIdRequest('444444444444');
464466
interceptFetchBranchesByIdsRequest();
@@ -472,6 +474,7 @@ describe('Branch Management Tests', () => {
472474
{ pageNumber: 1, pageSize: 10, search: '' },
473475
{ alias: 'fetchMultipleBranchesRequest', fixture: 'branch/branches-multiple' }
474476
);
477+
interceptFetchEmployeesByIdsRequest();
475478
cy.visit(ROUTES.employees.path);
476479

477480
cy.wait('@fetchMultipleEmployeesRequest');

cypress/e2e/Department/DepartmentManagement.cy.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ const testDepartmentInputFields = () => {
4848
verifyInputFields(Module.departmentManagement, SubModule.departmentDetails, {
4949
'form-field-name': 'Line Production',
5050
'form-field-parentDepartmentId': 'Production',
51-
'form-field-managerId': 'Anthony',
51+
'form-field-managerId': 'Anthony User Crowley',
5252
});
5353
};
5454

@@ -255,7 +255,7 @@ describe('Department Management Tests', () => {
255255
verifyInputFields(Module.departmentManagement, SubModule.departmentDetails, {
256256
'form-field-name': 'Production',
257257
'form-field-parentDepartmentId': '',
258-
'form-field-managerId': 'Anthony',
258+
'form-field-managerId': 'Anthony User Crowley',
259259
});
260260
});
261261

@@ -493,7 +493,7 @@ describe('Department Management Tests', () => {
493493
verifyInputFields(Module.departmentManagement, SubModule.departmentDetails, {
494494
'form-field-name': 'Costume',
495495
'form-field-parentDepartmentId': '',
496-
'form-field-managerId': 'Gabriel',
496+
'form-field-managerId': 'Gabriel Admin Archangel',
497497
});
498498

499499
getTestSelectorByModule(Module.departmentManagement, SubModule.departmentDetails, 'page-title-back-button').click();
@@ -533,7 +533,7 @@ describe('Department Management Tests', () => {
533533
verifyInputFields(Module.departmentManagement, SubModule.departmentDetails, {
534534
'form-field-name': 'Costume',
535535
'form-field-parentDepartmentId': '',
536-
'form-field-managerId': 'Gabriel',
536+
'form-field-managerId': 'Gabriel Admin Archangel',
537537
});
538538
});
539539

cypress/e2e/Employee/EmployeeCatalog.cy.ts

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import {
2525
interceptFetchDepartmentsByIdsRequest,
2626
interceptFetchDepartmentsRequest,
2727
interceptFetchDepartmentByIdRequest,
28+
interceptFetchEmployeesByIdsRequest,
2829
} from 'support/interceptors';
2930

3031
describe('Employee Catalog Tests', () => {
@@ -76,6 +77,7 @@ describe('Employee Catalog Tests', () => {
7677

7778
it('should display the loader if fetching employees is in progress', () => {
7879
interceptFetchEmployeesRequest();
80+
interceptFetchEmployeesByIdsRequest();
7981

8082
getLinearLoader(Module.employeeManagement, SubModule.employeeCatalog, 'table').should('exist');
8183
cy.wait('@fetchEmployeesRequest').its('request.url').should('include', 'Employees?pageNumber=1&pageSize=10');
@@ -89,6 +91,7 @@ describe('Employee Catalog Tests', () => {
8991
{ pageNumber: 1, pageSize: 10 },
9092
{ alias: 'fetchEmployeesQuickRequest', fixture: 'employee/employees', statusCode: 200, delay: 50 }
9193
);
94+
interceptFetchEmployeesByIdsRequest();
9295

9396
getLinearLoader(Module.employeeManagement, SubModule.employeeCatalog, 'table').should('not.exist');
9497
});
@@ -98,6 +101,7 @@ describe('Employee Catalog Tests', () => {
98101
{ pageNumber: 1, pageSize: 10 },
99102
{ alias: 'fetchMultipleEmployeesRequest', fixture: 'employee/employees-multiple' }
100103
);
104+
interceptFetchEmployeesByIdsRequest();
101105

102106
getLinearLoader(Module.employeeManagement, SubModule.employeeCatalog, 'table').should('exist');
103107
cy.wait('@fetchMultipleEmployeesRequest').its('request.url').should('include', 'Employees?pageNumber=1&pageSize=10');
@@ -116,6 +120,18 @@ describe('Employee Catalog Tests', () => {
116120
'have.text',
117121
'Full Name'
118122
);
123+
getTestSelectorByModule(Module.employeeManagement, SubModule.employeeCatalog, 'table-header-cell-assignedBranchName').should(
124+
'have.text',
125+
'Assigned Branch'
126+
);
127+
getTestSelectorByModule(Module.employeeManagement, SubModule.employeeCatalog, 'table-header-cell-assignedDepartmentName').should(
128+
'have.text',
129+
'Assigned Department'
130+
);
131+
getTestSelectorByModule(Module.employeeManagement, SubModule.employeeCatalog, 'table-header-cell-reportsToName').should(
132+
'have.text',
133+
'Manager'
134+
);
119135
getTestSelectorByModule(Module.employeeManagement, SubModule.employeeCatalog, 'table-body-cell-333333333335-firstName')
120136
.find('p')
121137
.should('exist')
@@ -129,6 +145,9 @@ describe('Employee Catalog Tests', () => {
129145
getTestSelectorByModule(Module.employeeManagement, SubModule.employeeCatalog, 'table-body-cell-333333333335-assignedBranchName')
130146
.should('exist')
131147
.and('have.text', 'New York Branch');
148+
getTestSelectorByModule(Module.employeeManagement, SubModule.employeeCatalog, 'table-body-cell-333333333335-reportsToName')
149+
.should('exist')
150+
.and('have.text', 'Gabriel Admin Archangel');
132151
getTestSelectorByModule(Module.employeeManagement, SubModule.employeeCatalog, 'table-body-cell-333333333335-assignedDepartmentName')
133152
.should('exist')
134153
.and('have.text', 'Production');
@@ -141,6 +160,7 @@ describe('Employee Catalog Tests', () => {
141160

142161
it('should send correct request when pagination changes', () => {
143162
interceptFetchEmployeesRequest();
163+
interceptFetchEmployeesByIdsRequest();
144164
cy.wait('@fetchEmployeesRequest');
145165

146166
getTestSelectorByModule(Module.employeeManagement, SubModule.employeeCatalog, 'table-pagination')
@@ -166,6 +186,7 @@ describe('Employee Catalog Tests', () => {
166186
{ pageNumber: 1, pageSize: 10 },
167187
{ alias: 'fetchMultipleEmployeesRequest', fixture: 'employee/employees-multiple' }
168188
);
189+
interceptFetchEmployeesByIdsRequest();
169190

170191
cy.wait('@fetchMultipleEmployeesRequest').its('request.url').should('include', 'Employees?pageNumber=1&pageSize=10');
171192

@@ -218,6 +239,7 @@ describe('Employee Catalog Tests', () => {
218239
{ pageNumber: 1, pageSize: 10, search: 'Anthony' },
219240
{ alias: 'fetchSearchedEmployeesRequest', fixture: 'employee/employees' }
220241
);
242+
interceptFetchEmployeesByIdsRequest();
221243

222244
getTestSelectorByModule(Module.employeeManagement, SubModule.employeeCatalog, 'search-employees').find('input').type('Anthony');
223245
getTestSelectorByModule(Module.employeeManagement, SubModule.employeeCatalog, 'table-body-row', true).should('have.length', 1);
@@ -242,6 +264,7 @@ describe('Employee Catalog Tests', () => {
242264
{ pageNumber: 1, pageSize: 10 },
243265
{ alias: 'fetchMultipleEmployeesRequest', fixture: 'employee/employees-multiple' }
244266
);
267+
interceptFetchEmployeesByIdsRequest();
245268

246269
getLinearLoader(Module.employeeManagement, SubModule.employeeCatalog, 'table').should('exist');
247270
cy.wait('@fetchMultipleEmployeesRequest');
@@ -294,6 +317,7 @@ describe('Employee Catalog Tests', () => {
294317

295318
it('should display action column and correct actions', () => {
296319
interceptFetchEmployeesRequest();
320+
interceptFetchEmployeesByIdsRequest();
297321

298322
getTestSelectorByModule(Module.employeeManagement, SubModule.employeeCatalog, 'table-layout-action-button').should('not.exist');
299323
getTestSelectorByModule(Module.employeeManagement, SubModule.employeeCatalog, 'actions-menu-icon-333333333335')
@@ -312,7 +336,9 @@ describe('Employee Catalog Tests', () => {
312336

313337
it('should be able to navigate to the View Employee page', () => {
314338
interceptFetchEmployeesRequest();
339+
interceptFetchEmployeesByIdsRequest();
315340
interceptFetchEmployeeByIdRequest('333333333335');
341+
interceptFetchEmployeeByIdRequest('333333333333');
316342
interceptFetchBranchByIdRequest('222222222222');
317343
interceptFetchDepartmentByIdRequest('444444444444');
318344

@@ -332,6 +358,7 @@ describe('Employee Catalog Tests', () => {
332358
{ pageNumber: 1, pageSize: 10 },
333359
{ alias: 'fetchMultipleEmployeesRequest', fixture: 'employee/employees-multiple' }
334360
);
361+
interceptFetchEmployeesByIdsRequest();
335362

336363
getLinearLoader(Module.employeeManagement, SubModule.employeeCatalog, 'table').should('exist');
337364
cy.wait('@fetchMultipleEmployeesRequest').its('request.url').should('include', 'Employees?pageNumber=1&pageSize=10');
@@ -350,6 +377,21 @@ describe('Employee Catalog Tests', () => {
350377
'have.text',
351378
'Full Name'
352379
);
380+
getTestSelectorByModule(
381+
Module.employeeManagement,
382+
SubModule.employeeCatalog,
383+
'table-header-cell-333333333335-assignedBranchName'
384+
).should('have.text', 'Assigned Branch');
385+
getTestSelectorByModule(
386+
Module.employeeManagement,
387+
SubModule.employeeCatalog,
388+
'table-header-cell-333333333335-assignedDepartmentName'
389+
).should('have.text', 'Assigned Department');
390+
getTestSelectorByModule(
391+
Module.employeeManagement,
392+
SubModule.employeeCatalog,
393+
'table-header-cell-333333333335-reportsToName'
394+
).should('have.text', 'Manager');
353395
getTestSelectorByModule(Module.employeeManagement, SubModule.employeeCatalog, 'table-body-cell-333333333335-firstName')
354396
.find('p')
355397
.should('exist')
@@ -366,6 +408,9 @@ describe('Employee Catalog Tests', () => {
366408
getTestSelectorByModule(Module.employeeManagement, SubModule.employeeCatalog, 'table-body-cell-333333333335-assignedDepartmentName')
367409
.should('exist')
368410
.and('have.text', 'Production');
411+
getTestSelectorByModule(Module.employeeManagement, SubModule.employeeCatalog, 'table-body-cell-333333333335-reportsToName')
412+
.should('exist')
413+
.and('have.text', 'Gabriel Admin Archangel');
369414
getTestSelectorByModule(Module.employeeManagement, SubModule.employeeCatalog, 'actions-menu-icon-333333333335')
370415
.should('exist')
371416
.click();
@@ -390,6 +435,8 @@ describe('Employee Catalog Tests', () => {
390435
describe('User Role', () => {
391436
beforeEach(() => {
392437
cy.loginMock();
438+
interceptFetchEmployeesRequest({ pageNumber: 1, pageSize: 1 });
439+
interceptFetchDepartmentsRequest({ pageNumber: 1, pageSize: 1 });
393440
});
394441

395442
it('should not be able to navigate to the Edit Employee page', () => {
@@ -411,11 +458,13 @@ describe('Employee Catalog Tests', () => {
411458

412459
it('should be able to navigate to the Edit Employee page', () => {
413460
interceptFetchEmployeesRequest();
461+
interceptFetchEmployeesByIdsRequest();
414462
interceptFetchBranchesByIdsRequest();
415463
interceptFetchDepartmentsByIdsRequest();
416464
interceptFetchBranchesRequest();
417465
interceptFetchDepartmentsRequest();
418466
interceptFetchEmployeeByIdRequest('333333333335');
467+
interceptFetchEmployeeByIdRequest('333333333333');
419468
interceptFetchBranchByIdRequest('222222222222');
420469
interceptFetchDepartmentByIdRequest('444444444444');
421470

0 commit comments

Comments
 (0)