sr-npm 1.7.723 → 1.7.725
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "sr-npm",
|
|
3
|
-
"version": "1.7.
|
|
3
|
+
"version": "1.7.725",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -31,6 +31,7 @@
|
|
|
31
31
|
"@eslint/js": "^9.39.0",
|
|
32
32
|
"eslint": "^9.38.0",
|
|
33
33
|
"globals": "^16.4.0",
|
|
34
|
-
"prettier": "^3.6.2"
|
|
34
|
+
"prettier": "^3.6.2",
|
|
35
|
+
"rewire": "^9.0.1"
|
|
35
36
|
}
|
|
36
37
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const { COLLECTIONS,CUSTOM_VALUES_COLLECTION_FIELDS,JOBS_COLLECTION_FIELDS } = require('../backend/collectionConsts');
|
|
2
|
+
const { queryParams } = require('wix-location-frontend');
|
|
2
3
|
const {CAREERS_MULTI_BOXES_PAGE_CONSTS,FiltersIds,fieldTitlesInCMS} = require('../backend/careersMultiBoxesPageIds');
|
|
3
|
-
const { query,queryParams,onChange} = require("wix-location-frontend");
|
|
4
4
|
const { groupValuesByField, debounce, getAllRecords, getFieldById, getFieldByTitle,getCorrectOption,getOptionIndexFromCheckBox } = require('./pagesUtils');
|
|
5
5
|
|
|
6
6
|
let dontUpdateThisCheckBox;
|
|
@@ -51,6 +51,9 @@ async function handleUrlParams(_$w,urlParams) {
|
|
|
51
51
|
if(applyFiltering) {
|
|
52
52
|
await updateJobsAndNumbersAndFilters(_$w);
|
|
53
53
|
}
|
|
54
|
+
// if(urlParams.page) {
|
|
55
|
+
|
|
56
|
+
// }
|
|
54
57
|
}
|
|
55
58
|
|
|
56
59
|
async function handleParams(_$w,param,value) {
|
|
@@ -314,13 +317,25 @@ async function loadJobsRepeater(_$w) {
|
|
|
314
317
|
|
|
315
318
|
function handlePaginationButtons(_$w,secondarySearch=false)
|
|
316
319
|
{
|
|
320
|
+
handlePageUrlParam();
|
|
317
321
|
pagination.currentPage===1? _$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.PAGE_BUTTON_PREVIOUS).disable():_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.PAGE_BUTTON_PREVIOUS).enable();
|
|
318
322
|
if(secondarySearch) {
|
|
319
|
-
pagination.currentPage
|
|
323
|
+
pagination.currentPage>=Math.ceil(secondarySearchJobs.length/pagination.pageSize)? _$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.PAGE_BUTTON_NEXT).disable():_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.PAGE_BUTTON_NEXT).enable();
|
|
320
324
|
}
|
|
321
325
|
else {
|
|
322
|
-
pagination.currentPage
|
|
326
|
+
pagination.currentPage>=Math.ceil(currentJobs.length/pagination.pageSize)? _$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.PAGE_BUTTON_NEXT).disable():_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.PAGE_BUTTON_NEXT).enable();
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
function handlePageUrlParam() {
|
|
331
|
+
if(pagination.currentPage==1)
|
|
332
|
+
{
|
|
333
|
+
queryParams.remove(["page"]);
|
|
334
|
+
}
|
|
335
|
+
else{
|
|
336
|
+
queryParams.add({ page: pagination.currentPage });
|
|
323
337
|
}
|
|
338
|
+
|
|
324
339
|
}
|
|
325
340
|
async function refreshFacetCounts(_$w,clearAll=false) {
|
|
326
341
|
const fieldIds = Array.from(optionsByFieldId.keys());
|
|
@@ -365,24 +380,21 @@ function primarySearch(_$w,query) {
|
|
|
365
380
|
console.log("primary search query: ", query);
|
|
366
381
|
}
|
|
367
382
|
function secondarySearch(_$w,query) {
|
|
368
|
-
console.log("secondary search query: ", query);
|
|
369
383
|
if(query.length===0) {
|
|
370
384
|
secondarySearchJobs=currentJobs;
|
|
371
385
|
}
|
|
372
386
|
else {
|
|
373
387
|
secondarySearchJobs=currentJobs.filter(job=>job.title.toLowerCase().includes(query));
|
|
374
388
|
}
|
|
375
|
-
console.log("current jobs length: ", currentJobs.length);
|
|
376
|
-
console.log("current jobs: ", currentJobs);
|
|
377
389
|
|
|
378
390
|
const jobsFirstPage=secondarySearchJobs.slice(0,pagination.pageSize);
|
|
379
|
-
console.log("jobs first page: ", jobsFirstPage);
|
|
380
391
|
_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.JOBS_REPEATER).data = jobsFirstPage;
|
|
381
392
|
_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.paginationCurrentText).text = jobsFirstPage.length.toString();
|
|
382
393
|
_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.paginationTotalCountText).text = secondarySearchJobs.length.toString();
|
|
383
394
|
pagination.currentPage=1;
|
|
384
395
|
handlePaginationButtons(_$w,true);
|
|
385
396
|
updateTotalJobsCountText(_$w,true);
|
|
397
|
+
return secondarySearchJobs;
|
|
386
398
|
}
|
|
387
399
|
function bindSearchInput(_$w) {
|
|
388
400
|
const primarySearchDebounced = debounce(() => {
|
|
@@ -398,5 +410,6 @@ function secondarySearch(_$w,query) {
|
|
|
398
410
|
}
|
|
399
411
|
|
|
400
412
|
module.exports = {
|
|
401
|
-
careersMultiBoxesPageOnReady
|
|
413
|
+
careersMultiBoxesPageOnReady,
|
|
414
|
+
secondarySearch
|
|
402
415
|
};
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
class MockJobBuilder {
|
|
2
|
+
constructor() {
|
|
3
|
+
this.reset();
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
reset() {
|
|
7
|
+
this.jobData = {
|
|
8
|
+
id: this.generateId(),
|
|
9
|
+
title: "Software Engineer",
|
|
10
|
+
uuid: this.generateUuid(),
|
|
11
|
+
refNumber: this.generateRefNumber(),
|
|
12
|
+
company: {
|
|
13
|
+
identifier: "TheWarehouseGroup1",
|
|
14
|
+
name: "The Warehouse Group"
|
|
15
|
+
},
|
|
16
|
+
location: {
|
|
17
|
+
city: "Auckland",
|
|
18
|
+
region: "Auckland Region",
|
|
19
|
+
country: "nz",
|
|
20
|
+
address: "123 Queen Street",
|
|
21
|
+
postalCode: "1010",
|
|
22
|
+
remote: false,
|
|
23
|
+
latitude: "-36.8484597",
|
|
24
|
+
longitude: "174.7633315",
|
|
25
|
+
fullLocation: "Auckland, Auckland Region, New Zealand"
|
|
26
|
+
},
|
|
27
|
+
employmentType: "Full-time",
|
|
28
|
+
customField: [
|
|
29
|
+
{
|
|
30
|
+
fieldId: "5cd160b26b2f07000673dc00",
|
|
31
|
+
fieldLabel: "Brands",
|
|
32
|
+
valueId: "2b6526b2-ed37-426c-8592-1c580f462334",
|
|
33
|
+
valueLabel: "The Warehouse"
|
|
34
|
+
}
|
|
35
|
+
]
|
|
36
|
+
};
|
|
37
|
+
return this;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
generateId() {
|
|
41
|
+
return `74400009${Math.floor(1000000 + Math.random() * 9000000)}`;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
generateUuid() {
|
|
45
|
+
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, (c) => {
|
|
46
|
+
const r = Math.random() * 16 | 0;
|
|
47
|
+
const v = c === 'x' ? r : (r & 0x3 | 0x8);
|
|
48
|
+
return v.toString(16);
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
generateRefNumber() {
|
|
53
|
+
return `REF${Math.floor(10000 + Math.random() * 90000)}G`;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
withId(id) {
|
|
57
|
+
this.jobData.id = id;
|
|
58
|
+
return this;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
withTitle(title) {
|
|
62
|
+
this.jobData.title = title;
|
|
63
|
+
return this;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
withUuid(uuid) {
|
|
67
|
+
this.jobData.uuid = uuid;
|
|
68
|
+
return this;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
withRefNumber(refNumber) {
|
|
72
|
+
this.jobData.refNumber = refNumber;
|
|
73
|
+
return this;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
withCompany(identifier, name) {
|
|
77
|
+
this.jobData.company = {
|
|
78
|
+
identifier: identifier || this.jobData.company.identifier,
|
|
79
|
+
name: name || this.jobData.company.name
|
|
80
|
+
};
|
|
81
|
+
return this;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
withLocation(locationData) {
|
|
85
|
+
this.jobData.location = {
|
|
86
|
+
...this.jobData.location,
|
|
87
|
+
...locationData
|
|
88
|
+
};
|
|
89
|
+
return this;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
withCity(city, region = null, fullLocation = null) {
|
|
93
|
+
this.jobData.location.city = city;
|
|
94
|
+
if (region) this.jobData.location.region = region;
|
|
95
|
+
if (fullLocation) {
|
|
96
|
+
this.jobData.location.fullLocation = fullLocation;
|
|
97
|
+
} else {
|
|
98
|
+
this.jobData.location.fullLocation = `${city}, ${this.jobData.location.region}, New Zealand`;
|
|
99
|
+
}
|
|
100
|
+
return this;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
withEmploymentType(employmentType) {
|
|
104
|
+
this.jobData.employmentType = employmentType;
|
|
105
|
+
return this;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
withCustomField(fieldId, fieldLabel, valueId, valueLabel) {
|
|
109
|
+
this.jobData.customField.push({
|
|
110
|
+
fieldId,
|
|
111
|
+
fieldLabel,
|
|
112
|
+
valueId,
|
|
113
|
+
valueLabel
|
|
114
|
+
});
|
|
115
|
+
return this;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
withCustomFields(fields) {
|
|
119
|
+
this.jobData.customField = fields;
|
|
120
|
+
return this;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
asRemote() {
|
|
124
|
+
this.jobData.location.remote = true;
|
|
125
|
+
return this;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
asOnsite() {
|
|
129
|
+
this.jobData.location.remote = false;
|
|
130
|
+
return this;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
build() {
|
|
134
|
+
const result = { ...this.jobData };
|
|
135
|
+
this.reset();
|
|
136
|
+
return result;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
static createDefault() {
|
|
140
|
+
return new MockJobBuilder().build();
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
static createSeniorEngineer() {
|
|
144
|
+
return new MockJobBuilder()
|
|
145
|
+
.withTitle("Senior Software Engineer")
|
|
146
|
+
.withCity("Dunedin", "Otago Region")
|
|
147
|
+
.withEmploymentType("Full-time")
|
|
148
|
+
.build();
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
static createBackendDeveloper() {
|
|
152
|
+
return new MockJobBuilder()
|
|
153
|
+
.withTitle("Backend Developer")
|
|
154
|
+
.withCity("Auckland", "Auckland Region")
|
|
155
|
+
.withEmploymentType("Part-time")
|
|
156
|
+
.build();
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
static createProductManager() {
|
|
160
|
+
return new MockJobBuilder()
|
|
161
|
+
.withTitle("Product Manager")
|
|
162
|
+
.withCity("Wellington", "Wellington Region")
|
|
163
|
+
.withEmploymentType("Full-time")
|
|
164
|
+
.asRemote()
|
|
165
|
+
.build();
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
static createMultiple(count, customizer = null) {
|
|
169
|
+
const jobs = [];
|
|
170
|
+
for (let i = 0; i < count; i++) {
|
|
171
|
+
const builder = new MockJobBuilder();
|
|
172
|
+
if (customizer) {
|
|
173
|
+
customizer(builder, i);
|
|
174
|
+
}
|
|
175
|
+
jobs.push(builder.build());
|
|
176
|
+
}
|
|
177
|
+
return jobs;
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
module.exports = MockJobBuilder;
|
|
182
|
+
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
const rewire = require('rewire');
|
|
2
|
+
const MockJobBuilder = require('./mockJobBuilder');
|
|
3
|
+
const { CAREERS_MULTI_BOXES_PAGE_CONSTS } = require('../backend/careersMultiBoxesPageIds');
|
|
4
|
+
|
|
5
|
+
const careersMultiBoxesPage = rewire('../pages/careersMultiBoxesPage');
|
|
6
|
+
const secondarySearch = careersMultiBoxesPage.__get__('secondarySearch');
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
describe('secondarySearch function tests', () => {
|
|
11
|
+
let mockW;
|
|
12
|
+
let mockJobsRepeater;
|
|
13
|
+
let mockPaginationCurrentText;
|
|
14
|
+
let mockPaginationTotalCountText;
|
|
15
|
+
let mockPageButtonNext;
|
|
16
|
+
let mockPageButtonPrevious;
|
|
17
|
+
let mockTotalJobsCountText;
|
|
18
|
+
|
|
19
|
+
beforeEach(() => {
|
|
20
|
+
mockJobsRepeater = { data: null };
|
|
21
|
+
mockPaginationCurrentText = { text: '' };
|
|
22
|
+
mockPaginationTotalCountText = { text: '' };
|
|
23
|
+
mockPageButtonNext = {
|
|
24
|
+
enable: jest.fn(),
|
|
25
|
+
disable: jest.fn()
|
|
26
|
+
};
|
|
27
|
+
mockPageButtonPrevious = {
|
|
28
|
+
enable: jest.fn(),
|
|
29
|
+
disable: jest.fn()
|
|
30
|
+
};
|
|
31
|
+
mockTotalJobsCountText = { text: '' };
|
|
32
|
+
|
|
33
|
+
mockW = jest.fn((selector) => {
|
|
34
|
+
const mocks = {
|
|
35
|
+
[CAREERS_MULTI_BOXES_PAGE_CONSTS.JOBS_REPEATER]: mockJobsRepeater,
|
|
36
|
+
[CAREERS_MULTI_BOXES_PAGE_CONSTS.paginationCurrentText]: mockPaginationCurrentText,
|
|
37
|
+
[CAREERS_MULTI_BOXES_PAGE_CONSTS.paginationTotalCountText]: mockPaginationTotalCountText,
|
|
38
|
+
[CAREERS_MULTI_BOXES_PAGE_CONSTS.PAGE_BUTTON_NEXT]: mockPageButtonNext,
|
|
39
|
+
[CAREERS_MULTI_BOXES_PAGE_CONSTS.PAGE_BUTTON_PREVIOUS]: mockPageButtonPrevious,
|
|
40
|
+
[CAREERS_MULTI_BOXES_PAGE_CONSTS.TotalJobsCountText]: mockTotalJobsCountText
|
|
41
|
+
};
|
|
42
|
+
return mocks[selector] || {
|
|
43
|
+
data: null,
|
|
44
|
+
text: '',
|
|
45
|
+
value: '',
|
|
46
|
+
onClick: jest.fn(),
|
|
47
|
+
onChange: jest.fn(),
|
|
48
|
+
onInput: jest.fn(),
|
|
49
|
+
enable: jest.fn(),
|
|
50
|
+
disable: jest.fn()
|
|
51
|
+
};
|
|
52
|
+
});
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
afterEach(() => {
|
|
56
|
+
jest.clearAllMocks();
|
|
57
|
+
careersMultiBoxesPage.__set__('currentJobs', []);
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
it('should return count > 0 when searching for existing job title', () => {
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
let mockJobs = MockJobBuilder.createMultiple(11, (builder, index) => {
|
|
64
|
+
builder.withTitle(`Product Manager ${index}`);
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
mockJobs.push(new MockJobBuilder().withTitle('Backend Engineer').build());
|
|
68
|
+
mockJobs.push(new MockJobBuilder().withTitle('Frontend Engineer').build());
|
|
69
|
+
|
|
70
|
+
careersMultiBoxesPage.__set__('currentJobs', mockJobs);
|
|
71
|
+
|
|
72
|
+
const result = secondarySearch(mockW, 'product');
|
|
73
|
+
|
|
74
|
+
expect(result.length).toBe(11);
|
|
75
|
+
expect(mockTotalJobsCountText.text).toContain('11 Jobs');
|
|
76
|
+
expect(mockPaginationCurrentText.text).toBe('10');
|
|
77
|
+
expect(mockPaginationTotalCountText.text).toBe('11');
|
|
78
|
+
expect(mockPageButtonNext.enable).toHaveBeenCalled();
|
|
79
|
+
expect(mockPageButtonPrevious.disable).toHaveBeenCalled();
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
it('should return 0 when searching for non-existing job title', () => {
|
|
83
|
+
let mockJobs = MockJobBuilder.createMultiple(11, (builder, index) => {
|
|
84
|
+
builder.withTitle(`random job ${index}`);
|
|
85
|
+
});
|
|
86
|
+
careersMultiBoxesPage.__set__('currentJobs', mockJobs);
|
|
87
|
+
|
|
88
|
+
const result = secondarySearch(mockW, 'unicorn hunter');
|
|
89
|
+
|
|
90
|
+
expect(result.length).toBe(0);
|
|
91
|
+
expect(mockTotalJobsCountText.text).toContain('0 Jobs');
|
|
92
|
+
expect(mockPaginationCurrentText.text).toBe('0');
|
|
93
|
+
expect(mockPaginationTotalCountText.text).toBe('0');
|
|
94
|
+
expect(mockPageButtonNext.disable).toHaveBeenCalled();
|
|
95
|
+
expect(mockPageButtonPrevious.disable).toHaveBeenCalled();
|
|
96
|
+
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
});
|
|
100
|
+
|