sr-npm 3.0.0 → 3.0.2
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/.github/workflows/update-sites.yml +17 -17
- package/backend/careersMultiBoxesPageIds.js +77 -0
- package/backend/collectionConsts.js +43 -1
- package/backend/consts.js +68 -14
- package/backend/data.js +164 -29
- package/backend/fetchPositionsFromSRAPI.js +2 -1
- package/backend/index.js +2 -0
- package/backend/queries.js +9 -5
- package/backend/secretsData.js +3 -3
- package/backend/utils.js +2 -1
- package/eslint.config.mjs +26 -0
- package/package.json +8 -3
- package/pages/boardPeoplePage.js +28 -0
- package/pages/brandPage.js +12 -0
- package/pages/careersMultiBoxesPage.js +622 -0
- package/pages/careersPage.js +120 -102
- package/pages/homePage.js +79 -8
- package/pages/index.js +6 -0
- package/pages/masterPage.js +35 -0
- package/pages/pagesUtils.js +241 -0
- package/pages/positionPage.js +93 -7
- package/pages/supportTeamsPage.js +92 -0
- package/public/selectors.js +53 -0
- package/public/utils.js +2 -1
- package/tests/brandPageTest.spec.js +45 -0
- package/tests/mockJobBuilder.js +290 -0
- package/tests/multiSearchBoxCareers.spec.js +394 -0
- package/tests/positionPageTest.spec.js +140 -0
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
const { items: wixData } = require('@wix/data');
|
|
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");
|
|
5
|
+
const { normalizeString } = require('../backend/utils');
|
|
6
|
+
|
|
7
|
+
function groupValuesByField(values, refKey) {
|
|
8
|
+
const map = new Map();
|
|
9
|
+
for (const v of values) {
|
|
10
|
+
const ref = v[refKey]; // should be the _id of the CustomFields item
|
|
11
|
+
if (!map.has(ref)) map.set(ref, []);
|
|
12
|
+
map.get(ref).push({
|
|
13
|
+
label: v.title ,
|
|
14
|
+
value: v._id
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
return map;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const debounce = (fn, ms = 150) => {
|
|
21
|
+
let t;
|
|
22
|
+
return (...args) => {
|
|
23
|
+
clearTimeout(t);
|
|
24
|
+
t = setTimeout(() => fn(...args), ms);
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
async function getAllRecords(collectionId) {
|
|
29
|
+
const q = wixData.query(collectionId).include(JOBS_COLLECTION_FIELDS.MULTI_REF_JOBS_CUSTOM_VALUES)
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
const items = [];
|
|
33
|
+
let res = await q.limit(1000).find();
|
|
34
|
+
items.push(...res.items);
|
|
35
|
+
|
|
36
|
+
while (res.hasNext()) {
|
|
37
|
+
res = await res.next();
|
|
38
|
+
items.push(...res.items);
|
|
39
|
+
}
|
|
40
|
+
return items;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
async function getAllRecordsWithoutMultiRef(collectionId) {
|
|
44
|
+
const q = wixData.query(collectionId)
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
const items = [];
|
|
48
|
+
let res = await q.limit(1000).find();
|
|
49
|
+
items.push(...res.items);
|
|
50
|
+
|
|
51
|
+
while (res.hasNext()) {
|
|
52
|
+
res = await res.next();
|
|
53
|
+
items.push(...res.items);
|
|
54
|
+
}
|
|
55
|
+
return items;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
function getFieldById(fieldId,allFields) {
|
|
59
|
+
return allFields.find(field=>field._id===fieldId);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
function getFieldByTitle(title,allFields) {
|
|
63
|
+
return allFields.find(field=>field.title===title);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
function getCorrectOption(value,options,param) {
|
|
67
|
+
const standardizedValue = normalizeString(value.toLowerCase())
|
|
68
|
+
if(param==="employmenttype") //employmenttype have a problematic value
|
|
69
|
+
{
|
|
70
|
+
return options.find(option=>normalizeString(option.value.toLowerCase())===standardizedValue);
|
|
71
|
+
}
|
|
72
|
+
return options.find(option=>normalizeString(option.label.toLowerCase())===standardizedValue);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
function getOptionIndexFromCheckBox(options,value) {
|
|
76
|
+
const normalizedValue=normalizeString(value.toLowerCase());
|
|
77
|
+
for(let index=0;index<options.length;index++) {
|
|
78
|
+
if(normalizeString(options[index].value.toLowerCase())===normalizedValue) {
|
|
79
|
+
return index;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
function loadPrimarySearchRepeater(_$w) {
|
|
85
|
+
|
|
86
|
+
_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.JOB_RESULTS_REPEATER).onItemReady(async ($item, itemData) => {
|
|
87
|
+
$item(CAREERS_MULTI_BOXES_PAGE_CONSTS.PRIMARY_SEARCH_POSITION_BUTTON).label = itemData.title || '';
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.JOB_RESULTS_REPEATER_ITEM).onClick((event) => {
|
|
91
|
+
const data = _$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.JOB_RESULTS_REPEATER).data;
|
|
92
|
+
const clickedItemData = data.find(
|
|
93
|
+
(item) => item._id === event.context.itemId,
|
|
94
|
+
|
|
95
|
+
);
|
|
96
|
+
console.log("clickedItemData: ",clickedItemData);
|
|
97
|
+
console.log("clickedItemData['link-jobs-title']: ",clickedItemData["link-jobs-title"]);
|
|
98
|
+
location.to(clickedItemData["link-jobs-title"]);
|
|
99
|
+
});
|
|
100
|
+
_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.CATEGORY_RESULTS_REPEATER).onItemReady(async ($item, itemData) => {
|
|
101
|
+
$item(CAREERS_MULTI_BOXES_PAGE_CONSTS.PRIMARY_SEARCH_CATEGORY_BUTTON).label = itemData.title || '';
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.CATEGORY_RESULTS_REPEATER_ITEM).onClick(async (event) => {
|
|
105
|
+
const data = _$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.CATEGORY_RESULTS_REPEATER).data;
|
|
106
|
+
const clickedItemData = data.find(
|
|
107
|
+
(item) => item._id === event.context.itemId,
|
|
108
|
+
);
|
|
109
|
+
const baseUrl = await location.baseUrl();
|
|
110
|
+
const encodedCategory=encodeURIComponent(clickedItemData._id);
|
|
111
|
+
location.to(`${baseUrl}/search?category=${encodedCategory}`);
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
function bindPrimarySearch(_$w,allvaluesobjects,alljobs) {
|
|
117
|
+
|
|
118
|
+
const primarySearchDebounced = debounce(async () => {
|
|
119
|
+
const query = (_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.PRIMARY_SEARCH_INPUT).value || '').toLowerCase().trim();
|
|
120
|
+
await primarySearch(_$w, query, alljobs);
|
|
121
|
+
}, 300);
|
|
122
|
+
|
|
123
|
+
_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.PRIMARY_SEARCH_INPUT).onInput(async () => {
|
|
124
|
+
await primarySearchDebounced();
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.PRIMARY_SEARCH_INPUT).onClick(async () => {
|
|
128
|
+
_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.RESULTS_CONTAINER).expand();
|
|
129
|
+
if(_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.PRIMARY_SEARCH_INPUT).value.trim()!=='') {
|
|
130
|
+
await primarySearch(_$w, _$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.PRIMARY_SEARCH_INPUT).value.trim(), alljobs);
|
|
131
|
+
}
|
|
132
|
+
else {
|
|
133
|
+
await loadCategoriesListPrimarySearch(_$w,allvaluesobjects);
|
|
134
|
+
}
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.RESULTS_CONTAINER).onMouseOut(async () => {
|
|
138
|
+
_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.RESULTS_CONTAINER).collapse();
|
|
139
|
+
});
|
|
140
|
+
|
|
141
|
+
_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.PRIMARY_SEARCH_INPUT).onKeyPress(async (event) => {
|
|
142
|
+
if( event.key==='Enter') {
|
|
143
|
+
console.log("primary search input key pressed");
|
|
144
|
+
console.log("_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.PRIMARY_SEARCH_INPUT).value: ",_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.PRIMARY_SEARCH_INPUT).value);
|
|
145
|
+
if(_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.PRIMARY_SEARCH_INPUT).value.trim()==='') {
|
|
146
|
+
// _$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.RESULTS_CONTAINER).collapse();
|
|
147
|
+
const baseUrl = await location.baseUrl();
|
|
148
|
+
location.to(`${baseUrl}/search`);
|
|
149
|
+
|
|
150
|
+
}
|
|
151
|
+
else {
|
|
152
|
+
let encodedKeyWord=encodeURIComponent(_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.PRIMARY_SEARCH_INPUT).value);
|
|
153
|
+
const baseUrl = await location.baseUrl();
|
|
154
|
+
location.to(`${baseUrl}/search?keyword=${encodedKeyWord}`);
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
});
|
|
158
|
+
|
|
159
|
+
_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.PRIMARY_SEARCH_BUTTON).onClick(async () => {
|
|
160
|
+
console.log("primary search button clicked");
|
|
161
|
+
console.log("_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.PRIMARY_SEARCH_INPUT).value: ",_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.PRIMARY_SEARCH_INPUT).value);
|
|
162
|
+
if(_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.PRIMARY_SEARCH_INPUT).value.trim()==='') {
|
|
163
|
+
const baseUrl = await location.baseUrl();
|
|
164
|
+
location.to(`${baseUrl}/search`);
|
|
165
|
+
}
|
|
166
|
+
else {
|
|
167
|
+
let encodedKeyWord=encodeURIComponent(_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.PRIMARY_SEARCH_INPUT).value);
|
|
168
|
+
const baseUrl = await location.baseUrl();
|
|
169
|
+
location.to(`${baseUrl}/search?keyword=${encodedKeyWord}`);
|
|
170
|
+
}
|
|
171
|
+
});
|
|
172
|
+
|
|
173
|
+
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
async function loadCategoriesListPrimarySearch(_$w,allvaluesobjects) {
|
|
177
|
+
_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.PRIMARY_SEARCH_MULTI_BOX).changeState("categoryResults");
|
|
178
|
+
let categoryValues=[]
|
|
179
|
+
for(const value of allvaluesobjects) {
|
|
180
|
+
if(value.customField===CATEGORY_CUSTOM_FIELD_ID_IN_CMS) {
|
|
181
|
+
categoryValues.push({title:value.title+` (${value.count})` ,_id:value._id});
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.CATEGORY_RESULTS_REPEATER).data = categoryValues;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
async function primarySearch(_$w,query,alljobs) {
|
|
188
|
+
if(query.length===0 || query===undefined || query==='') {
|
|
189
|
+
_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.PRIMARY_SEARCH_MULTI_BOX).changeState("categoryResults");
|
|
190
|
+
return false;
|
|
191
|
+
}
|
|
192
|
+
let filteredJobs=alljobs.filter(job=>job.title.toLowerCase().includes(query));
|
|
193
|
+
if(filteredJobs.length>0) {
|
|
194
|
+
_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.PRIMARY_SEARCH_MULTI_BOX).changeState("jobResults");
|
|
195
|
+
}
|
|
196
|
+
else {
|
|
197
|
+
console.log("searching by location")
|
|
198
|
+
filteredJobs=alljobs.filter(job=>job.location.fullLocation.toLowerCase().includes(query));
|
|
199
|
+
if(filteredJobs.length>0) {
|
|
200
|
+
_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.PRIMARY_SEARCH_MULTI_BOX).changeState("jobResults");
|
|
201
|
+
}
|
|
202
|
+
else{
|
|
203
|
+
_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.PRIMARY_SEARCH_MULTI_BOX).changeState("noResults");
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.JOB_RESULTS_REPEATER).data = filteredJobs
|
|
207
|
+
return filteredJobs.length>0;
|
|
208
|
+
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
async function getValueFromValueId(valueId) {
|
|
212
|
+
const result=await getAllRecords(COLLECTIONS.CUSTOM_VALUES);
|
|
213
|
+
console.log("result: ",result);
|
|
214
|
+
console.log("valueId: ",valueId);
|
|
215
|
+
return result.find(value=>value._id===valueId);
|
|
216
|
+
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
async function getLatestJobsByValue(Value) {
|
|
220
|
+
const jobs=Value.multiRefJobsCustomValues;
|
|
221
|
+
const latestJobs = jobs
|
|
222
|
+
.sort((a, b) => new Date(b.releasedDate) - new Date(a.releasedDate))
|
|
223
|
+
.slice(0, 5);
|
|
224
|
+
return latestJobs;
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
module.exports = {
|
|
228
|
+
groupValuesByField,
|
|
229
|
+
debounce,
|
|
230
|
+
getAllRecords,
|
|
231
|
+
getFieldById,
|
|
232
|
+
getFieldByTitle,
|
|
233
|
+
getCorrectOption,
|
|
234
|
+
getOptionIndexFromCheckBox,
|
|
235
|
+
loadPrimarySearchRepeater,
|
|
236
|
+
bindPrimarySearch,
|
|
237
|
+
primarySearch,
|
|
238
|
+
getLatestJobsByValue,
|
|
239
|
+
getValueFromValueId,
|
|
240
|
+
getAllRecordsWithoutMultiRef
|
|
241
|
+
}
|
package/pages/positionPage.js
CHANGED
|
@@ -1,50 +1,136 @@
|
|
|
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
|
+
const{isElementExistOnPage} = require('psdev-utils');
|
|
2
7
|
const {
|
|
3
8
|
htmlToText,
|
|
4
9
|
appendQueryParams
|
|
5
10
|
} = require('../public/utils');
|
|
6
11
|
|
|
7
12
|
|
|
13
|
+
|
|
14
|
+
|
|
8
15
|
async function positionPageOnReady(_$w) {
|
|
9
16
|
|
|
10
17
|
await bind(_$w);
|
|
18
|
+
|
|
19
|
+
|
|
11
20
|
|
|
12
21
|
}
|
|
13
22
|
|
|
23
|
+
async function getCategoryValue(customValues) {
|
|
24
|
+
const categoryCustomField=await wixData.query(COLLECTIONS.CUSTOM_FIELDS).eq(CUSTOM_FIELDS_COLLECTION_FIELDS.TITLE,"Category").find().then(result => result.items[0]);
|
|
25
|
+
for(const value of customValues) {
|
|
26
|
+
if(value.customField===categoryCustomField._id) {
|
|
27
|
+
return value;
|
|
28
|
+
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
|
|
14
34
|
async function bind(_$w) {
|
|
15
35
|
_$w('#datasetJobsItem').onReady(async () => {
|
|
16
36
|
|
|
17
37
|
const item = await _$w('#datasetJobsItem').getCurrentItem();
|
|
38
|
+
console.log("item: ",item);
|
|
18
39
|
|
|
19
40
|
handleReferFriendButton(_$w,item);
|
|
20
|
-
|
|
21
41
|
handleApplyButton(_$w,item);
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
|
|
22
45
|
|
|
23
46
|
_$w('#companyDescriptionText').text = htmlToText(item.jobDescription.companyDescription.text);
|
|
24
47
|
_$w('#responsibilitiesText').text = htmlToText(item.jobDescription.jobDescription.text);
|
|
25
48
|
_$w('#qualificationsText').text = htmlToText(item.jobDescription.qualifications.text);
|
|
26
49
|
_$w('#relatedJobsTitleText').text = `More ${item.department} Positions`;
|
|
27
|
-
|
|
50
|
+
if(isElementExistOnPage(_$w('#additionalInfoText')))
|
|
51
|
+
{
|
|
52
|
+
_$w('#additionalInfoText').text = htmlToText(item.jobDescription.additionalInformation.text);
|
|
53
|
+
}
|
|
54
|
+
if(isElementExistOnPage(_$w('#relatedJobsRepNoDepartment'))) // when there is no department, we filter based on category
|
|
55
|
+
{
|
|
56
|
+
|
|
57
|
+
const multiRefField=await getPositionWithMultiRefField(item._id);
|
|
58
|
+
const categoryValue=await getCategoryValue(multiRefField);
|
|
59
|
+
|
|
60
|
+
if(isElementExistOnPage(_$w('#jobCategory'))) {
|
|
61
|
+
_$w('#jobCategory').text = categoryValue.title;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
const relatedJobs = await getRelatedJobs({ categoryValueId:categoryValue._id, itemId: item._id ,limit:5});
|
|
65
|
+
_$w('#relatedJobsRepNoDepartment').onItemReady(($item, itemData) => {
|
|
66
|
+
$item('#relatedJobTitle').text = itemData.title;
|
|
67
|
+
$item('#relatedJobLocation').text = itemData.location.fullLocation;
|
|
68
|
+
});
|
|
69
|
+
_$w('#relatedJobsRepNoDepartment').data = relatedJobs;
|
|
28
70
|
|
|
71
|
+
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
if(isElementExistOnPage(_$w('#relatedJobsRepNoDepartment'))) {
|
|
75
|
+
_$w('#relatedJobsNoDepartmentItem').onClick((event) => {
|
|
76
|
+
const data = _$w("#relatedJobsRepNoDepartment").data;
|
|
77
|
+
const clickedItemData = data.find(
|
|
78
|
+
(item) => item._id === event.context.itemId,
|
|
79
|
+
);
|
|
80
|
+
location.to(clickedItemData["link-jobs-title"]);
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
if(isElementExistOnPage(_$w('#relatedJobsDataset')))
|
|
84
|
+
{
|
|
29
85
|
_$w('#relatedJobsDataset').onReady(() => {
|
|
30
86
|
const count = _$w('#relatedJobsDataset').getTotalCount();
|
|
31
87
|
if(!count){
|
|
32
88
|
_$w('#relatedJobsSection').collapse();
|
|
33
89
|
}
|
|
34
90
|
});
|
|
91
|
+
}
|
|
92
|
+
|
|
35
93
|
}
|
|
36
|
-
|
|
94
|
+
|
|
37
95
|
function handleReferFriendButton(_$w,item) {
|
|
38
|
-
if(!item.referFriendLink){
|
|
39
|
-
console.log("hiding referFriendButton");
|
|
96
|
+
if(!item.referFriendLink && isElementExistOnPage(_$w('#referFriendButton'))){
|
|
40
97
|
_$w('#referFriendButton').hide();
|
|
41
98
|
}
|
|
42
99
|
}
|
|
43
100
|
|
|
44
101
|
function handleApplyButton(_$w,item) {
|
|
102
|
+
try{
|
|
45
103
|
_$w('#applyButton').target="_blank";//so it can open in new tab
|
|
46
|
-
|
|
47
|
-
|
|
104
|
+
|
|
105
|
+
const url=buildApplyLinkWithQueryParams(item.applyLink,query);
|
|
106
|
+
_$w('#applyButton').link=url; //so it can be clicked
|
|
107
|
+
}
|
|
108
|
+
catch(error){
|
|
109
|
+
console.warn("error in handleApplyButton: , using applyLink directly", error);
|
|
110
|
+
_$w('#applyButton').target="_blank";
|
|
111
|
+
_$w('#applyButton').link=item.applyLink;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
function buildApplyLinkWithQueryParams(url, query) {
|
|
116
|
+
if (!url || typeof url !== 'string' || !url.startsWith('http')) {
|
|
117
|
+
console.warn(`Invalid URL ${url}, button link will not be set`);
|
|
118
|
+
return null;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
if (!query || typeof query !== 'object') {
|
|
122
|
+
console.warn(`Invalid query params ${query}, button link will not be set`);
|
|
123
|
+
return null;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
return appendQueryParams(url, query);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
async function getRelatedJobs({ categoryValueId, itemId, limit = 1000 }) {
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
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).limit(limit).find();
|
|
133
|
+
return relatedJobs.items;
|
|
48
134
|
}
|
|
49
135
|
|
|
50
136
|
module.exports = {
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
const { getLatestJobsByValue, getValueFromValueId } = require('./pagesUtils');
|
|
2
|
+
const { location } = require("@wix/site-location");
|
|
3
|
+
const { supportTeamsPageIds,supportTeamsPageSections } = require('../backend/consts');
|
|
4
|
+
const { getAllRecordsWithoutMultiRef } = require('./pagesUtils');
|
|
5
|
+
|
|
6
|
+
let currentItem;
|
|
7
|
+
async function supportTeasmPageOnReady(_$w) {
|
|
8
|
+
currentItem= _$w(supportTeamsPageIds.TEAM_SUPPORT_DYNAMIC_DATASET).getCurrentItem();
|
|
9
|
+
Promise.all([handleRecentJobsSection(_$w),handlePeopleSection(_$w),handleVideoSection(_$w)]);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
async function handleVideoSection(_$w) {
|
|
13
|
+
if(!currentItem.videoExists) {
|
|
14
|
+
console.log("Video does not exist , collapsing video section ");
|
|
15
|
+
await collapseSection(_$w,supportTeamsPageSections.VIDEO);
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
async function handlePeopleSection(_$w) {
|
|
22
|
+
const allpeoplesrecord=await getAllRecordsWithoutMultiRef("OurPeople");
|
|
23
|
+
const peopleToDisplay=allpeoplesrecord.filter(person=>person.supportTeamName===currentItem._id);
|
|
24
|
+
|
|
25
|
+
if(peopleToDisplay.length === 0) {
|
|
26
|
+
console.log("No people found , collapsing people section ");
|
|
27
|
+
await collapseSection(_$w,supportTeamsPageSections.PEOPLE);
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
async function handleRecentJobsSection(_$w) {
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
if(supportTeamsPageIds.excludeValues.has(currentItem.title_fld)) {
|
|
38
|
+
console.log("Value is excluded , collapsing recently Jobs Section ");
|
|
39
|
+
await collapseSection(_$w,supportTeamsPageSections.RECENT_JOBS);
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
const valueId=supportTeamsPageIds.valueToValueIdMap[currentItem.title_fld]
|
|
43
|
+
const Value=await getValueFromValueId(valueId);
|
|
44
|
+
if(Value===undefined) {
|
|
45
|
+
console.log("Value is undefined , collapsing recently Jobs Section ");
|
|
46
|
+
await collapseSection(_$w,supportTeamsPageSections.RECENT_JOBS);
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
const latestsJobs=await getLatestJobsByValue(Value);
|
|
50
|
+
|
|
51
|
+
_$w(supportTeamsPageIds.RECENT_JOBS_REPEATER).onItemReady(($item, itemData) => {
|
|
52
|
+
$item(supportTeamsPageIds.JOB_TITLE).text = itemData.title;
|
|
53
|
+
$item(supportTeamsPageIds.JOB_LOCATION).text = itemData.location.fullLocation;
|
|
54
|
+
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
_$w(supportTeamsPageIds.RECENT_JOBS_REPEATER).data = latestsJobs;
|
|
58
|
+
_$w(supportTeamsPageIds.RECENTLEY_ADDED_JOBS_ITEM).onClick((event) => {
|
|
59
|
+
const data = _$w(supportTeamsPageIds.RECENT_JOBS_REPEATER).data;
|
|
60
|
+
const clickedItemData = data.find(
|
|
61
|
+
(item) => item._id === event.context.itemId,
|
|
62
|
+
);
|
|
63
|
+
location.to(clickedItemData["link-jobs-title"]);
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
_$w(supportTeamsPageIds.RECENT_JOBS_BUTTON).onClick( () => {
|
|
67
|
+
location.to(`/search?category=${Value.title}`);
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
async function collapseSection(_$w,sectionName) {
|
|
72
|
+
if(sectionName === supportTeamsPageSections.PEOPLE) {
|
|
73
|
+
await _$w(supportTeamsPageIds.PEOPLE_BUTTON).collapse();
|
|
74
|
+
await _$w(supportTeamsPageIds.PEOPLE_TITLE).collapse();
|
|
75
|
+
await _$w(supportTeamsPageIds.PEOPLE_REPEATER).collapse();
|
|
76
|
+
}
|
|
77
|
+
else if(sectionName === supportTeamsPageSections.VIDEO) {
|
|
78
|
+
await _$w(supportTeamsPageIds.VIDEO_TITLE).collapse();
|
|
79
|
+
await _$w(supportTeamsPageIds.VIDEO_PLAYER).collapse();
|
|
80
|
+
await _$w(supportTeamsPageIds.VIDEO_SECTION).collapse();
|
|
81
|
+
}
|
|
82
|
+
else {
|
|
83
|
+
if(sectionName === supportTeamsPageSections.RECENT_JOBS) {
|
|
84
|
+
await _$w(supportTeamsPageIds.RECENT_JOBS_TITLE).collapse()
|
|
85
|
+
await _$w(supportTeamsPageIds.RECENT_JOBS_BUTTON).collapse()
|
|
86
|
+
await _$w(supportTeamsPageIds.RECENT_JOBS_SECTION).collapse()
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
module.exports = {
|
|
91
|
+
supportTeasmPageOnReady,
|
|
92
|
+
};
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
const CAREERS_PAGE_SELECTORS = {
|
|
2
|
+
FILTER_ICON: '#filterIcon',
|
|
3
|
+
FILTER_BOX: '#filterBox',
|
|
4
|
+
RESULT_BOX: '#resultBox',
|
|
5
|
+
PAGINATION_BTN: '#paginationBtn',
|
|
6
|
+
HEAD_BTNS: '#headBtns',
|
|
7
|
+
SELECTED_VALUES_REPEATER: '#selectedValuesReapter',
|
|
8
|
+
BUTTOM_TXT: '#buttomTxt',
|
|
9
|
+
SECTION_24: '#section24',
|
|
10
|
+
SECTION_3: '#section3',
|
|
11
|
+
LINE_3: '#line3',
|
|
12
|
+
EXIT_BUTTON: '#exitBtn',
|
|
13
|
+
REFINE_SEARCH_BUTTON: '#refineSearchBtn',
|
|
14
|
+
|
|
15
|
+
POSITIONS_REPEATER: '#positionsRepeater',
|
|
16
|
+
POSITION_ITEM: '#positionItem',
|
|
17
|
+
SEARCH_INPUT: '#searchInput',
|
|
18
|
+
CLEAR_SEARCH: '#clearSearch',
|
|
19
|
+
|
|
20
|
+
DROPDOWN_BRAND: '#dropdownBrand',
|
|
21
|
+
DROPDOWN_CONTAINER: '#dropdownsContainer',
|
|
22
|
+
DROPDOWN_DEPARTMENT: '#dropdownDepartment',
|
|
23
|
+
DROPDOWN_LOCATION: '#dropdownLocation',
|
|
24
|
+
DROPDOWN_JOB_TYPE: '#dropdownJobType',
|
|
25
|
+
|
|
26
|
+
OPEN_FILTERS_BUTTON: '#openFiltersButton',
|
|
27
|
+
CLOSE_FILTERS_BUTTON: '#closeFiltersButton',
|
|
28
|
+
RESET_FILTERS_BUTTON: '#resetFiltersButton',
|
|
29
|
+
RESET_FILTERS_BUTTON: '#resetFiltersButton',
|
|
30
|
+
|
|
31
|
+
RESULTS_MULTI_STATE: '#resultsMultiState',
|
|
32
|
+
BRANDS_DATASET: '#brandsDataset',
|
|
33
|
+
DEPARTMENTS_DATASET: '#departmentsDataset',
|
|
34
|
+
LOCATIONS_DATASET: '#locationsDataset',
|
|
35
|
+
JOB_TYPES_DATASET: '#jobTypesDataset',
|
|
36
|
+
JOBS_DATASET: '#jobsDataset',
|
|
37
|
+
|
|
38
|
+
GOOGLE_MAPS: '#googleMaps',
|
|
39
|
+
FOOTER: '#footer',
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const FILTER_FIELDS = {
|
|
43
|
+
DEPARTMENT: 'department',
|
|
44
|
+
LOCATION: 'cityText',
|
|
45
|
+
JOB_TYPE: 'remote',
|
|
46
|
+
BRAND: 'brand',
|
|
47
|
+
SEARCH: 'title',
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
module.exports = {
|
|
51
|
+
CAREERS_PAGE_SELECTORS,
|
|
52
|
+
FILTER_FIELDS,
|
|
53
|
+
}
|
package/public/utils.js
CHANGED
|
@@ -14,7 +14,8 @@ function htmlToText(html) {
|
|
|
14
14
|
.replace(/>/g, '>')
|
|
15
15
|
.replace(/"/g, '"')
|
|
16
16
|
.replace(/'/g, "'")
|
|
17
|
-
.replace(/ /g, ' ')
|
|
17
|
+
.replace(/ /g, ' ')
|
|
18
|
+
.replace(/ /gi, ' ');
|
|
18
19
|
|
|
19
20
|
// Clean up whitespace
|
|
20
21
|
return text.replace(/\n\s*\n+/g, '\n\n').replace(/[ \t]+\n/g, '\n').trim();
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
const mockLocation = {
|
|
2
|
+
to: jest.fn()
|
|
3
|
+
};
|
|
4
|
+
|
|
5
|
+
jest.mock('@wix/site-location', () => ({
|
|
6
|
+
location: mockLocation
|
|
7
|
+
}));
|
|
8
|
+
|
|
9
|
+
const { brandPageOnReady } = require('../pages/brandPage');
|
|
10
|
+
|
|
11
|
+
describe('Brand Page Tests', () => {
|
|
12
|
+
let mockW;
|
|
13
|
+
let mockButton;
|
|
14
|
+
|
|
15
|
+
beforeEach(() => {
|
|
16
|
+
jest.clearAllMocks();
|
|
17
|
+
|
|
18
|
+
mockButton = {
|
|
19
|
+
onClick: jest.fn()
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
mockW = jest.fn((selector) => {
|
|
23
|
+
if (selector === '#seeJobsButton') {
|
|
24
|
+
return mockButton;
|
|
25
|
+
}
|
|
26
|
+
return {};
|
|
27
|
+
});
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
it('should navigate to search page with brand param when all jobs button is clicked', async () => {
|
|
31
|
+
const brandName = 'TestBrand';
|
|
32
|
+
|
|
33
|
+
await brandPageOnReady(mockW, brandName);
|
|
34
|
+
|
|
35
|
+
expect(mockButton.onClick).toHaveBeenCalled();
|
|
36
|
+
|
|
37
|
+
const onClickCallback = mockButton.onClick.mock.calls[0][0];
|
|
38
|
+
await onClickCallback();
|
|
39
|
+
|
|
40
|
+
expect(mockLocation.to).toHaveBeenCalledWith(`/search?brand=${brandName}`);
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
});
|
|
45
|
+
|