4658-createWorker #1236

Merged
alexm merged 35 commits from 4658-createWorker into dev 2023-01-23 07:30:52 +00:00
6 changed files with 62 additions and 65 deletions
Showing only changes of commit 9b98249398 - Show all commits

View File

@ -31,7 +31,7 @@ INSERT INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `pri
VALUES
('Worker', 'updateAttributes', 'WRITE', 'ALLOW', 'ROLE', 'hr'),
('Worker', 'createAbsence', '*', 'ALLOW', 'ROLE', 'employee'),
('Worker', 'updateAbsence', '*', 'ALLOW', 'ROLE', 'employee'),
('Worker', 'updateAbsence', 'WRITE', 'ALLOW', 'ROLE', 'employee'),
('Worker', 'deleteAbsence', '*', 'ALLOW', 'ROLE', 'employee'),
('Worker', 'new', 'WRITE', 'ALLOW', 'ROLE', 'hr'),
('Role', '*', 'READ', 'ALLOW', 'ROLE', 'hr');

View File

@ -58,6 +58,7 @@ export default {
deleteAccount: '.vn-menu [name="deleteUser"]',
setPassword: '.vn-menu [name="setPassword"]',
activateAccount: '.vn-menu [name="enableAccount"]',
disableAccount: '.vn-menu [name="disableAccount"]',
activateUser: '.vn-menu [name="activateUser"]',
deactivateUser: '.vn-menu [name="deactivateUser"]',
newPassword: 'vn-textfield[ng-model="$ctrl.newPassword"]',

View File

@ -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({

View File

@ -1,7 +1,7 @@
import selectors from '../../helpers/selectors.js';
import getBrowser from '../../helpers/puppeteer';
xdescribe('Worker calendar path', () => {
describe('Worker calendar path', () => {
alexm marked this conversation as resolved Outdated

Este E2E esta conforme lo que Juan comentà de que els it siguen independents?

Este E2E esta conforme lo que Juan comentà de que els it siguen independents?
let browser;
let page;
let newWorker;
@ -58,15 +58,22 @@ xdescribe('Worker calendar path', () => {
expect(message.text).toContain('Data saved!');
});
xit('rollback', async() => {
it('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');
await page.waitToClick(selectors.accountDescriptor.menuButton);
await page.waitToClick(selectors.accountDescriptor.deactivateUser);
await page.waitToClick(selectors.accountDescriptor.acceptButton);
let message = await page.waitForSnackbar();
expect(message.text).toContain('User deactivated!');
await page.waitToClick(selectors.accountDescriptor.menuButton);
await page.waitToClick(selectors.accountDescriptor.disableAccount);
await page.waitToClick(selectors.accountDescriptor.acceptButton);
message = await page.waitForSnackbar();
expect(message.text).toContain('Account disabled!');
});
});

View File

@ -4,29 +4,9 @@ import Section from 'salix/components/section';
export default class Controller extends Section {
constructor($element, $) {
super($element, $);
// this.$http.get('NewWorkerConfigs/findOne').then(res => {
// return this.worker = Object.assign({}, res.data);
// });
// DELETE
this.worker = {
fi: '73226971P',
name: 'ASDASD',
firstName: 'Test',
lastNames: 'Test',
email: 'developer4@mydomain.com',
roleFk: 1,
street: 'S/ ',
city: 'asd',
provinceFk: 1,
iban: 'ES2420386579855387888566',
bankEntityFk: 128,
companyFk: 442,
postcode: 'asd',
phone: '633342693',
code: 'ASD',
bossFk: 34,
birth: '2022-12-11T23:00:00.000Z'
};
this.$http.get('NewWorkerConfigs/findOne').then(res => {
return this.worker = Object.assign({}, res.data);
});
}
onSubmit() {

View File

@ -1,12 +1,12 @@
import './index';
describe('Client', () => {
describe('Component vnClientCreate', () => {
describe('Worker', () => {
describe('Component vnWorkerCreate', () => {
let $scope;
let $state;
let controller;
beforeEach(ngModule('client'));
beforeEach(ngModule('worker'));
beforeEach(inject(($componentController, $rootScope, _$state_) => {
$scope = $rootScope.$new();
@ -20,28 +20,23 @@ describe('Client', () => {
};
}
};
const $element = angular.element('<vn-client-create></vn-client-create>');
controller = $componentController('vnClientCreate', {$element, $scope});
const $element = angular.element('<vn-worker-create></vn-worker-create>');
controller = $componentController('vnWorkerCreate', {$element, $scope});
controller.worker = {};
}));
it('should define and set scope, state and client properties', () => {
expect(controller.$).toBe($scope);
expect(controller.$state).toBe($state);
expect(controller.client.active).toBe(true);
});
describe('onSubmit()', () => {
it(`should call submit() on the watcher then expect a callback`, () => {
jest.spyOn($state, 'go');
controller.onSubmit();
expect(controller.$state.go).toHaveBeenCalledWith('client.card.basicData', {id: '1234'});
expect(controller.$state.go).toHaveBeenCalledWith('worker.card.basicData', {id: '1234'});
});
});
describe('province() setter', () => {
it(`should set countryFk property`, () => {
controller.client.countryFk = null;
controller.worker.countryFk = null;
controller.province = {
id: 1,
name: 'New york',
@ -51,7 +46,7 @@ describe('Client', () => {
}
};
expect(controller.client.countryFk).toEqual(2);
expect(controller.worker.countryFk).toEqual(2);
});
});
@ -71,7 +66,7 @@ describe('Client', () => {
postcodes: []
};
expect(controller.client.provinceFk).toEqual(1);
expect(controller.worker.provinceFk).toEqual(1);
});
it(`should set provinceFk property and fill the postalCode if there's just one`, () => {
@ -89,8 +84,8 @@ describe('Client', () => {
postcodes: [{code: '46001'}]
};
expect(controller.client.provinceFk).toEqual(1);
expect(controller.client.postcode).toEqual('46001');
expect(controller.worker.provinceFk).toEqual(1);
expect(controller.worker.postcode).toEqual('46001');
});
});
@ -113,9 +108,23 @@ describe('Client', () => {
}
};
expect(controller.client.city).toEqual('New York');
expect(controller.client.provinceFk).toEqual(1);
expect(controller.client.countryFk).toEqual(2);
expect(controller.worker.city).toEqual('New York');
expect(controller.worker.provinceFk).toEqual(1);
expect(controller.worker.countryFk).toEqual(2);
});
});
describe('generateCodeUser()', () => {
it(`should generate worker code and name `, () => {
controller.worker = {
firstName: 'default',
lastNames: 'generate worker'
};
controller.generateCodeUser();
expect(controller.worker.code).toEqual('DGW');
expect(controller.worker.name).toEqual('defaultgw');
});
});
});