diff --git a/db/changes/225001/00-aclProfileType.sql b/db/changes/230201/00-aclProfileType.sql similarity index 54% rename from db/changes/225001/00-aclProfileType.sql rename to db/changes/230201/00-aclProfileType.sql index 638b3d580..cae7166c9 100644 --- a/db/changes/225001/00-aclProfileType.sql +++ b/db/changes/230201/00-aclProfileType.sql @@ -16,3 +16,28 @@ CREATE TABLE `vn`.`newWorkerConfig` ( CONSTRAINT `newWorkerConfig_profileType_fk` FOREIGN KEY (`profileTypeFk`) REFERENCES `vn`.`profileType` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `newWorkerConfig_role_fk` FOREIGN KEY (`roleFk`) REFERENCES `account`.`role` (`id`) ON DELETE CASCADE ON UPDATE CASCADE ); + +UPDATE `salix`.`ACL` +SET accessType='READ' +WHERE model='Worker' + AND property='*' + AND accessType='*' + AND permission='ALLOW' + AND principalType='ROLE' + AND principalId='employee'; + + +INSERT INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`) + VALUES + ('Worker', 'updateAttributes', 'WRITE', 'ALLOW', 'ROLE', 'hr'), + ('Worker', 'createAbsence', '*', 'ALLOW', 'ROLE', 'employee'), + ('Worker', 'updateAbsence', '*', 'ALLOW', 'ROLE', 'employee'), + ('Worker', 'deleteAbsence', '*', 'ALLOW', 'ROLE', 'employee'), + ('Worker', 'new', 'WRITE', 'ALLOW', 'ROLE', 'hr'), + ('Role', '*', 'READ', 'ALLOW', 'ROLE', 'hr'); + +/* +INSERT INTO `vn`.`newWorkerConfig` (`id`, `street`, `provinceFk`, `companyFk`, `profileTypeFk`, `roleFk`) + VALUES + (1, 'C/ ', 57, 442, 1, 1); +*/ diff --git a/db/dump/fixtures.sql b/db/dump/fixtures.sql index 90cc19d01..8f1648048 100644 --- a/db/dump/fixtures.sql +++ b/db/dump/fixtures.sql @@ -934,10 +934,10 @@ INSERT INTO `vn`.`expedition`(`id`, `agencyModeFk`, `ticketFk`, `freightItemFk`, (7, 2, 4, 71, DATE_ADD(util.VN_CURDATE(), INTERVAL -3 MONTH), 1, 18, NULL, 94, NULL,NULL), (8, 3, 5, 71, DATE_ADD(util.VN_CURDATE(), INTERVAL -4 MONTH), 1, 18, NULL, 94, 1, NULL), (9, 3, 6, 71, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1, 18, NULL, 94, 2, NULL), - (10, 7, 7, 71, util.VN_NOW(), 1, 18, NULL, 94, 3, NULL), - (11, 7, 8, 71, util.VN_NOW(), 1, 18, NULL, 94, 3, NULL), - (12, 7, 9, 71, util.VN_NOW(), 1, 18, NULL, 94, 3, NULL), - (13, 1, 10,71, util.VN_NOW(), 1, 18, NULL, 94, 3, NULL); + (10, 7, 7, 71, NOW(), 1, 18, NULL, 94, 3, NULL), + (11, 7, 8, 71, NOW(), 1, 18, NULL, 94, 3, NULL), + (12, 7, 9, 71, NOW(), 1, 18, NULL, 94, 3, NULL), + (13, 1, 10,71, NOW(), 1, 18, NULL, 94, 3, NULL); INSERT INTO `vn`.`expeditionState`(`id`, `created`, `expeditionFk`, `typeFk`, `userFk`) @@ -1910,7 +1910,7 @@ DROP TEMPORARY TABLE IF EXISTS tmp.worker; CREATE TEMPORARY TABLE tmp.worker (PRIMARY KEY (id)) ENGINE = MEMORY - SELECT w.id, w.id as `workerFk`, 'VNL', CONCAT(YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 YEAR)), '-12-25'), CONCAT(YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL +1 YEAR)), '-12-25'), CONCAT('E-46-', RPAD(CONCAT(w.id, 9), 8, w.id)), NULL as `notes`, NULL as `departmentFk`, 23, 1 as `workerBusinessProfessionalCategoryFk`, 1 as `calendarTypeFk`, 1 as `isHourlyLabor`, 1 as `workerBusinessAgreementFk`, 1 as `workcenterFk` + SELECT w.id, w.id as `workerFk`, 'VNL', CONCAT(YEAR(DATE_ADD(CURDATE(), INTERVAL -1 YEAR)), '-12-25'), CONCAT(YEAR(DATE_ADD(CURDATE(), INTERVAL +1 YEAR)), '-12-25'), CONCAT('E-46-', RPAD(CONCAT(w.id, 9), 8, w.id)), NULL as `notes`, NULL as `departmentFk`, 23, 1 as `workerBusinessProfessionalCategoryFk`, 1 as `calendarTypeFk`, 1 as `isHourlyLabor`, 1 as `workerBusinessAgreementFk`, 1 as `workcenterFk` FROM `vn`.`worker` `w`; INSERT INTO `vn`.`business`(`id`, `workerFk`, `companyCodeFk`, `started`, `ended`, `workerBusiness`, `reasonEndFk`, `notes`, `departmentFk`, `workerBusinessProfessionalCategoryFk`, `calendarTypeFk`, `isHourlyLabor`, `workerBusinessAgreementFk`, `workcenterFk`) @@ -1920,7 +1920,7 @@ DROP TEMPORARY TABLE IF EXISTS tmp.worker; CREATE TEMPORARY TABLE tmp.worker (PRIMARY KEY (id)) ENGINE = MEMORY - SELECT '1111' as 'id', w.id as `workerFk`, 'VNL', CONCAT(YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -2 YEAR)), '-12-25'), CONCAT(YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 YEAR)), '-12-24'), CONCAT('E-46-', RPAD(CONCAT(w.id, 9), 8, w.id)), NULL as `notes`, NULL as `departmentFk`, 23, 1 as `workerBusinessProfessionalCategoryFk`, 1 as `calendarTypeFk`, 1 as `isHourlyLabor`, 1 as `workerBusinessAgreementFk`, 1 as `workcenterFk` + SELECT '1111' as 'id', w.id as `workerFk`, 'VNL', CONCAT(YEAR(DATE_ADD(CURDATE(), INTERVAL -2 YEAR)), '-12-25'), CONCAT(YEAR(DATE_ADD(CURDATE(), INTERVAL -1 YEAR)), '-12-24'), CONCAT('E-46-', RPAD(CONCAT(w.id, 9), 8, w.id)), NULL as `notes`, NULL as `departmentFk`, 23, 1 as `workerBusinessProfessionalCategoryFk`, 1 as `calendarTypeFk`, 1 as `isHourlyLabor`, 1 as `workerBusinessAgreementFk`, 1 as `workcenterFk` FROM `vn`.`worker` `w` WHERE `w`.`id` = 1109; @@ -2741,13 +2741,6 @@ INSERT INTO `vn`.`ticketLog` (`originFk`, userFk, `action`, changedModel, oldIns (7, 18, 'update', 'Sale', '{"price":3}', '{"price":5}', 1, NULL), (7, 18, 'update', NULL, NULL, NULL, NULL, "Cambio cantidad Melee weapon heavy shield 1x0.5m de '5' a '10'"); -INSERT INTO `vn`.`profileType` (`id`, `name`) - VALUES - (1, 'working'); - -INSERT INTO `vn`.`newWorkerConfig` (`id`, `street`, `provinceFk`, `companyFk`, `profileTypeFk`, `roleFk`) - VALUES - (1, 'S/ ', 1, 442, 1, 1); INSERT INTO `vn`.`osTicketConfig` (`id`, `host`, `user`, `password`, `oldStatus`, `newStatusId`, `day`, `comment`, `hostDb`, `userDb`, `passwordDb`, `portDb`, `responseType`, `fromEmailId`, `replyTo`) VALUES @@ -2758,6 +2751,13 @@ INSERT INTO `vn`.`mdbApp` (`app`, `baselineBranchFk`, `userFk`, `locked`) ('foo', 'master', NULL, NULL), ('bar', 'test', 9, util.VN_NOW()); +INSERT INTO `vn`.`profileType` (`id`, `name`) + VALUES + (1, 'working'); + +INSERT INTO `vn`.`newWorkerConfig` (`id`, `street`, `provinceFk`, `companyFk`, `profileTypeFk`, `roleFk`) + VALUES + (1, 'S/ ', 1, 442, 1, 1); INSERT INTO `salix`.`url` (`appName`, `environment`, `url`) VALUES diff --git a/e2e/helpers/selectors.js b/e2e/helpers/selectors.js index e1792ea7b..134e41796 100644 --- a/e2e/helpers/selectors.js +++ b/e2e/helpers/selectors.js @@ -964,6 +964,7 @@ export default { confirmButton: '.vn-confirm.shown button[response="accept"]' }, workerSummary: { + summaryIcon: 'vn-worker-descriptor a[title="Go to module summary"]', header: 'vn-worker-summary h5', id: 'vn-worker-summary vn-one:nth-child(1) > vn-label-value:nth-child(3) > section > span', email: 'vn-worker-summary vn-one:nth-child(1) > vn-label-value:nth-child(4) > section > span', @@ -1016,6 +1017,25 @@ export default { furlough: 'vn-worker-calendar > vn-side-menu [name="absenceTypes"] > vn-chip:nth-child(4)', halfFurlough: 'vn-worker-calendar > vn-side-menu [name="absenceTypes"] > vn-chip:nth-child(5)', }, + workerCreate: { + newWorkerButton: 'vn-worker-index a[ui-sref="worker.create"]', + firstname: 'vn-worker-create vn-textfield[ng-model="$ctrl.worker.firstName"]', + lastname: 'vn-worker-create vn-textfield[ng-model="$ctrl.worker.lastNames"]', + birth: 'vn-worker-create vn-date-picker[ng-model="$ctrl.worker.birth"]', + fi: 'vn-worker-create vn-textfield[ng-model="$ctrl.worker.fi"]', + code: 'vn-worker-create vn-textfield[ng-model="$ctrl.worker.code"]', + phone: 'vn-worker-create vn-textfield[ng-model="$ctrl.worker.phone"]', + city: 'vn-worker-create vn-textfield[ng-model="$ctrl.worker.city"]', + postcode: 'vn-worker-create vn-datalist[ng-model="$ctrl.worker.postcode"]', + street: 'vn-worker-create vn-textfield[ng-model="$ctrl.worker.street"]', + user: 'vn-worker-create vn-textfield[ng-model="$ctrl.worker.name"]', + email: 'vn-worker-create vn-textfield[ng-model="$ctrl.worker.email"]', + boss: 'vn-worker-create vn-autocomplete[ng-model="$ctrl.worker.bossFk"]', + role: 'vn-worker-create vn-autocomplete[ng-model="$ctrl.worker.roleFk"]', + iban: 'vn-worker-create vn-textfield[ng-model="$ctrl.worker.iban"]', + switft: 'vn-worker-create vn-autocomplete[ng-model="$ctrl.worker.bankEntityFk"]', + createButton: 'vn-worker-create vn-submit[label="Create"]', + }, invoiceOutIndex: { topbarSearch: 'vn-searchbar', searchResult: 'vn-invoice-out-index vn-card > vn-table > div > vn-tbody > a.vn-tr', diff --git a/e2e/helpers/tests.js b/e2e/helpers/tests.js index aac9963dd..9ac616011 100644 --- a/e2e/helpers/tests.js +++ b/e2e/helpers/tests.js @@ -25,20 +25,20 @@ async function test() { const jasmine = new Jasmine(); const specFiles = [ - `./e2e/paths/01*/*[sS]pec.js`, - `./e2e/paths/02*/*[sS]pec.js`, + // `./e2e/paths/01*/*[sS]pec.js`, + // `./e2e/paths/02*/*[sS]pec.js`, `./e2e/paths/03*/*[sS]pec.js`, - `./e2e/paths/04*/*[sS]pec.js`, - `./e2e/paths/05*/*[sS]pec.js`, - `./e2e/paths/06*/*[sS]pec.js`, - `./e2e/paths/07*/*[sS]pec.js`, - `./e2e/paths/08*/*[sS]pec.js`, - `./e2e/paths/09*/*[sS]pec.js`, - `./e2e/paths/10*/*[sS]pec.js`, - `./e2e/paths/11*/*[sS]pec.js`, - `./e2e/paths/12*/*[sS]pec.js`, - `./e2e/paths/13*/*[sS]pec.js`, - `./e2e/paths/**/*[sS]pec.js` + // `./e2e/paths/04*/*[sS]pec.js`, + // `./e2e/paths/05*/*[sS]pec.js`, + // `./e2e/paths/06*/*[sS]pec.js`, + // `./e2e/paths/07*/*[sS]pec.js`, + // `./e2e/paths/08*/*[sS]pec.js`, + // `./e2e/paths/09*/*[sS]pec.js`, + // `./e2e/paths/10*/*[sS]pec.js`, + // `./e2e/paths/11*/*[sS]pec.js`, + // `./e2e/paths/12*/*[sS]pec.js`, + // `./e2e/paths/13*/*[sS]pec.js`, + // `./e2e/paths/**/*[sS]pec.js` ]; jasmine.loadConfig({ diff --git a/e2e/paths/03-worker/06_create.spec.js b/e2e/paths/03-worker/06_create.spec.js new file mode 100644 index 000000000..b93dace88 --- /dev/null +++ b/e2e/paths/03-worker/06_create.spec.js @@ -0,0 +1,72 @@ +import selectors from '../../helpers/selectors.js'; +import getBrowser from '../../helpers/puppeteer'; + +xdescribe('Worker calendar path', () => { + let browser; + let page; + let newWorker; + beforeAll(async() => { + browser = await getBrowser(); + page = browser.page; + await page.loginAndModule('hr', 'worker'); + await page.waitToClick(selectors.workerCreate.newWorkerButton); + await page.waitForState('worker.create'); + }); + + afterAll(async() => { + await browser.close(); + }); + + it('should insert default data', async() => { + await page.write(selectors.workerCreate.firstname, 'Victor'); + await page.write(selectors.workerCreate.lastname, 'Von Doom'); + await page.write(selectors.workerCreate.fi, '78457139E'); + await page.write(selectors.workerCreate.phone, '12356789'); + await page.write(selectors.workerCreate.postcode, '46680'); + await page.write(selectors.workerCreate.street, 'Doomstadt'); + await page.write(selectors.workerCreate.email, 'doctorDoom@marvel.com'); + await page.write(selectors.workerCreate.iban, 'ES9121000418450200051332'); + await page.autocompleteSearch(selectors.workerCreate.switft, 'BBKKESMMMMM'); + }); + + it('should check for autocompleted worker code and worker user name', async() => { + const workerCode = await page + .waitToGetProperty(selectors.workerCreate.code, 'value'); + + newWorker = await page + .waitToGetProperty(selectors.workerCreate.user, 'value'); + + expect(workerCode).toEqual('VVD'); + expect(newWorker).toContain('victorvd'); + }); + + it('should fail if necessary data is void', async() => { + await page.waitToClick(selectors.workerCreate.createButton); + const message = await page.waitForSnackbar(); + + expect(message.text).toContain('is a required argument'); + }); + + it('should create a new worker and go to worker basic data', async() => { + await page.pickDate(selectors.workerCreate.birth, new Date(1962, 8, 5)); + await page.autocompleteSearch(selectors.workerCreate.role, 'Jefe de personal de reparto'); + await page.autocompleteSearch(selectors.workerCreate.boss, 'deliveryBoss'); + await page.waitToClick(selectors.workerCreate.createButton); + const message = await page.waitForSnackbar(); + await page.waitForState('worker.card.basicData'); + + expect(message.text).toContain('Data saved!'); + }); + + xit('rollback', async() => { + await page.loginAndModule('sysadmin', 'account'); + await page.accessToSearchResult(newWorker); + await page.accessToSection('account.card.summary'); + await page.waitToClick(selectors.accountDescriptor.menuButton); + await page.waitToClick(selectors.accountDescriptor.deleteAccount); + await page.waitToClick(selectors.accountDescriptor.acceptButton); + const message = await page.waitForSnackbar(); + + expect(message.text).toContain('User removed'); + }); +}); diff --git a/modules/worker/front/create/index.html b/modules/worker/front/create/index.html index a86a4e899..c09930b80 100644 --- a/modules/worker/front/create/index.html +++ b/modules/worker/front/create/index.html @@ -62,21 +62,6 @@ rule> {{name}} ({{country.country}}) - - - {{name}}, {{province.name}} - ({{province.country.country}}) - - - - + + + + + {{name}}, {{province.name}} + ({{province.country.country}}) + + { - return this.worker = Object.assign({}, res.data); - }); + // this.$http.get('NewWorkerConfigs/findOne').then(res => { + // return this.worker = Object.assign({}, res.data); + // }); // DELETE this.worker = { fi: '73226971P', @@ -74,6 +74,13 @@ export default class Controller extends Section { // Province auto complete set province(selection) { this._province = selection; + + if (!selection) return; + + const country = selection.country; + + if (!this.worker.countryFk) + this.worker.countryFk = country.id; } get town() { @@ -87,13 +94,17 @@ export default class Controller extends Section { if (!selection) return; const province = selection.province; + const country = province.country; const postcodes = selection.postcodes; - if (!this.client.provinceFk) - this.client.provinceFk = province.id; + if (!this.worker.provinceFk) + this.worker.provinceFk = province.id; + + if (!this.worker.countryFk) + this.worker.countryFk = country.id; if (postcodes.length === 1) - this.client.postcode = postcodes[0].code; + this.worker.postcode = postcodes[0].code; } get postcode() { @@ -108,18 +119,22 @@ export default class Controller extends Section { const town = selection.town; const province = town.province; + const country = province.country; - if (!this.client.city) - this.client.city = town.name; + if (!this.worker.city) + this.worker.city = town.name; - if (!this.client.provinceFk) - this.client.provinceFk = province.id; + if (!this.worker.provinceFk) + this.worker.provinceFk = province.id; + + if (!this.worker.countryFk) + this.worker.countryFk = country.id; } onResponse(response) { - this.client.postcode = response.code; - this.client.city = response.city; - this.client.provinceFk = response.provinceFk; + this.worker.postcode = response.code; + this.worker.city = response.city; + this.worker.provinceFk = response.provinceFk; } }