sr-npm 1.7.818 → 1.7.820
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/backend/collectionConsts.js +3 -0
- package/backend/consts.js +31 -0
- package/backend/data.js +2 -1
- package/backend/queries.js +5 -9
- package/package.json +1 -1
- package/pages/careersMultiBoxesPage.js +6 -108
- package/pages/homePage.js +18 -1
- package/pages/index.js +1 -1
- package/pages/pagesUtils.js +137 -1
- package/pages/positionPage.js +1 -48
- package/pages/supportTeamsPage.js +31 -14
- package/tests/mockJobBuilder.js +0 -93
- package/tests/multiSearchBoxCareers.spec.js +6 -5
- package/pages/brandPage.js +0 -12
- package/tests/positionPageTest.spec.js +0 -139
|
@@ -8,6 +8,7 @@ const COLLECTIONS = {
|
|
|
8
8
|
CUSTOM_VALUES:'CustomValues',
|
|
9
9
|
CUSTOM_FIELDS:'CustomFields',
|
|
10
10
|
SITE_CONFIGS: 'SiteConfigs',
|
|
11
|
+
SUPPORT_TEAMS: 'SupportTeams',
|
|
11
12
|
|
|
12
13
|
}
|
|
13
14
|
const JOBS_COLLECTION_FIELDS = {
|
|
@@ -29,6 +30,7 @@ const JOBS_COLLECTION_FIELDS = {
|
|
|
29
30
|
BRAND_REF: 'brandRef',
|
|
30
31
|
MULTI_REF_JOBS_CUSTOM_VALUES: 'multiRefJobsCustomValues',
|
|
31
32
|
EMPLOYMENT_TYPE: 'employmentType',
|
|
33
|
+
RELEASED_DATE: 'releasedDate',
|
|
32
34
|
}
|
|
33
35
|
const AMOUNT_OF_JOBS_PER_DEPARTMENT_COLLECTION_FIELDS = {
|
|
34
36
|
TITLE: 'title',
|
|
@@ -90,6 +92,7 @@ const COLLECTIONS_FIELDS = {
|
|
|
90
92
|
{key:'brandRef', type: 'REFERENCE', typeMetadata: { reference: { referencedCollectionId: COLLECTIONS.BRANDS } } },
|
|
91
93
|
{key: 'image', type: 'IMAGE' },
|
|
92
94
|
{key:'employmentType', type: 'TEXT'},
|
|
95
|
+
{key:'releasedDate', type: 'TEXT'},
|
|
93
96
|
],
|
|
94
97
|
TEMPLATE_TYPE: [
|
|
95
98
|
{key:'templateType', type: 'TEXT'},
|
package/backend/consts.js
CHANGED
|
@@ -80,9 +80,40 @@ const TASK_TYPE = {
|
|
|
80
80
|
EVENT: 'event',
|
|
81
81
|
};
|
|
82
82
|
|
|
83
|
+
const supportTeamsPageIds={
|
|
84
|
+
RECENTLEY_ADDED_JOBS: "#recentleyAddedJobs",
|
|
85
|
+
JOB_LOCATION: "#jobLocation",
|
|
86
|
+
JOB_TITLE: "#jobTitle",
|
|
87
|
+
SEE_ALL_JOBS_TEXT: "#seeAllJobsText",
|
|
88
|
+
TEAM_SUPPORT_DYNAMIC_DATASET: "#dynamicDataset",
|
|
89
|
+
RECENTLY_ADDED_JOBS_SECTION: "#recentlyJobsSection",
|
|
90
|
+
MOST_RECENT_JOBS_TITLE: "#mostRecentJobsTitle",
|
|
91
|
+
valueToValueIdMap: {
|
|
92
|
+
"Human Resouces":"PeopleSupport",
|
|
93
|
+
"Buying":"Merchandise",
|
|
94
|
+
"Tech":"InformationServices",
|
|
95
|
+
"Planning":"Merchandise",
|
|
96
|
+
"Digital":"ecommerceandDigital",// this field doesnt exists in the database
|
|
97
|
+
"Marketing":"Marketing",
|
|
98
|
+
"Finance":"Finance",// this field doesnt exists in the database
|
|
99
|
+
"Services":"ServicesInstallation",
|
|
100
|
+
"Design":"Merchandise",
|
|
101
|
+
"Retail Operations":"Operations",// this field doesnt exists in the database
|
|
102
|
+
"Data":"InsightsandDataScience",// this field doesnt exists in the database
|
|
103
|
+
"Property":"Property",// this field doesnt exists in the database,
|
|
104
|
+
"Legal":"Legal",// this field doesnt exists in the database,
|
|
105
|
+
"Supply Chain":"Logistics",
|
|
106
|
+
"Contact Centre":"CustomerEngagementCentres",// this field doesnt exists in the database
|
|
107
|
+
"Commercial":"CommercialSales",// this field doesnt exists in the database
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
|
|
83
113
|
module.exports = {
|
|
84
114
|
TASKS_NAMES,
|
|
85
115
|
TASK_TYPE,
|
|
86
116
|
TASKS,
|
|
87
117
|
QUERY_MAX_LIMIT,
|
|
118
|
+
supportTeamsPageIds,
|
|
88
119
|
};
|
package/backend/data.js
CHANGED
|
@@ -125,7 +125,8 @@ async function saveJobsDataToCMS() {
|
|
|
125
125
|
language: position.language?.label || '',
|
|
126
126
|
brand: getBrand(position.customField),
|
|
127
127
|
jobDescription: null, // Will be filled later
|
|
128
|
-
employmentType: position.typeOfEmployment.label
|
|
128
|
+
employmentType: position.typeOfEmployment.label,
|
|
129
|
+
releasedDate: position.releasedDate
|
|
129
130
|
};
|
|
130
131
|
|
|
131
132
|
getCustomFieldsAndValuesFromPosition(position,customFieldsLabels,customFieldsValues);
|
package/backend/queries.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const { COLLECTIONS
|
|
1
|
+
const { COLLECTIONS } = require('./collectionConsts');
|
|
2
2
|
const { items: wixData } = require('@wix/data');
|
|
3
3
|
|
|
4
4
|
|
|
@@ -18,11 +18,7 @@ async function getPositionsByField(field, value) {
|
|
|
18
18
|
.then(result => result.items);
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
.then(result => result.items);
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
module.exports = { getAllPositions, getPositionsByField, getPositionWithMultiRefField };
|
|
21
|
+
module.exports = {
|
|
22
|
+
getAllPositions,
|
|
23
|
+
getPositionsByField,
|
|
24
|
+
};
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
const { COLLECTIONS,CUSTOM_VALUES_COLLECTION_FIELDS,JOBS_COLLECTION_FIELDS } = require('../backend/collectionConsts');
|
|
2
2
|
const { queryParams} = require('wix-location-frontend');
|
|
3
3
|
const { location } = require("@wix/site-location");
|
|
4
|
-
const {CAREERS_MULTI_BOXES_PAGE_CONSTS,FiltersIds,fieldTitlesInCMS
|
|
5
|
-
const { groupValuesByField, debounce, getAllRecords, getFieldById, getFieldByTitle,getCorrectOption,getOptionIndexFromCheckBox } = require('./pagesUtils');
|
|
4
|
+
const {CAREERS_MULTI_BOXES_PAGE_CONSTS,FiltersIds,fieldTitlesInCMS} = require('../backend/careersMultiBoxesPageIds');
|
|
5
|
+
const { groupValuesByField, debounce, getAllRecords, getFieldById, getFieldByTitle,getCorrectOption,getOptionIndexFromCheckBox,loadPrimarySearchRepeater,bindPrimarySearch,primarySearch } = require('./pagesUtils');
|
|
6
6
|
|
|
7
7
|
let dontUpdateThisCheckBox;
|
|
8
8
|
const selectedByField = new Map(); // fieldId -> array of selected value IDs
|
|
@@ -54,31 +54,6 @@ async function clearAll(_$w) {
|
|
|
54
54
|
}
|
|
55
55
|
|
|
56
56
|
|
|
57
|
-
async function loadPrimarySearchRepeater(_$w) {
|
|
58
|
-
try {
|
|
59
|
-
_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.JOB_RESULTS_REPEATER).onItemReady(async ($item, itemData) => {
|
|
60
|
-
$item(CAREERS_MULTI_BOXES_PAGE_CONSTS.PRIMARY_SEARCH_POSITION_BUTTON).label = itemData.title || '';
|
|
61
|
-
$item(CAREERS_MULTI_BOXES_PAGE_CONSTS.PRIMARY_SEARCH_POSITION_BUTTON).onClick(async () => {
|
|
62
|
-
console.log("primary search position button clicked: ", itemData);
|
|
63
|
-
await location.to(itemData["link-jobs-title"]);
|
|
64
|
-
})
|
|
65
|
-
|
|
66
|
-
});
|
|
67
|
-
|
|
68
|
-
_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.CATEGORY_RESULTS_REPEATER).onItemReady(async ($item, itemData) => {
|
|
69
|
-
$item(CAREERS_MULTI_BOXES_PAGE_CONSTS.PRIMARY_SEARCH_CATEGORY_BUTTON).label = itemData.title || '';
|
|
70
|
-
$item(CAREERS_MULTI_BOXES_PAGE_CONSTS.PRIMARY_SEARCH_CATEGORY_BUTTON).onClick(async () => {
|
|
71
|
-
await clearAll(_$w);
|
|
72
|
-
let encodedCategory=encodeURIComponent(itemData._id);
|
|
73
|
-
queryParams.add({ category:encodedCategory });
|
|
74
|
-
await handleUrlParams(_$w,{category:encodedCategory});
|
|
75
|
-
});
|
|
76
|
-
});
|
|
77
|
-
} catch (error) {
|
|
78
|
-
console.error('Failed to load primary search repeater:', error);
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
|
|
82
57
|
async function handleUrlParams(_$w,urlParams) {
|
|
83
58
|
try {
|
|
84
59
|
let applyFiltering=false;
|
|
@@ -91,7 +66,7 @@ async function handleUrlParams(_$w,urlParams) {
|
|
|
91
66
|
applyFiltering=await handleParams(_$w,"category",urlParams.category)
|
|
92
67
|
}
|
|
93
68
|
if(urlParams.keyword) {
|
|
94
|
-
applyFiltering=await primarySearch(_$w, decodeURIComponent(urlParams.keyword));
|
|
69
|
+
applyFiltering=await primarySearch(_$w, decodeURIComponent(urlParams.keyword), alljobs);
|
|
95
70
|
_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.PRIMARY_SEARCH_INPUT).value=decodeURIComponent(urlParams.keyword);
|
|
96
71
|
keyword=true;
|
|
97
72
|
}
|
|
@@ -485,26 +460,7 @@ async function refreshFacetCounts(_$w,clearAll=false) {
|
|
|
485
460
|
}
|
|
486
461
|
|
|
487
462
|
|
|
488
|
-
async function primarySearch(_$w,query) {
|
|
489
|
-
console.log("primary search query: ", query);
|
|
490
|
-
if(query.length===0 || query===undefined || query==='') {
|
|
491
|
-
_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.PRIMARY_SEARCH_MULTI_BOX).changeState("categoryResults");
|
|
492
|
-
return false;
|
|
493
|
-
}
|
|
494
463
|
|
|
495
|
-
let filteredJobs=alljobs.filter(job=>job.title.toLowerCase().includes(query));
|
|
496
|
-
console.log("filteredJobs.length: ", filteredJobs.length);
|
|
497
|
-
if(filteredJobs.length>0) {
|
|
498
|
-
currentJobs=filteredJobs;
|
|
499
|
-
_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.PRIMARY_SEARCH_MULTI_BOX).changeState("jobResults");
|
|
500
|
-
_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.JOB_RESULTS_REPEATER).data = currentJobs
|
|
501
|
-
return true;
|
|
502
|
-
}
|
|
503
|
-
else {
|
|
504
|
-
_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.PRIMARY_SEARCH_MULTI_BOX).changeState("noResults");
|
|
505
|
-
return false;
|
|
506
|
-
}
|
|
507
|
-
}
|
|
508
464
|
async function secondarySearch(_$w,query) {
|
|
509
465
|
if(query.length===0 || query===undefined || query==='') {
|
|
510
466
|
secondarySearchIsFilled=false;
|
|
@@ -535,80 +491,22 @@ async function secondarySearch(_$w,query) {
|
|
|
535
491
|
}
|
|
536
492
|
async function bindSearchInput(_$w) {
|
|
537
493
|
try {
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
await primarySearch(_$w, query);
|
|
541
|
-
}, 150);
|
|
494
|
+
await bindPrimarySearch(_$w,allvaluesobjects,alljobs);
|
|
495
|
+
|
|
542
496
|
|
|
543
497
|
const secondarySearchDebounced = debounce(async () => {
|
|
544
498
|
const query = (_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.SECONDARY_SEARCH_INPUT).value || '').toLowerCase().trim();
|
|
545
499
|
await secondarySearch(_$w, query);
|
|
546
500
|
}, 150);
|
|
547
501
|
|
|
548
|
-
|
|
549
|
-
await primarySearchDebounced();
|
|
550
|
-
});
|
|
551
|
-
|
|
552
|
-
_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.PRIMARY_SEARCH_INPUT).onClick(async () => {
|
|
553
|
-
_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.RESULTS_CONTAINER).expand();
|
|
554
|
-
if(_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.PRIMARY_SEARCH_INPUT).value.trim()!=='') {
|
|
555
|
-
await primarySearch(_$w, _$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.PRIMARY_SEARCH_INPUT).value.trim());
|
|
556
|
-
}
|
|
557
|
-
else {
|
|
558
|
-
await loadCategoriesListPrimarySearch(_$w);
|
|
559
|
-
}
|
|
560
|
-
});
|
|
561
|
-
|
|
562
|
-
_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.RESULTS_CONTAINER).onMouseOut(async () => {
|
|
563
|
-
_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.RESULTS_CONTAINER).collapse();
|
|
564
|
-
});
|
|
565
|
-
|
|
566
|
-
_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.PRIMARY_SEARCH_INPUT).onKeyPress(async (event) => {
|
|
567
|
-
if( event.key==='Enter') {
|
|
568
|
-
if(_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.PRIMARY_SEARCH_INPUT).value.trim()==='') {
|
|
569
|
-
_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.RESULTS_CONTAINER).collapse();
|
|
570
|
-
await updateJobsAndNumbersAndFilters(_$w);
|
|
571
|
-
|
|
572
|
-
}
|
|
573
|
-
else {
|
|
574
|
-
let encodedKeyWord=encodeURIComponent(_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.PRIMARY_SEARCH_INPUT).value);
|
|
575
|
-
queryParams.add({ keyword:encodedKeyWord });
|
|
576
|
-
handleUrlParams(_$w,{keyword:encodedKeyWord});
|
|
577
|
-
_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.RESULTS_CONTAINER).collapse();
|
|
578
|
-
// await primarySearch(_$w, _$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.PRIMARY_SEARCH_INPUT).value.trim());
|
|
579
|
-
}
|
|
580
|
-
}
|
|
581
|
-
});
|
|
502
|
+
|
|
582
503
|
_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.SECONDARY_SEARCH_INPUT).onInput(secondarySearchDebounced);
|
|
583
504
|
|
|
584
|
-
_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.PRIMARY_SEARCH_BUTTON).onClick(async () => {
|
|
585
|
-
if(_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.PRIMARY_SEARCH_INPUT).value.trim()==='') {
|
|
586
|
-
_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.RESULTS_CONTAINER).collapse();
|
|
587
|
-
await updateJobsAndNumbersAndFilters(_$w);
|
|
588
|
-
}
|
|
589
|
-
else {
|
|
590
|
-
let encodedKeyWord=encodeURIComponent(_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.PRIMARY_SEARCH_INPUT).value);
|
|
591
|
-
queryParams.add({ keyword:encodedKeyWord });
|
|
592
|
-
await primarySearch(_$w, _$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.PRIMARY_SEARCH_INPUT).value.trim());
|
|
593
|
-
_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.RESULTS_CONTAINER).collapse();
|
|
594
|
-
}
|
|
595
|
-
});
|
|
596
505
|
} catch (error) {
|
|
597
506
|
console.error('Failed to bind search input:', error);
|
|
598
507
|
}
|
|
599
508
|
}
|
|
600
509
|
|
|
601
|
-
async function loadCategoriesListPrimarySearch(_$w) {
|
|
602
|
-
_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.PRIMARY_SEARCH_MULTI_BOX).changeState("categoryResults");
|
|
603
|
-
let categoryValues=[]
|
|
604
|
-
for(const value of allvaluesobjects) {
|
|
605
|
-
if(value.customField===CATEGORY_CUSTOM_FIELD_ID_IN_CMS) {
|
|
606
|
-
categoryValues.push({title:value.title+` (${value.totalJobs})` ,_id:value._id});
|
|
607
|
-
}
|
|
608
|
-
}
|
|
609
|
-
console.log("categoryValues: ", categoryValues);
|
|
610
|
-
_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.CATEGORY_RESULTS_REPEATER).data = categoryValues;
|
|
611
|
-
}
|
|
612
510
|
|
|
613
511
|
module.exports = {
|
|
614
512
|
careersMultiBoxesPageOnReady,
|
package/pages/homePage.js
CHANGED
|
@@ -5,12 +5,29 @@ const {
|
|
|
5
5
|
const { handleOnLocationClick } = require('../public/mapUtils');
|
|
6
6
|
const { filterBrokenMarkers } = require('../public/utils');
|
|
7
7
|
const { location } = require('@wix/site-location');
|
|
8
|
+
const {wixData} = require('wix-data');
|
|
9
|
+
const { COLLECTIONS } = require('../backend/collectionConsts');
|
|
10
|
+
const { bindPrimarySearch,getAllRecords,loadPrimarySearchRepeater } = require('./pagesUtils');
|
|
8
11
|
let thisObjectVar;
|
|
9
12
|
let searchByCityFlag=false;
|
|
10
|
-
async function homePageOnReady(_$w,thisObject) {
|
|
13
|
+
async function homePageOnReady(_$w,thisObject=null) {
|
|
14
|
+
|
|
15
|
+
const queryResult = await wixData.query(COLLECTIONS.SITE_CONFIGS).find();
|
|
16
|
+
const siteconfig = queryResult.items[0];
|
|
17
|
+
if(siteconfig.categorySearch==="true") {
|
|
18
|
+
const allJobs=await getAllRecords(COLLECTIONS.JOBS);
|
|
19
|
+
const allvaluesobjects=await getAllRecords(COLLECTIONS.CUSTOM_VALUES);
|
|
20
|
+
await Promise.all([
|
|
21
|
+
bindPrimarySearch(_$w,allvaluesobjects,allJobs),
|
|
22
|
+
loadPrimarySearchRepeater(_$w)
|
|
23
|
+
]);
|
|
24
|
+
}
|
|
25
|
+
else{
|
|
26
|
+
|
|
11
27
|
thisObjectVar=thisObject;
|
|
12
28
|
await bind(_$w);
|
|
13
29
|
await init(_$w);
|
|
30
|
+
}
|
|
14
31
|
|
|
15
32
|
}
|
|
16
33
|
|
package/pages/index.js
CHANGED
package/pages/pagesUtils.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
const { items: wixData } = require('@wix/data');
|
|
2
|
-
const { JOBS_COLLECTION_FIELDS } = require('../backend/collectionConsts');
|
|
2
|
+
const { JOBS_COLLECTION_FIELDS,COLLECTIONS } = require('../backend/collectionConsts');
|
|
3
|
+
const { CAREERS_MULTI_BOXES_PAGE_CONSTS,CATEGORY_CUSTOM_FIELD_ID_IN_CMS } = require('../backend/careersMultiBoxesPageIds');
|
|
4
|
+
const { location } = require("@wix/site-location");
|
|
3
5
|
|
|
4
6
|
function groupValuesByField(values, refKey) {
|
|
5
7
|
const map = new Map();
|
|
@@ -58,6 +60,135 @@ function groupValuesByField(values, refKey) {
|
|
|
58
60
|
}
|
|
59
61
|
}
|
|
60
62
|
|
|
63
|
+
async function loadPrimarySearchRepeater(_$w) {
|
|
64
|
+
try {
|
|
65
|
+
_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.JOB_RESULTS_REPEATER).onItemReady(async ($item, itemData) => {
|
|
66
|
+
$item(CAREERS_MULTI_BOXES_PAGE_CONSTS.PRIMARY_SEARCH_POSITION_BUTTON).label = itemData.title || '';
|
|
67
|
+
$item(CAREERS_MULTI_BOXES_PAGE_CONSTS.PRIMARY_SEARCH_POSITION_BUTTON).onClick(async () => {
|
|
68
|
+
await location.to(itemData["link-jobs-title"]);
|
|
69
|
+
})
|
|
70
|
+
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.CATEGORY_RESULTS_REPEATER).onItemReady(async ($item, itemData) => {
|
|
74
|
+
$item(CAREERS_MULTI_BOXES_PAGE_CONSTS.PRIMARY_SEARCH_CATEGORY_BUTTON).label = itemData.title || '';
|
|
75
|
+
$item(CAREERS_MULTI_BOXES_PAGE_CONSTS.PRIMARY_SEARCH_CATEGORY_BUTTON).onClick(async () => {
|
|
76
|
+
const baseUrl = await location.baseUrl();
|
|
77
|
+
const encodedCategory=encodeURIComponent(itemData._id);
|
|
78
|
+
await location.to(`${baseUrl}/search?category=${encodedCategory}`);
|
|
79
|
+
});
|
|
80
|
+
});
|
|
81
|
+
} catch (error) {
|
|
82
|
+
console.error('Failed to load primary search repeater:', error);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
async function bindPrimarySearch(_$w,allvaluesobjects,alljobs) {
|
|
87
|
+
|
|
88
|
+
const primarySearchDebounced = debounce(async () => {
|
|
89
|
+
const query = (_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.PRIMARY_SEARCH_INPUT).value || '').toLowerCase().trim();
|
|
90
|
+
await primarySearch(_$w, query, alljobs);
|
|
91
|
+
}, 150);
|
|
92
|
+
|
|
93
|
+
_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.PRIMARY_SEARCH_INPUT).onInput(async () => {
|
|
94
|
+
await primarySearchDebounced();
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.PRIMARY_SEARCH_INPUT).onClick(async () => {
|
|
98
|
+
_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.RESULTS_CONTAINER).expand();
|
|
99
|
+
if(_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.PRIMARY_SEARCH_INPUT).value.trim()!=='') {
|
|
100
|
+
await primarySearch(_$w, _$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.PRIMARY_SEARCH_INPUT).value.trim(), alljobs);
|
|
101
|
+
}
|
|
102
|
+
else {
|
|
103
|
+
await loadCategoriesListPrimarySearch(_$w,allvaluesobjects);
|
|
104
|
+
}
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.RESULTS_CONTAINER).onMouseOut(async () => {
|
|
108
|
+
_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.RESULTS_CONTAINER).collapse();
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.PRIMARY_SEARCH_INPUT).onKeyPress(async (event) => {
|
|
112
|
+
if( event.key==='Enter') {
|
|
113
|
+
if(_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.PRIMARY_SEARCH_INPUT).value.trim()==='') {
|
|
114
|
+
_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.RESULTS_CONTAINER).collapse();
|
|
115
|
+
// await updateJobsAndNumbersAndFilters(_$w);
|
|
116
|
+
|
|
117
|
+
}
|
|
118
|
+
else {
|
|
119
|
+
let encodedKeyWord=encodeURIComponent(_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.PRIMARY_SEARCH_INPUT).value);
|
|
120
|
+
const baseUrl = await location.baseUrl();
|
|
121
|
+
await location.to(`${baseUrl}/search?keyword=${encodedKeyWord}`);
|
|
122
|
+
// queryParams.add({ keyword:encodedKeyWord });
|
|
123
|
+
// handleUrlParams(_$w,{keyword:encodedKeyWord});
|
|
124
|
+
// _$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.RESULTS_CONTAINER).collapse();
|
|
125
|
+
// await primarySearch(_$w, _$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.PRIMARY_SEARCH_INPUT).value.trim());
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.PRIMARY_SEARCH_BUTTON).onClick(async () => {
|
|
131
|
+
if(_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.PRIMARY_SEARCH_INPUT).value.trim()==='') {
|
|
132
|
+
_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.RESULTS_CONTAINER).collapse();
|
|
133
|
+
//await updateJobsAndNumbersAndFilters(_$w);
|
|
134
|
+
}
|
|
135
|
+
else {
|
|
136
|
+
let encodedKeyWord=encodeURIComponent(_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.PRIMARY_SEARCH_INPUT).value);
|
|
137
|
+
const baseUrl = await location.baseUrl();
|
|
138
|
+
await location.to(`${baseUrl}/search?keyword=${encodedKeyWord}`);
|
|
139
|
+
// queryParams.add({ keyword:encodedKeyWord });
|
|
140
|
+
// await primarySearch(_$w, _$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.PRIMARY_SEARCH_INPUT).value.trim());
|
|
141
|
+
// _$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.RESULTS_CONTAINER).collapse();
|
|
142
|
+
}
|
|
143
|
+
});
|
|
144
|
+
|
|
145
|
+
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
async function loadCategoriesListPrimarySearch(_$w,allvaluesobjects) {
|
|
149
|
+
_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.PRIMARY_SEARCH_MULTI_BOX).changeState("categoryResults");
|
|
150
|
+
let categoryValues=[]
|
|
151
|
+
for(const value of allvaluesobjects) {
|
|
152
|
+
if(value.customField===CATEGORY_CUSTOM_FIELD_ID_IN_CMS) {
|
|
153
|
+
categoryValues.push({title:value.title+` (${value.totalJobs})` ,_id:value._id});
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.CATEGORY_RESULTS_REPEATER).data = categoryValues;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
async function primarySearch(_$w,query,alljobs) {
|
|
160
|
+
if(query.length===0 || query===undefined || query==='') {
|
|
161
|
+
_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.PRIMARY_SEARCH_MULTI_BOX).changeState("categoryResults");
|
|
162
|
+
return false;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
let filteredJobs=alljobs.filter(job=>job.title.toLowerCase().includes(query));
|
|
166
|
+
if(filteredJobs.length>0) {
|
|
167
|
+
//currentJobs=filteredJobs;
|
|
168
|
+
_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.PRIMARY_SEARCH_MULTI_BOX).changeState("jobResults");
|
|
169
|
+
_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.JOB_RESULTS_REPEATER).data = filteredJobs
|
|
170
|
+
return true;
|
|
171
|
+
}
|
|
172
|
+
else {
|
|
173
|
+
_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.PRIMARY_SEARCH_MULTI_BOX).changeState("noResults");
|
|
174
|
+
return false;
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
async function getValueFromValueId(valueId) {
|
|
179
|
+
const result=await getAllRecords(COLLECTIONS.CUSTOM_VALUES);
|
|
180
|
+
return result.find(value=>value._id===valueId);
|
|
181
|
+
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
async function getLatestJobsByValue(Value) {
|
|
185
|
+
const jobs=Value.multiRefJobsCustomValues;
|
|
186
|
+
const latestJobs = jobs
|
|
187
|
+
.sort((a, b) => new Date(b.releasedDate) - new Date(a.releasedDate))
|
|
188
|
+
.slice(0, 5);
|
|
189
|
+
return latestJobs;
|
|
190
|
+
}
|
|
191
|
+
|
|
61
192
|
module.exports = {
|
|
62
193
|
groupValuesByField,
|
|
63
194
|
debounce,
|
|
@@ -66,4 +197,9 @@ function groupValuesByField(values, refKey) {
|
|
|
66
197
|
getFieldByTitle,
|
|
67
198
|
getCorrectOption,
|
|
68
199
|
getOptionIndexFromCheckBox,
|
|
200
|
+
loadPrimarySearchRepeater,
|
|
201
|
+
bindPrimarySearch,
|
|
202
|
+
primarySearch,
|
|
203
|
+
getLatestJobsByValue,
|
|
204
|
+
getValueFromValueId
|
|
69
205
|
}
|
package/pages/positionPage.js
CHANGED
|
@@ -1,41 +1,20 @@
|
|
|
1
1
|
const { query } = require("wix-location-frontend");
|
|
2
|
-
const { getPositionWithMultiRefField } = require('../backend/queries');
|
|
3
|
-
const { COLLECTIONS,JOBS_COLLECTION_FIELDS,CUSTOM_FIELDS_COLLECTION_FIELDS } = require('../backend/collectionConsts');
|
|
4
|
-
const { items: wixData } = require('@wix/data');
|
|
5
|
-
const { location } = require("@wix/site-location");
|
|
6
2
|
const {
|
|
7
3
|
htmlToText,
|
|
8
4
|
appendQueryParams
|
|
9
5
|
} = require('../public/utils');
|
|
10
6
|
|
|
11
7
|
|
|
12
|
-
|
|
13
|
-
|
|
14
8
|
async function positionPageOnReady(_$w) {
|
|
15
9
|
|
|
16
10
|
await bind(_$w);
|
|
17
|
-
|
|
18
|
-
|
|
19
11
|
|
|
20
12
|
}
|
|
21
13
|
|
|
22
|
-
async function getCategoryValueId(customFields) {
|
|
23
|
-
const categoryCustomField=await wixData.query(COLLECTIONS.CUSTOM_FIELDS).eq(CUSTOM_FIELDS_COLLECTION_FIELDS.TITLE,"Category").find().then(result => result.items[0]);
|
|
24
|
-
for(const field of customFields) {
|
|
25
|
-
if(field.customField===categoryCustomField._id) {
|
|
26
|
-
return field._id;
|
|
27
|
-
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
|
|
33
14
|
async function bind(_$w) {
|
|
34
15
|
_$w('#datasetJobsItem').onReady(async () => {
|
|
35
16
|
|
|
36
17
|
const item = await _$w('#datasetJobsItem').getCurrentItem();
|
|
37
|
-
const multiRefField=await getPositionWithMultiRefField(item._id);
|
|
38
|
-
const categoryValueId=await getCategoryValueId(multiRefField);
|
|
39
18
|
|
|
40
19
|
handleReferFriendButton(_$w,item);
|
|
41
20
|
|
|
@@ -45,39 +24,18 @@ async function getCategoryValueId(customFields) {
|
|
|
45
24
|
_$w('#responsibilitiesText').text = htmlToText(item.jobDescription.jobDescription.text);
|
|
46
25
|
_$w('#qualificationsText').text = htmlToText(item.jobDescription.qualifications.text);
|
|
47
26
|
_$w('#relatedJobsTitleText').text = `More ${item.department} Positions`;
|
|
48
|
-
if(_$w('#additionalInfoText'))
|
|
49
|
-
{
|
|
50
|
-
_$w('#additionalInfoText').text = htmlToText(item.jobDescription.additionalInformation.text);
|
|
51
|
-
}
|
|
52
|
-
if(_$w('#relatedJobsRepNoDepartment')) // when there is no department, we filter based on category
|
|
53
|
-
{
|
|
54
|
-
const relatedJobs=await getRelatedJobs(categoryValueId,item._id);
|
|
55
|
-
_$w('#relatedJobsRepNoDepartment').onItemReady(($item, itemData) => {
|
|
56
|
-
$item('#relatedJobTitle').text = itemData.title;
|
|
57
|
-
$item('#relatedJobLocation').text = itemData.location.fullLocation;
|
|
58
|
-
$item('#relatedJobTitle').onClick(async () => {
|
|
59
|
-
await location.to(itemData["link-jobs-title"]);
|
|
60
|
-
});
|
|
61
|
-
});
|
|
62
|
-
_$w('#relatedJobsRepNoDepartment').data = relatedJobs
|
|
63
|
-
|
|
64
|
-
}
|
|
65
27
|
});
|
|
66
28
|
|
|
67
|
-
if(_$w('#relatedJobsDataset') && _$w('#relatedJobsDataset').length>0)
|
|
68
|
-
{
|
|
69
29
|
_$w('#relatedJobsDataset').onReady(() => {
|
|
70
30
|
const count = _$w('#relatedJobsDataset').getTotalCount();
|
|
71
31
|
if(!count){
|
|
72
32
|
_$w('#relatedJobsSection').collapse();
|
|
73
33
|
}
|
|
74
34
|
});
|
|
75
|
-
}
|
|
76
|
-
|
|
77
35
|
}
|
|
78
36
|
|
|
79
37
|
function handleReferFriendButton(_$w,item) {
|
|
80
|
-
if(!item.referFriendLink
|
|
38
|
+
if(!item.referFriendLink){
|
|
81
39
|
console.log("hiding referFriendButton");
|
|
82
40
|
_$w('#referFriendButton').hide();
|
|
83
41
|
}
|
|
@@ -89,11 +47,6 @@ async function getCategoryValueId(customFields) {
|
|
|
89
47
|
_$w('#applyButton').link=url; //so it can be clicked
|
|
90
48
|
}
|
|
91
49
|
|
|
92
|
-
async function getRelatedJobs(categoryValueId,itemId) {
|
|
93
|
-
const relatedJobs=await wixData.query(COLLECTIONS.JOBS).include(JOBS_COLLECTION_FIELDS.MULTI_REF_JOBS_CUSTOM_VALUES).hasSome(JOBS_COLLECTION_FIELDS.MULTI_REF_JOBS_CUSTOM_VALUES,[categoryValueId]).ne("_id",itemId).find();
|
|
94
|
-
return relatedJobs.items;
|
|
95
|
-
}
|
|
96
|
-
|
|
97
50
|
module.exports = {
|
|
98
51
|
positionPageOnReady,
|
|
99
52
|
};
|
|
@@ -1,21 +1,28 @@
|
|
|
1
|
-
const {
|
|
1
|
+
const { getLatestJobsByValue, getValueFromValueId } = require('./pagesUtils');
|
|
2
2
|
const { location } = require("@wix/site-location");
|
|
3
3
|
const { supportTeamsPageIds } = require('../backend/consts');
|
|
4
4
|
|
|
5
|
-
async function supportTeasmPageOnReady(_$w) {
|
|
6
5
|
|
|
7
|
-
bindRepeater(_$w);
|
|
8
|
-
loadOnClick(_$w)
|
|
9
|
-
}
|
|
10
6
|
|
|
11
|
-
function
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
await location.to(`/search`);
|
|
15
|
-
});
|
|
7
|
+
async function supportTeasmPageOnReady(_$w) {
|
|
8
|
+
handleRecentJobsSection(_$w);
|
|
9
|
+
|
|
16
10
|
}
|
|
17
11
|
|
|
18
|
-
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
async function handleRecentJobsSection(_$w) {
|
|
15
|
+
|
|
16
|
+
const currentItem= _$w(supportTeamsPageIds.TEAM_SUPPORT_DYNAMIC_DATASET).getCurrentItem();
|
|
17
|
+
const valueId=supportTeamsPageIds.valueToValueIdMap[currentItem.title_fld]
|
|
18
|
+
const Value=await getValueFromValueId(valueId);
|
|
19
|
+
const latestsJobs=await getLatestJobsByValue(Value);
|
|
20
|
+
|
|
21
|
+
if(latestsJobs.length === 0) {
|
|
22
|
+
console.log("No jobs found , collapsing recently Jobs Section ");
|
|
23
|
+
await collapseSection(_$w);
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
19
26
|
_$w(supportTeamsPageIds.RECENTLEY_ADDED_JOBS).onItemReady(($item, itemData) => {
|
|
20
27
|
$item(supportTeamsPageIds.JOB_TITLE).text = itemData.title;
|
|
21
28
|
$item(supportTeamsPageIds.JOB_LOCATION).text = itemData.location.fullLocation;
|
|
@@ -23,12 +30,22 @@ async function bindRepeater(_$w) {
|
|
|
23
30
|
await location.to(itemData["link-jobs-title"]);
|
|
24
31
|
})
|
|
25
32
|
});
|
|
26
|
-
|
|
27
|
-
const categoryId=supportTeamsPageIds.valueToCategoryIdMap[obj.title_fld]
|
|
28
|
-
const latestsJobs=await getLatestJobsByCategoryId(categoryId);
|
|
33
|
+
|
|
29
34
|
_$w(supportTeamsPageIds.RECENTLEY_ADDED_JOBS).data = latestsJobs;
|
|
35
|
+
|
|
36
|
+
_$w(supportTeamsPageIds.SEE_ALL_JOBS_TEXT).onClick(async () => {
|
|
37
|
+
await location.to(`/search?category=${Value.title}`);
|
|
38
|
+
});
|
|
30
39
|
}
|
|
31
40
|
|
|
41
|
+
|
|
42
|
+
async function collapseSection(_$w) {
|
|
43
|
+
Promise.all([
|
|
44
|
+
_$w(supportTeamsPageIds.RECENTLY_ADDED_JOBS_SECTION).collapse(),
|
|
45
|
+
_$w(supportTeamsPageIds.MOST_RECENT_JOBS_TITLE).collapse(),
|
|
46
|
+
_$w(supportTeamsPageIds.SEE_ALL_JOBS_TEXT).collapse()
|
|
47
|
+
]);
|
|
48
|
+
}
|
|
32
49
|
module.exports = {
|
|
33
50
|
supportTeasmPageOnReady,
|
|
34
51
|
};
|
package/tests/mockJobBuilder.js
CHANGED
|
@@ -120,67 +120,6 @@ class MockJobBuilder {
|
|
|
120
120
|
return this;
|
|
121
121
|
}
|
|
122
122
|
|
|
123
|
-
withMultiRefCustomValues(categoryIds) {
|
|
124
|
-
this.jobData.multiRefJobsCustomValues = categoryIds;
|
|
125
|
-
return this;
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
withCategory(categoryId) {
|
|
129
|
-
if (!this.jobData.multiRefJobsCustomValues) {
|
|
130
|
-
this.jobData.multiRefJobsCustomValues = [];
|
|
131
|
-
}
|
|
132
|
-
this.jobData.multiRefJobsCustomValues.push(categoryId);
|
|
133
|
-
return this;
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
withDepartment(department) {
|
|
137
|
-
this.jobData.department = department;
|
|
138
|
-
return this;
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
withJobDescription(companyDesc, jobDesc, qualifications, additionalInfo = null) {
|
|
142
|
-
this.jobData.jobDescription = {
|
|
143
|
-
companyDescription: { text: companyDesc },
|
|
144
|
-
jobDescription: { text: jobDesc },
|
|
145
|
-
qualifications: { text: qualifications }
|
|
146
|
-
};
|
|
147
|
-
if (additionalInfo) {
|
|
148
|
-
this.jobData.jobDescription.additionalInformation = { text: additionalInfo };
|
|
149
|
-
}
|
|
150
|
-
return this;
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
withApplyLink(link) {
|
|
154
|
-
this.jobData.applyLink = link;
|
|
155
|
-
return this;
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
withLinkJobsTitle(link) {
|
|
159
|
-
this.jobData['link-jobs-title'] = link;
|
|
160
|
-
return this;
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
forPositionPage() {
|
|
164
|
-
if (!this.jobData._id) {
|
|
165
|
-
this.jobData._id = this.generateId();
|
|
166
|
-
}
|
|
167
|
-
if (!this.jobData.department) {
|
|
168
|
-
this.jobData.department = 'Technology';
|
|
169
|
-
}
|
|
170
|
-
if (!this.jobData.jobDescription) {
|
|
171
|
-
this.withJobDescription(
|
|
172
|
-
'<p>Great company to work for</p>',
|
|
173
|
-
'<p>You will build awesome stuff</p>',
|
|
174
|
-
'<p>Must know how to code</p>',
|
|
175
|
-
'<p>Additional info here</p>'
|
|
176
|
-
);
|
|
177
|
-
}
|
|
178
|
-
if (!this.jobData.applyLink) {
|
|
179
|
-
this.jobData.applyLink = `https://apply.com/${this.jobData.id}`;
|
|
180
|
-
}
|
|
181
|
-
return this;
|
|
182
|
-
}
|
|
183
|
-
|
|
184
123
|
asRemote() {
|
|
185
124
|
this.jobData.location.remote = true;
|
|
186
125
|
return this;
|
|
@@ -237,38 +176,6 @@ class MockJobBuilder {
|
|
|
237
176
|
}
|
|
238
177
|
return jobs;
|
|
239
178
|
}
|
|
240
|
-
|
|
241
|
-
static createJobsWithSameCategory(categoryId, count = 3) {
|
|
242
|
-
const jobs = [];
|
|
243
|
-
const titles = [
|
|
244
|
-
'Frontend Developer', 'Backend Developer', 'Full Stack Engineer',
|
|
245
|
-
'DevOps Engineer', 'QA Engineer', 'Data Scientist',
|
|
246
|
-
'Product Manager', 'UX Designer', 'System Architect'
|
|
247
|
-
];
|
|
248
|
-
const cities = [
|
|
249
|
-
{ city: 'Auckland', region: 'Auckland Region' },
|
|
250
|
-
{ city: 'Wellington', region: 'Wellington Region' },
|
|
251
|
-
{ city: 'Christchurch', region: 'Canterbury Region' },
|
|
252
|
-
{ city: 'Hamilton', region: 'Waikato Region' },
|
|
253
|
-
{ city: 'Dunedin', region: 'Otago Region' }
|
|
254
|
-
];
|
|
255
|
-
|
|
256
|
-
for (let i = 0; i < count; i++) {
|
|
257
|
-
const randomTitle = titles[Math.floor(Math.random() * titles.length)];
|
|
258
|
-
const randomCity = cities[Math.floor(Math.random() * cities.length)];
|
|
259
|
-
|
|
260
|
-
jobs.push(
|
|
261
|
-
new MockJobBuilder()
|
|
262
|
-
.withTitle(`${randomTitle} ${i + 1}`)
|
|
263
|
-
.withCity(randomCity.city, randomCity.region)
|
|
264
|
-
.withCategory(categoryId)
|
|
265
|
-
.withLinkJobsTitle(`/jobs/${randomTitle.toLowerCase().replace(/\s+/g, '-')}-${i + 1}`)
|
|
266
|
-
.forPositionPage()
|
|
267
|
-
.build()
|
|
268
|
-
);
|
|
269
|
-
}
|
|
270
|
-
return jobs;
|
|
271
|
-
}
|
|
272
179
|
}
|
|
273
180
|
|
|
274
181
|
module.exports = MockJobBuilder;
|
|
@@ -28,13 +28,14 @@ Module.prototype.require = function(id) {
|
|
|
28
28
|
};
|
|
29
29
|
|
|
30
30
|
const careersMultiBoxesPage = rewire('../pages/careersMultiBoxesPage');
|
|
31
|
+
const pagesUtils = rewire('../pages/pagesUtils');
|
|
31
32
|
|
|
32
33
|
// Restore original require
|
|
33
34
|
Module.prototype.require = originalRequire;
|
|
34
35
|
|
|
35
36
|
const secondarySearch = careersMultiBoxesPage.__get__('secondarySearch');
|
|
36
|
-
const primarySearch =
|
|
37
|
-
const loadCategoriesListPrimarySearch =
|
|
37
|
+
const primarySearch = pagesUtils.__get__('primarySearch');
|
|
38
|
+
const loadCategoriesListPrimarySearch = pagesUtils.__get__('loadCategoriesListPrimarySearch');
|
|
38
39
|
|
|
39
40
|
|
|
40
41
|
|
|
@@ -165,7 +166,7 @@ describe('primarySearch function tests', () => {
|
|
|
165
166
|
});
|
|
166
167
|
careersMultiBoxesPage.__set__('alljobs', mockJobs);
|
|
167
168
|
|
|
168
|
-
await primarySearch(mockW, 'product');
|
|
169
|
+
await primarySearch(mockW, 'product',mockJobs);
|
|
169
170
|
|
|
170
171
|
expect(mockprimarySearchMultiBox.changeState).toHaveBeenCalledWith('jobResults');
|
|
171
172
|
expect(mockprimarySearcJobResult.data).toHaveLength(11);
|
|
@@ -178,7 +179,7 @@ describe('primarySearch function tests', () => {
|
|
|
178
179
|
});
|
|
179
180
|
careersMultiBoxesPage.__set__('alljobs', mockJobs);
|
|
180
181
|
|
|
181
|
-
await primarySearch(mockW, 'unicorn hunter');
|
|
182
|
+
await primarySearch(mockW, 'unicorn hunter',mockJobs);
|
|
182
183
|
|
|
183
184
|
expect(mockprimarySearchMultiBox.changeState).toHaveBeenCalledWith('noResults');
|
|
184
185
|
expect(mockprimarySearcJobResult.data).toBeNull();
|
|
@@ -193,7 +194,7 @@ describe('primarySearch function tests', () => {
|
|
|
193
194
|
|
|
194
195
|
careersMultiBoxesPage.__set__('allvaluesobjects', mockCategoryValues);
|
|
195
196
|
|
|
196
|
-
await loadCategoriesListPrimarySearch(mockW);
|
|
197
|
+
await loadCategoriesListPrimarySearch(mockW,mockCategoryValues);
|
|
197
198
|
|
|
198
199
|
expect(mockprimarySearchMultiBox.changeState).toHaveBeenCalledWith('categoryResults');
|
|
199
200
|
expect(mockCategoryResultsRepeater.data).toHaveLength(3);
|
package/pages/brandPage.js
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
const { location } = require("@wix/site-location");
|
|
3
|
-
async function brandPageOnReady(_$w,brand) {
|
|
4
|
-
const decodedBrand = decodeURIComponent(brand);
|
|
5
|
-
_$w('#seeJobsButton').onClick(async () => {
|
|
6
|
-
await location.to(`/search?brand=${decodedBrand}`);
|
|
7
|
-
});
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
module.exports = {
|
|
11
|
-
brandPageOnReady,
|
|
12
|
-
};
|
|
@@ -1,139 +0,0 @@
|
|
|
1
|
-
const MockJobBuilder = require('./mockJobBuilder');
|
|
2
|
-
|
|
3
|
-
// Create mocks before importing
|
|
4
|
-
const mockQueryChain = {
|
|
5
|
-
eq: jest.fn().mockReturnThis(),
|
|
6
|
-
find: jest.fn(),
|
|
7
|
-
include: jest.fn().mockReturnThis(),
|
|
8
|
-
hasSome: jest.fn().mockReturnThis(),
|
|
9
|
-
ne: jest.fn().mockReturnThis(),
|
|
10
|
-
limit: jest.fn().mockReturnThis(),
|
|
11
|
-
then: jest.fn()
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
const mockWixData = {
|
|
15
|
-
query: jest.fn(() => mockQueryChain),
|
|
16
|
-
queryReferenced: jest.fn()
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
jest.mock('wix-location-frontend', () => ({
|
|
20
|
-
query: {}
|
|
21
|
-
}), { virtual: true });
|
|
22
|
-
jest.mock('@wix/data', () => ({
|
|
23
|
-
items: mockWixData
|
|
24
|
-
}));
|
|
25
|
-
jest.mock('@wix/site-location', () => ({
|
|
26
|
-
location: {
|
|
27
|
-
to: jest.fn()
|
|
28
|
-
}
|
|
29
|
-
}));
|
|
30
|
-
|
|
31
|
-
// Mock the backend queries module as well
|
|
32
|
-
jest.mock('../backend/queries', () => ({
|
|
33
|
-
getPositionWithMultiRefField: jest.fn()
|
|
34
|
-
}));
|
|
35
|
-
|
|
36
|
-
// Mock utils
|
|
37
|
-
jest.mock('../public/utils', () => ({
|
|
38
|
-
htmlToText: jest.fn((text) => text.replace(/<[^>]*>/g, '')),
|
|
39
|
-
appendQueryParams: jest.fn((url) => url)
|
|
40
|
-
}));
|
|
41
|
-
|
|
42
|
-
const { positionPageOnReady } = require('../pages/positionPage');
|
|
43
|
-
const { getPositionWithMultiRefField } = require('../backend/queries');
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
describe('related jobs show jobs with the same category value test', () => {
|
|
47
|
-
let mockW;
|
|
48
|
-
let mockRealtedJobsRepeater;
|
|
49
|
-
|
|
50
|
-
beforeEach(() => {
|
|
51
|
-
// Create a proper repeater mock that allows data to be set
|
|
52
|
-
mockRealtedJobsRepeater = {
|
|
53
|
-
data: null,
|
|
54
|
-
onItemReady: jest.fn()
|
|
55
|
-
};
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
it('should show related jobs with the same category value', async () => {
|
|
59
|
-
const CATEGORY_FIELD_ID = `category-field-${Date.now()}`;
|
|
60
|
-
const TECH_CATEGORY_VALUE_ID = `tech-category-${Math.floor(Math.random() * 10000)}`;
|
|
61
|
-
|
|
62
|
-
// Create current job using MockJobBuilder with random data
|
|
63
|
-
const currentJob = new MockJobBuilder()
|
|
64
|
-
.withTitle('Senior Developer')
|
|
65
|
-
.withDepartment('Technology')
|
|
66
|
-
.withCategory(TECH_CATEGORY_VALUE_ID)
|
|
67
|
-
.forPositionPage()
|
|
68
|
-
.build();
|
|
69
|
-
|
|
70
|
-
// Create 0-5 related jobs with same category using random data (including case with 0 related jobs)
|
|
71
|
-
const relatedJobsCount = Math.floor(Math.random() * 6); // 0-5 jobs
|
|
72
|
-
const relatedJobs = MockJobBuilder.createJobsWithSameCategory(
|
|
73
|
-
TECH_CATEGORY_VALUE_ID,
|
|
74
|
-
relatedJobsCount
|
|
75
|
-
);
|
|
76
|
-
|
|
77
|
-
// Current job's custom values (Tech category)
|
|
78
|
-
const currentJobCustomValues = [
|
|
79
|
-
{ _id: TECH_CATEGORY_VALUE_ID, customField: CATEGORY_FIELD_ID, title: 'Technology' }
|
|
80
|
-
];
|
|
81
|
-
|
|
82
|
-
const categoryCustomField = {
|
|
83
|
-
_id: CATEGORY_FIELD_ID,
|
|
84
|
-
title: 'Category'
|
|
85
|
-
};
|
|
86
|
-
|
|
87
|
-
// Setup mocks - capture the onReady callback so we can await it
|
|
88
|
-
let datasetReadyCallback;
|
|
89
|
-
const mockDataset = {
|
|
90
|
-
onReady: jest.fn((callback) => {
|
|
91
|
-
datasetReadyCallback = callback;
|
|
92
|
-
}),
|
|
93
|
-
getCurrentItem: jest.fn().mockResolvedValue(currentJob)
|
|
94
|
-
};
|
|
95
|
-
|
|
96
|
-
mockW = jest.fn((selector) => {
|
|
97
|
-
const mocks = {
|
|
98
|
-
'#datasetJobsItem': mockDataset,
|
|
99
|
-
'#relatedJobsRepNoDepartment': mockRealtedJobsRepeater,
|
|
100
|
-
'#companyDescriptionText': { text: '' },
|
|
101
|
-
'#responsibilitiesText': { text: '' },
|
|
102
|
-
'#qualificationsText': { text: '' },
|
|
103
|
-
'#relatedJobsTitleText': { text: '' },
|
|
104
|
-
'#additionalInfoText': { text: '' },
|
|
105
|
-
'#applyButton': { target: '', link: '' }
|
|
106
|
-
};
|
|
107
|
-
return mocks[selector] || { text: '', hide: jest.fn() };
|
|
108
|
-
});
|
|
109
|
-
|
|
110
|
-
getPositionWithMultiRefField.mockResolvedValue(currentJobCustomValues);
|
|
111
|
-
|
|
112
|
-
mockQueryChain.find.mockImplementation(() => {
|
|
113
|
-
const queryArg = mockWixData.query.mock.calls[mockWixData.query.mock.calls.length - 1][0];
|
|
114
|
-
if (queryArg === 'CustomFields') {
|
|
115
|
-
return Promise.resolve({ items: [categoryCustomField] });
|
|
116
|
-
}
|
|
117
|
-
return Promise.resolve({ items: relatedJobs });
|
|
118
|
-
});
|
|
119
|
-
|
|
120
|
-
// Run the page function (sets up the onReady callback)
|
|
121
|
-
await positionPageOnReady(mockW);
|
|
122
|
-
|
|
123
|
-
// Now execute the dataset onReady callback and wait for it
|
|
124
|
-
await datasetReadyCallback();
|
|
125
|
-
|
|
126
|
-
// Verify the repeater got populated with related jobs
|
|
127
|
-
expect(mockRealtedJobsRepeater.data).not.toBeNull();
|
|
128
|
-
expect(mockRealtedJobsRepeater.data).toHaveLength(relatedJobsCount);
|
|
129
|
-
|
|
130
|
-
// Verify all related jobs have the same category as current job
|
|
131
|
-
const allHaveSameCategory = mockRealtedJobsRepeater.data.every(job =>
|
|
132
|
-
job.multiRefJobsCustomValues &&
|
|
133
|
-
job.multiRefJobsCustomValues.includes(TECH_CATEGORY_VALUE_ID)
|
|
134
|
-
);
|
|
135
|
-
expect(allHaveSameCategory).toBe(true);
|
|
136
|
-
});
|
|
137
|
-
|
|
138
|
-
});
|
|
139
|
-
|