| 1 |
import { registry } from "@web/core/registry"; |
| 2 |
import { |
| 3 |
clickOnEditAndWaitEditMode, |
| 4 |
clickOnSave, |
| 5 |
registerWebsitePreviewTour, |
| 6 |
} from "@website/js/tours/tour_utils"; |
| 7 |
import { stepUtils } from "@web_tour/tour_utils"; |
| 8 |
|
| 9 |
function applyForAJob(jobName, application) { |
| 10 |
return [{ |
| 11 |
content: "Select Job", |
| 12 |
trigger: `.oe_website_jobs h3:contains(${jobName})`, |
| 13 |
run: "click", |
| 14 |
expectUnloadPage: true, |
| 15 |
}, { |
| 16 |
content: "Apply", |
| 17 |
trigger: ".js_hr_recruitment a:contains('Apply')", |
| 18 |
run: "click", |
| 19 |
expectUnloadPage: true, |
| 20 |
}, { |
| 21 |
content: "Complete name", |
| 22 |
trigger: "input[name=partner_name]", |
| 23 |
run: `edit ${application.name}`, |
| 24 |
}, { |
| 25 |
content: "Complete Email", |
| 26 |
trigger: "input[name=email_from]", |
| 27 |
run: `edit ${application.email}`, |
| 28 |
}, { |
| 29 |
content: "Complete phone number", |
| 30 |
trigger: "input[name=partner_phone]", |
| 31 |
run: `edit ${application.phone}`, |
| 32 |
}, { |
| 33 |
content: "Complete LinkedIn profile", |
| 34 |
trigger: "input[name=linkedin_profile]", |
| 35 |
run: `edit linkedin.com/in/${application.name.toLowerCase().replace(' ', '-')}`, |
| 36 |
}, { |
| 37 |
content: "Complete Subject", |
| 38 |
trigger: "textarea[name=short_introduction]", |
| 39 |
run: `edit ${application.subject}`, |
| 40 |
}, { |
| 41 |
content: "Send the form", |
| 42 |
trigger: ".s_website_form_send", |
| 43 |
run: "click", |
| 44 |
expectUnloadPage: true, |
| 45 |
}, { |
| 46 |
content: "Check the form is submitted without errors", |
| 47 |
trigger: "#jobs_thankyou h1:contains('Congratulations')", |
| 48 |
}]; |
| 49 |
} |
| 50 |
|
| 51 |
registry.category("web_tour.tours").add('website_hr_recruitment_tour', { |
| 52 |
url: '/jobs', |
| 53 |
steps: () => [ |
| 54 |
...applyForAJob('Guru', { |
| 55 |
name: 'John Smith', |
| 56 |
email: '[email protected]', |
| 57 |
phone: '118.218', |
| 58 |
subject: '### [GURU] HR RECRUITMENT TEST DATA ###', |
| 59 |
}), |
| 60 |
{ |
| 61 |
content: "Go back to the jobs page", |
| 62 |
trigger: "body", |
| 63 |
run: () => { |
| 64 |
window.location.href = '/jobs'; |
| 65 |
}, |
| 66 |
expectUnloadPage: true, |
| 67 |
}, |
| 68 |
...applyForAJob('Internship', { |
| 69 |
name: 'Jack Doe', |
| 70 |
email: '[email protected]', |
| 71 |
phone: '118.712', |
| 72 |
subject: '### HR [INTERN] RECRUITMENT TEST DATA ###', |
| 73 |
}), |
| 74 |
]}); |
| 75 |
|
| 76 |
registerWebsitePreviewTour('website_hr_recruitment_tour_edit_form', { |
| 77 |
url: '/jobs', |
| 78 |
}, () => [ |
| 79 |
stepUtils.waitIframeIsReady(), |
| 80 |
{ |
| 81 |
content: 'Go to the Guru job page', |
| 82 |
trigger: ':iframe a[href*="guru"]', |
| 83 |
run: "click", |
| 84 |
}, { |
| 85 |
content: 'Go to the Guru job form', |
| 86 |
trigger: ':iframe a[href*="apply"]', |
| 87 |
run: "click", |
| 88 |
}, { |
| 89 |
content: 'Check if the Guru form is present', |
| 90 |
trigger: ':iframe form', |
| 91 |
run: "click", |
| 92 |
}, |
| 93 |
...clickOnEditAndWaitEditMode(), |
| 94 |
{ |
| 95 |
content: 'Add a fake default value for the job_id hidden field', |
| 96 |
trigger: ":iframe form input[name=job_id]:not(:visible)", |
| 97 |
run() { |
| 98 |
|
| 99 |
|
| 100 |
this.anchor.value = "FAKE_JOB_ID_DEFAULT_VAL"; |
| 101 |
}, |
| 102 |
}, { |
| 103 |
content: 'Make the department_id field visible', |
| 104 |
trigger: ':iframe form', |
| 105 |
run() { |
| 106 |
const departmentEl = this.anchor.querySelector('input[name="department_id"]'); |
| 107 |
departmentEl.value = 'FAKE_DEPARTMENT_ID_DEFAULT_VAL'; |
| 108 |
departmentEl.type = 'text'; |
| 109 |
departmentEl.closest('.s_website_form_field').classList.remove('s_website_form_dnone'); |
| 110 |
}, |
| 111 |
}, |
| 112 |
{ |
| 113 |
content: 'Edit the form', |
| 114 |
trigger: ':iframe input[type="file"]', |
| 115 |
run: "click", |
| 116 |
}, { |
| 117 |
content: 'Add a new field', |
| 118 |
trigger: 'div[data-container-title="Field"] button.btn-success', |
| 119 |
run: "click", |
| 120 |
}, |
| 121 |
...clickOnSave(), |
| 122 |
{ |
| 123 |
content: "wait for the form values are patched", |
| 124 |
trigger: ":iframe form input[name=partner_name]:value(admin)", |
| 125 |
}, |
| 126 |
{ |
| 127 |
content: 'Go back to /jobs page after save', |
| 128 |
trigger: ":iframe nav a[href='/jobs']", |
| 129 |
run: "click", |
| 130 |
}, { |
| 131 |
content: 'Go to the Internship job page', |
| 132 |
trigger: ':iframe a[href*="internship"]', |
| 133 |
run: "click", |
| 134 |
}, { |
| 135 |
content: 'Go to the Internship job form', |
| 136 |
trigger: ':iframe a[href*="apply"]', |
| 137 |
run: "click", |
| 138 |
}, { |
| 139 |
content: 'Check that a job_id has been loaded', |
| 140 |
trigger: ":iframe form input[name=job_id]:not(:visible):not([value='']):not([value=FAKE_JOB_ID_DEFAULT_VAL])", |
| 141 |
}, { |
| 142 |
content: 'Check that a department_id has been loaded', |
| 143 |
trigger: ':iframe input[name="department_id"][value="FAKE_DEPARTMENT_ID_DEFAULT_VAL"]', |
| 144 |
run: function () { |
| 145 |
if (this.anchor.value === "FAKE_DEPARTMENT_ID_DEFAULT_VAL") { |
| 146 |
console.error('The department_id data-for should have been applied'); |
| 147 |
} |
| 148 |
} |
| 149 |
}, |
| 150 |
...clickOnEditAndWaitEditMode(), |
| 151 |
{ |
| 152 |
content: 'Verify that the job_id hidden field has lost its default value', |
| 153 |
trigger: ":iframe form input[name=job_id]:not(:visible):not([value='']):not([value=FAKE_JOB_ID_DEFAULT_VAL])", |
| 154 |
}, { |
| 155 |
content: 'Verify that the department_id shown field has kept its default value', |
| 156 |
trigger: ':iframe form input[name="department_id"][value="FAKE_DEPARTMENT_ID_DEFAULT_VAL"]', |
| 157 |
run: function () { |
| 158 |
if (this.anchor.value !== "FAKE_DEPARTMENT_ID_DEFAULT_VAL") { |
| 159 |
console.error('The department_id field has lost its default value'); |
| 160 |
} |
| 161 |
}, |
| 162 |
}, |
| 163 |
]); |
| 164 |
|
| 165 |
|
| 166 |
|
| 167 |
|
| 168 |
|
| 169 |
registerWebsitePreviewTour('model_required_field_should_have_action_name', { |
| 170 |
url: '/jobs', |
| 171 |
}, () => [{ |
| 172 |
content: "Select Job", |
| 173 |
trigger: ":iframe h3:contains('Guru')", |
| 174 |
run: "click", |
| 175 |
}, { |
| 176 |
content: "Apply", |
| 177 |
trigger: ":iframe a:contains('Apply')", |
| 178 |
run: "click", |
| 179 |
}, |
| 180 |
...clickOnEditAndWaitEditMode(), |
| 181 |
{ |
| 182 |
content: "click on the your name field", |
| 183 |
trigger: ":iframe #hr_recruitment_form div.s_website_form_model_required", |
| 184 |
run: "click", |
| 185 |
}, { |
| 186 |
content: "Select model-required field", |
| 187 |
trigger: ".options-container .alert > span:not(:contains(undefined))", |
| 188 |
} |
| 189 |
]); |