Skip to content

Commit fa13d8a

Browse files
authored
Merge pull request #1148 from fossa-app/use-bridge
Use Bridge NPM Package
2 parents ea56511 + 883533c commit fa13d8a

90 files changed

Lines changed: 1620 additions & 1426 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

cypress.config.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export default defineConfig({
1010
viewportWidth: 1280,
1111
viewportHeight: 720,
1212
env: {
13-
serverBaseUrl: 'http://we.dev.localhost:5210/api/1',
13+
serverBaseUrl: 'http://we.dev.localhost:5210/api/1.0',
1414
fusionAuthBaseUrl: 'http://localhost:9011',
1515
},
1616
setupNodeEvents(on) {
@@ -24,6 +24,7 @@ export default defineConfig({
2424
},
2525
hosts: {
2626
'we.dev.localhost': '127.0.0.1',
27+
'xxx.dev.localhost': '127.0.0.1',
2728
localhost: '127.0.0.1',
2829
},
2930
});

cypress/e2e/Branch/BranchCatalog.cy.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ describe('Branch Catalog Tests', () => {
179179
search(Module.branchManagement, SubModule.branchCatalog, 'search-branches', 'New');
180180

181181
getLinearLoader(Module.branchManagement, SubModule.branchCatalog, 'table').should('exist');
182-
cy.wait('@fetchSearchedBranchesRequest').its('request.url').should('include', 'Branches?pageNumber=1&pageSize=10&search=New');
182+
cy.wait('@fetchSearchedBranchesRequest').its('request.url').should('include', 'Branches?search=New&pageNumber=1&pageSize=10');
183183
getTestSelectorByModule(Module.branchManagement, SubModule.branchCatalog, 'table-body-row', true).should('have.length', 1);
184184

185185
interceptFetchBranchesRequest(
@@ -190,7 +190,7 @@ describe('Branch Catalog Tests', () => {
190190
search(Module.branchManagement, SubModule.branchCatalog, 'search-branches', 'w');
191191

192192
getLinearLoader(Module.branchManagement, SubModule.branchCatalog, 'table').should('exist');
193-
cy.wait('@fetchSearchedNoBranchesRequest').its('request.url').should('include', 'Branches?pageNumber=1&pageSize=10&search=Neww');
193+
cy.wait('@fetchSearchedNoBranchesRequest').its('request.url').should('include', 'Branches?search=Neww&pageNumber=1&pageSize=10');
194194
getTestSelectorByModule(Module.branchManagement, SubModule.branchCatalog, 'table-body-row', true).should('have.length', 0);
195195
getTestSelectorByModule(Module.branchManagement, SubModule.branchCatalog, 'page-subtitle')
196196
.should('exist')
@@ -221,7 +221,7 @@ describe('Branch Catalog Tests', () => {
221221
{ alias: 'searchBranchesRequest', fixture: 'branch/branches' }
222222
);
223223
search(Module.branchManagement, SubModule.branchCatalog, 'search-branches', 'New');
224-
cy.wait('@searchBranchesRequest').its('request.url').should('include', 'Branches?pageNumber=1&pageSize=10&search=New');
224+
cy.wait('@searchBranchesRequest').its('request.url').should('include', 'Branches?search=New&pageNumber=1&pageSize=10');
225225
getTestSelectorByModule(Module.branchManagement, SubModule.branchCatalog, 'table-body-row', true).should('have.length', 1);
226226

227227
interceptFetchBranchesRequest(
@@ -233,7 +233,7 @@ describe('Branch Catalog Tests', () => {
233233
.click();
234234
cy.get('.MuiMenu-paper').find('.MuiTablePagination-menuItem[data-value="20"]').click();
235235

236-
cy.wait('@searchBranchesPageSize20').its('request.url').should('include', 'Branches?pageNumber=1&pageSize=20&search=New');
236+
cy.wait('@searchBranchesPageSize20').its('request.url').should('include', 'Branches?search=New&pageNumber=1&pageSize=20');
237237
getTestSelectorByModule(Module.branchManagement, SubModule.branchCatalog, 'table-body-row', true).should('have.length', 20);
238238
});
239239

cypress/e2e/Company/CompanyManagement.cy.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { ROUTES } from 'shared/constants';
22
import { Module, SubModule } from 'shared/types';
3+
import { daysUntil } from 'shared/helpers';
34
import {
45
clearInputField,
56
clickActionButton,
@@ -44,8 +45,9 @@ const testCompaLicenseFields = () => {
4445
'view-details-label-terms.licensee.shortName': 'Short Name',
4546
'view-details-value-terms.licensee.shortName': 'TCL',
4647
'view-details-label-terms.notBefore': 'Valid From',
47-
'view-details-value-terms.notBefore': '9/1/2024',
48+
'view-details-value-terms.notBefore': new Date('2024-09-01T00:00:00Z').toLocaleDateString(),
4849
'view-details-label-terms.notAfter': 'Valid To',
50+
'view-details-value-terms.notAfter': `${new Date('2035-09-01T00:00:00Z').toLocaleDateString()} (${daysUntil('2035-09-01T00:00:00Z')} days left)`,
4951
'view-details-label-entitlements.maximumBranchCount': 'Branch usage: 1 of 10',
5052
'view-details-label-entitlements.maximumEmployeeCount': 'Employee usage: 1 of 100',
5153
'view-details-label-entitlements.maximumDepartmentCount': 'Department usage: 4 of 20',

cypress/e2e/Department/DepartmentCatalog.cy.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ describe('Department Catalog Tests', () => {
235235
getLinearLoader(Module.departmentManagement, SubModule.departmentCatalog, 'table').should('exist');
236236
cy.wait('@fetchSearchedDepartmentsRequest')
237237
.its('request.url')
238-
.should('include', 'Departments?pageNumber=1&pageSize=10&search=Production');
238+
.should('include', 'Departments?search=Production&pageNumber=1&pageSize=10');
239239
getTestSelectorByModule(Module.departmentManagement, SubModule.departmentCatalog, 'table-body-row', true).should(
240240
'have.length',
241241
3
@@ -251,7 +251,7 @@ describe('Department Catalog Tests', () => {
251251
getLinearLoader(Module.departmentManagement, SubModule.departmentCatalog, 'table').should('exist');
252252
cy.wait('@fetchSearchedNoDepartmentsRequest')
253253
.its('request.url')
254-
.should('include', 'Departments?pageNumber=1&pageSize=10&search=Productions');
254+
.should('include', 'Departments?search=Productions&pageNumber=1&pageSize=10');
255255
getTestSelectorByModule(Module.departmentManagement, SubModule.departmentCatalog, 'table-body-row', true).should(
256256
'have.length',
257257
0
@@ -298,7 +298,7 @@ describe('Department Catalog Tests', () => {
298298
getLinearLoader(Module.departmentManagement, SubModule.departmentCatalog, 'table').should('exist');
299299
cy.wait('@searchDepartmentsRequest')
300300
.its('request.url')
301-
.should('include', 'Departments?pageNumber=1&pageSize=10&search=Production');
301+
.should('include', 'Departments?search=Production&pageNumber=1&pageSize=10');
302302
getTestSelectorByModule(Module.departmentManagement, SubModule.departmentCatalog, 'table-body-row', true).should(
303303
'have.length',
304304
3
@@ -315,7 +315,7 @@ describe('Department Catalog Tests', () => {
315315

316316
cy.wait('@searchDepartmentsPageSize20')
317317
.its('request.url')
318-
.should('include', 'Departments?pageNumber=1&pageSize=20&search=Production');
318+
.should('include', 'Departments?search=Production&pageNumber=1&pageSize=20');
319319
getTestSelectorByModule(Module.departmentManagement, SubModule.departmentCatalog, 'table-body-row', true).should(
320320
'have.length',
321321
20
@@ -580,8 +580,8 @@ describe('Department Catalog Tests', () => {
580580

581581
fillDepartmentDetailsForm({
582582
name: 'Set Design',
583-
parentDepartmentId: 444444444446,
584-
managerId: 333333333333,
583+
parentDepartmentId: 444444444446n,
584+
managerId: 333333333333n,
585585
});
586586

587587
interceptFetchDepartmentsRequest(

cypress/e2e/Department/DepartmentManagement.cy.ts

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,8 @@ describe('Department Management Tests', () => {
102102

103103
fillDepartmentDetailsForm({
104104
name: 'Veeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeery long department name',
105-
parentDepartmentId: 444444444446,
106-
managerId: 333333333335,
105+
parentDepartmentId: 444444444446n,
106+
managerId: 333333333335n,
107107
});
108108
clickActionButton(Module.departmentManagement, SubModule.departmentDetails);
109109

@@ -114,7 +114,7 @@ describe('Department Management Tests', () => {
114114
clearDepartmentDetailsForm();
115115
fillDepartmentDetailsForm({
116116
name: 'Valid Name',
117-
managerId: 333333333335,
117+
managerId: 333333333335n,
118118
});
119119
clickActionButton(Module.departmentManagement, SubModule.departmentDetails);
120120

@@ -144,8 +144,8 @@ describe('Department Management Tests', () => {
144144

145145
fillDepartmentDetailsForm({
146146
name: 'New Department',
147-
parentDepartmentId: 444444444446,
148-
managerId: 333333333335,
147+
parentDepartmentId: 444444444446n,
148+
managerId: 333333333335n,
149149
});
150150
clickActionButton(Module.departmentManagement, SubModule.departmentDetails);
151151
cy.wait('@createDepartmentFailedRequest');
@@ -175,8 +175,8 @@ describe('Department Management Tests', () => {
175175

176176
fillDepartmentDetailsForm({
177177
name: 'Set Design',
178-
parentDepartmentId: 444444444446,
179-
managerId: 333333333333,
178+
parentDepartmentId: 444444444446n,
179+
managerId: 333333333333n,
180180
});
181181
getTestSelectorByModule(Module.departmentManagement, SubModule.departmentDetails, 'form-submit-button').should('contain.text', 'Save');
182182
interceptFetchDepartmentsRequest(
@@ -241,8 +241,8 @@ describe('Department Management Tests', () => {
241241
clearDepartmentDetailsForm();
242242
fillDepartmentDetailsForm({
243243
name: 'Department Name',
244-
parentDepartmentId: 444444444446,
245-
managerId: 333333333335,
244+
parentDepartmentId: 444444444446n,
245+
managerId: 333333333335n,
246246
});
247247
getTestSelectorByModule(Module.departmentManagement, SubModule.departmentDetails, 'form-cancel-button').should('exist').click();
248248

@@ -291,7 +291,7 @@ describe('Department Management Tests', () => {
291291
clearDepartmentDetailsForm();
292292
fillDepartmentDetailsForm({
293293
name: 'Set Design',
294-
managerId: 333333333333,
294+
managerId: 333333333333n,
295295
});
296296
clickActionButton(Module.departmentManagement, SubModule.departmentDetails);
297297

@@ -323,7 +323,7 @@ describe('Department Management Tests', () => {
323323
cy.wait('@fetchDepartmentByIdRequest');
324324

325325
fillDepartmentDetailsForm({
326-
parentDepartmentId: 444444444446,
326+
parentDepartmentId: 444444444446n,
327327
});
328328
clickActionButton(Module.departmentManagement, SubModule.departmentDetails);
329329

@@ -368,8 +368,8 @@ describe('Department Management Tests', () => {
368368

369369
fillDepartmentDetailsForm({
370370
name: 'Department Name',
371-
parentDepartmentId: 444444444446,
372-
managerId: 333333333335,
371+
parentDepartmentId: 444444444446n,
372+
managerId: 333333333335n,
373373
});
374374
clickActionButton(Module.departmentManagement, SubModule.departmentDetails);
375375
cy.wait('@createDepartmentFailedWithErrorRequest');
@@ -421,8 +421,8 @@ describe('Department Management Tests', () => {
421421
clearDepartmentDetailsForm();
422422
fillDepartmentDetailsForm({
423423
name: 'Costume Updated',
424-
parentDepartmentId: 444444444446,
425-
managerId: 333333333335,
424+
parentDepartmentId: 444444444446n,
425+
managerId: 333333333335n,
426426
});
427427
interceptFetchEmployeesByIdsRequest();
428428
interceptFetchDepartmentsByIdsRequest();

cypress/e2e/Employee/EmployeeCatalog.cy.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ describe('Employee Catalog Tests', () => {
225225

226226
getLinearLoader(Module.employeeManagement, SubModule.employeeCatalog, 'table').should('exist');
227227

228-
cy.wait('@fetchSearchedEmployeesRequest').its('request.url').should('include', 'Employees?pageNumber=1&pageSize=10&search=Anthony');
228+
cy.wait('@fetchSearchedEmployeesRequest').its('request.url').should('include', 'Employees?search=Anthony&pageNumber=1&pageSize=10');
229229
getTestSelectorByModule(Module.employeeManagement, SubModule.employeeCatalog, 'table-body-row', true).should('have.length', 1);
230230

231231
interceptFetchEmployeesRequest(
@@ -239,7 +239,7 @@ describe('Employee Catalog Tests', () => {
239239

240240
cy.wait('@fetchSearchedNoEmployeesRequest')
241241
.its('request.url')
242-
.should('include', 'Employees?pageNumber=1&pageSize=10&search=Anthonyy');
242+
.should('include', 'Employees?search=Anthonyy&pageNumber=1&pageSize=10');
243243
getTestSelectorByModule(Module.employeeManagement, SubModule.employeeCatalog, 'table-body-row', true).should('have.length', 0);
244244
getTestSelectorByModule(Module.employeeManagement, SubModule.employeeCatalog, 'page-subtitle')
245245
.should('exist')
@@ -274,7 +274,7 @@ describe('Employee Catalog Tests', () => {
274274
search(Module.employeeManagement, SubModule.employeeCatalog, 'search-employees', 'Anthony');
275275

276276
getLinearLoader(Module.employeeManagement, SubModule.employeeCatalog, 'table').should('exist');
277-
cy.wait('@searchEmployeesRequest').its('request.url').should('include', 'Employees?pageNumber=1&pageSize=10&search=Anthony');
277+
cy.wait('@searchEmployeesRequest').its('request.url').should('include', 'Employees?search=Anthony&pageNumber=1&pageSize=10');
278278
getTestSelectorByModule(Module.employeeManagement, SubModule.employeeCatalog, 'table-body-row', true).should('have.length', 1);
279279

280280
interceptFetchEmployeesRequest(
@@ -286,7 +286,7 @@ describe('Employee Catalog Tests', () => {
286286
.click();
287287
cy.get('.MuiMenu-paper').find('.MuiTablePagination-menuItem[data-value="20"]').click();
288288

289-
cy.wait('@searchEmployeesPageSize20').its('request.url').should('include', 'Employees?pageNumber=1&pageSize=20&search=Anthony');
289+
cy.wait('@searchEmployeesPageSize20').its('request.url').should('include', 'Employees?search=Anthony&pageNumber=1&pageSize=20');
290290
getTestSelectorByModule(Module.employeeManagement, SubModule.employeeCatalog, 'table-body-row', true).should('have.length', 15);
291291
getTablePaginationSizeInput(Module.employeeManagement, SubModule.employeeCatalog, 'table-pagination').should('have.value', '20');
292292
});

cypress/support/interceptors.ts

Lines changed: 23 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
import { Branch, Department, Employee, PaginatedResponse } from '../../src/shared/types';
1+
import { Branch } from '../../src/shared/types/branch';
2+
import { Department } from '../../src/shared/types/department';
3+
import { Employee } from '../../src/shared/types/employee';
4+
import type { PaginatedResponse } from '../../src/shared/types/response';
25

36
const baseUrl = Cypress.config('baseUrl');
47
const serverBaseUrl = Cypress.env('serverBaseUrl');
@@ -12,18 +15,14 @@ export const interceptFetchSystemLicenseRequest = () => {
1215

1316
export const interceptFetchClientRequest = () => {
1417
cy.fixture('client').then((client) => {
15-
cy.intercept('GET', `${serverBaseUrl}/Identity/Client?origin=${Cypress.config('baseUrl')}`, { body: client }).as('fetchClientRequest');
18+
cy.intercept('GET', `${serverBaseUrl}/Identity/Client?origin=${encodeURIComponent(baseUrl ?? '')}`, { body: client }).as(
19+
'fetchClientRequest'
20+
);
1621
});
1722
};
1823

1924
export const interceptFetchClientFailedRequest = () => {
20-
cy.interceptWithAuth(
21-
'GET',
22-
`${serverBaseUrl}/Identity/Client?origin=${Cypress.config('baseUrl')}`,
23-
null,
24-
'fetchClientFailedRequest',
25-
404
26-
);
25+
cy.intercept('GET', '**/api/1.0/Identity/Client?origin=*', { statusCode: 404 }).as('fetchClientFailedRequest');
2726
};
2827

2928
export const interceptLoginRequest = () => {
@@ -98,7 +97,7 @@ export const interceptDeleteCompanyFailedRequest = () => {
9897

9998
export const interceptFetchCompanyLicenseRequest = ({
10099
notBefore = '2024-09-01T00:00:00+00:00',
101-
notAfter = '2025-09-01T00:00:00+00:00',
100+
notAfter = '2035-09-01T00:00:00+00:00',
102101
} = {}) => {
103102
cy.fixture('company/company-license').then((companyLicense) => {
104103
const modifiedLicense = JSON.parse(JSON.stringify(companyLicense));
@@ -178,8 +177,8 @@ export const interceptFetchBranchesRequest = (
178177
{ alias = 'fetchBranchesRequest', fixture = 'branch/branches', statusCode = 200, delay = 300 } = {}
179178
) => {
180179
cy.fixture(fixture).then((branches) => {
181-
const searchParam = search ? `&search=${search}` : '';
182-
const url = `${serverBaseUrl}/Branches?pageNumber=${pageNumber}&pageSize=${pageSize}${searchParam}`;
180+
const searchParam = search ? `search=${search}&` : '';
181+
const url = `${serverBaseUrl}/Branches?${searchParam}pageNumber=${pageNumber}&pageSize=${pageSize}`;
183182

184183
cy.interceptWithAuth('GET', url, branches, alias, statusCode, delay);
185184
});
@@ -339,10 +338,15 @@ export const interceptFetchEmployeesRequest = (
339338
{ alias = 'fetchEmployeesRequest', fixture = 'employee/employees', statusCode = 200, delay = 300 } = {}
340339
) => {
341340
cy.fixture(fixture).then((employees) => {
342-
const searchParam = search ? `&search=${search}` : '';
343-
const reportsToParam = reportsToId !== undefined ? `&reportsToId=${reportsToId}` : '';
344-
const topLevelParam = topLevelOnly !== undefined ? `&topLevelOnly=${topLevelOnly}` : '';
345-
const url = `${serverBaseUrl}/Employees?pageNumber=${pageNumber}&pageSize=${pageSize}${searchParam}${reportsToParam}${topLevelParam}`;
341+
const searchParam = search ? `search=${encodeURIComponent(search)}&` : '';
342+
const pageNumberParam = `pageNumber=${pageNumber}&`;
343+
const pageSizeParam = `pageSize=${pageSize}&`;
344+
const reportsToParam = reportsToId !== undefined ? `reportsToId=${reportsToId}&` : '';
345+
const topLevelParam = topLevelOnly !== undefined ? `topLevelOnly=${topLevelOnly}` : '';
346+
const url = `${serverBaseUrl}/Employees?${searchParam}${pageNumberParam}${pageSizeParam}${reportsToParam}${topLevelParam}`.replace(
347+
/&$/,
348+
''
349+
);
346350

347351
cy.interceptWithAuth('GET', url, employees, alias, statusCode, delay);
348352
});
@@ -355,7 +359,7 @@ export const interceptFetchEmployeesFailedRequest = () => {
355359
export const interceptFetchEmployeeByIdRequest = (
356360
id: string,
357361
alias = 'fetchEmployeeByIdRequest',
358-
fixture = 'employee/employees',
362+
fixture = 'employee/employees-multiple',
359363
statusCode = 200,
360364
delay = 300
361365
) => {
@@ -412,8 +416,8 @@ export const interceptFetchDepartmentsRequest = (
412416
{ alias = 'fetchDepartmentsRequest', fixture = 'department/departments', statusCode = 200, delay = 300 } = {}
413417
) => {
414418
cy.fixture(fixture).then((departments) => {
415-
const searchParam = search ? `&search=${search}` : '';
416-
const url = `${serverBaseUrl}/Departments?pageNumber=${pageNumber}&pageSize=${pageSize}${searchParam}`;
419+
const searchParam = search ? `search=${search}&` : '';
420+
const url = `${serverBaseUrl}/Departments?${searchParam}pageNumber=${pageNumber}&pageSize=${pageSize}`;
417421

418422
cy.interceptWithAuth('GET', url, departments, alias, statusCode, delay);
419423
});

jest.config.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -171,12 +171,11 @@ const config: Config = {
171171

172172
// A map from regular expressions to paths to transformers
173173
transform: {
174-
'^.+\\.tsx?$': 'ts-jest',
175-
'^.+\\.ts?$': 'ts-jest',
174+
'^.+\\.[tj]sx?$': 'ts-jest',
176175
},
177176

178177
// An array of regexp pattern strings that are matched against all source file paths, matched files will skip transformation
179-
transformIgnorePatterns: ['node_modules/(?!(\\oidc-client-ts)/)'],
178+
transformIgnorePatterns: ['node_modules/(?!(@fossa-app|@fable-org|oidc-client-ts)/)'],
180179

181180
// An array of regexp pattern strings that are matched against all modules before the module loader will automatically return a mock for them
182181
// unmockedModulePathPatterns: undefined,

package-lock.json

Lines changed: 16 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@
66
"dependencies": {
77
"@emotion/react": "^11.14.0",
88
"@emotion/styled": "^11.13.0",
9+
"@fossa-app/bridge": "^0.1.40",
910
"@mui/icons-material": "^6.1.6",
1011
"@mui/material": "^6.4.8",
1112
"@reduxjs/toolkit": "^2.11.2",
12-
"axios": "^1.16.1",
1313
"leaflet": "^1.9.4",
1414
"oidc-client-ts": "^3.5.0",
1515
"react": "^19.2.0",

0 commit comments

Comments
 (0)