From 1095a5995475dcaa0d2c807a66321d9d9ff7ce22 Mon Sep 17 00:00:00 2001 From: carlossa Date: Fri, 2 Jun 2023 14:44:56 +0200 Subject: [PATCH] refs #5334 rest back, e2e summary, less e2e basic --- e2e/helpers/puppeteer.js | 2 +- e2e/helpers/selectors.js | 19 ++++++++ .../01-department/01_summary.spec.js | 30 +++++++++++++ .../01-department/02-basicData.spec.js | 44 +++++++++++++++++++ .../department/specs/getLeaves.spec.js | 13 +----- 5 files changed, 96 insertions(+), 12 deletions(-) create mode 100644 e2e/paths/03-worker/01-department/01_summary.spec.js create mode 100644 e2e/paths/03-worker/01-department/02-basicData.spec.js diff --git a/e2e/helpers/puppeteer.js b/e2e/helpers/puppeteer.js index ac4f6cc02..1d484c823 100644 --- a/e2e/helpers/puppeteer.js +++ b/e2e/helpers/puppeteer.js @@ -28,7 +28,7 @@ export async function getBrowser() { args, defaultViewport: null, headless: headless, - slowMo: 1, // slow down by ms + slowMo: 40, // slow down by ms // ignoreDefaultArgs: ['--disable-extensions'], // executablePath: '/usr/bin/google-chrome-stable', // executablePath: '/usr/bin/firefox-developer-edition', diff --git a/e2e/helpers/selectors.js b/e2e/helpers/selectors.js index dcd9211f9..2f979aa4b 100644 --- a/e2e/helpers/selectors.js +++ b/e2e/helpers/selectors.js @@ -904,6 +904,18 @@ export default { extension: 'vn-worker-summary vn-one:nth-child(2) > vn-label-value:nth-child(5) > section > span', }, + department: { + firstDepartment: 'vn-worker-department-index vn-card > vn-treeview vn-treeview-childs vn-treeview-childs vn-treeview-childs a' + }, + departmentSummary: { + header: 'vn-worker-department-summary h5', + name: 'vn-worker-department-summary vn-horizontal > vn-one > vn-label-value:nth-child(3) > section > span', + code: 'vn-worker-department-summary vn-horizontal > vn-one > vn-label-value:nth-child(4) > section > span', + chat: 'vn-worker-department-summary vn-horizontal > vn-one > vn-label-value:nth-child(5) > section > span', + bossDepartment: 'vn-worker-department-summary vn-horizontal > vn-one > vn-label-value:nth-child(6) > section > span', + email: 'vn-worker-department-summary vn-horizontal > vn-one > vn-label-value:nth-child(7) > section > span', + clientFk: 'vn-worker-department-summary vn-horizontal > vn-one > vn-label-value:nth-child(8) > section > span', + }, workerBasicData: { name: 'vn-worker-basic-data vn-textfield[ng-model="$ctrl.worker.firstName"]', surname: 'vn-worker-basic-data vn-textfield[ng-model="$ctrl.worker.lastName"]', @@ -911,6 +923,13 @@ export default { locker: 'vn-worker-basic-data vn-input-number[ng-model="$ctrl.worker.locker"]', saveButton: 'vn-worker-basic-data button[type=submit]' }, + departmentBasicData: { + Name: 'vn-worker-department-basic-data vn-textfield[ng-model="$ctrl.department.name"]', + Code: 'vn-worker-department-basic-data vn-textfield[ng-model="$ctrl.department.code"]', + Chat: 'vn-worker-department-basic-data vn-textfield[ng-model="$ctrl.department.chat"]', + Email: 'vn-worker-department-basic-data vn-textfield[ng-model="$ctrl.department.notificationEmail"]', + saveButton: 'vn-worker-department-basic-data button[type=submit]' + }, workerNotes: { addNoteFloatButton: 'vn-worker-note vn-icon[icon="add"]', note: 'vn-note-worker-create vn-textarea[ng-model="$ctrl.note.text"]', diff --git a/e2e/paths/03-worker/01-department/01_summary.spec.js b/e2e/paths/03-worker/01-department/01_summary.spec.js new file mode 100644 index 000000000..094a184dd --- /dev/null +++ b/e2e/paths/03-worker/01-department/01_summary.spec.js @@ -0,0 +1,30 @@ +import selectors from '../../../helpers/selectors.js'; +import getBrowser from '../../../helpers/puppeteer'; + +describe('department summary path', () => { + let browser; + let page; + beforeAll(async() => { + browser = await getBrowser(); + page = browser.page; + await page.loginAndModule('hr','worker'); + await page.accessToSection('worker.department'); + await page.doSearch('INFORMATICA'); + await page.click(selectors.department.firstDepartment); + }); + + afterAll(async() => { + await browser.close(); + }); + + it('should reach the employee summary section and check all properties', async() => { + + expect(await page.waitToGetProperty(selectors.departmentSummary.header, 'innerText')).toEqual('INFORMATICA'); + expect(await page.getProperty(selectors.departmentSummary.name, 'innerText')).toEqual('INFORMATICA'); + expect(await page.getProperty(selectors.departmentSummary.code, 'innerText')).toEqual('IT'); + expect(await page.getProperty(selectors.departmentSummary.chat, 'innerText')).toEqual('informatica-cau'); + expect(await page.getProperty(selectors.departmentSummary.bossDepartment, 'innerText')).toEqual(''); + expect(await page.getProperty(selectors.departmentSummary.email, 'innerText')).toEqual('-'); + expect(await page.getProperty(selectors.departmentSummary.clientFk, 'innerText')).toEqual('-'); + }); +}); diff --git a/e2e/paths/03-worker/01-department/02-basicData.spec.js b/e2e/paths/03-worker/01-department/02-basicData.spec.js new file mode 100644 index 000000000..8a31ab0f4 --- /dev/null +++ b/e2e/paths/03-worker/01-department/02-basicData.spec.js @@ -0,0 +1,44 @@ +import getBrowser from '../../../helpers/puppeteer'; +import selectors from '../../../helpers/selectors.js'; + +const $ = { + form: 'vn-worker-department-basic-data form', +}; + +fdescribe('department summary path', () => { + let browser; + let page; + beforeAll(async() => { + browser = await getBrowser(); + page = browser.page; + await page.loginAndModule('hr', 'worker'); + await page.accessToSection('worker.department'); + await page.doSearch('INFORMATICA'); + await page.click(selectors.department.firstDepartment); + }); + + beforeEach(async() => { + await page.accessToSection('worker.department.card.basicData'); + }); + + afterAll(async() => { + await browser.close(); + }); + + it(`should edit the item basic data and confirm the item data was edited`, async() => { + const values = { + Name: 'Informatica', + Code: 'IT', + Chat: 'informatica-cau', + Email: 'it@verdnatura.es', + }; + + const message = await page.sendForm($.form, values); + await page.reloadSection('worker.department.card.basicData'); + const formValues = await page.fetchForm($.form, Object.keys(values)); + await page.click(selectors.departmentBasicData.saveButton); + + expect(message.isSuccess).toBeTrue(); + expect(formValues).toEqual(values); + }); +}); diff --git a/modules/worker/back/methods/department/specs/getLeaves.spec.js b/modules/worker/back/methods/department/specs/getLeaves.spec.js index 4ebadbb02..5972a9b4c 100644 --- a/modules/worker/back/methods/department/specs/getLeaves.spec.js +++ b/modules/worker/back/methods/department/specs/getLeaves.spec.js @@ -2,17 +2,8 @@ const models = require('vn-loopback/server/server').models; describe('department getLeaves()', () => { it('should return the department and the childs containing the search value', async() => { - const tx = await models.Zone.beginTransaction({}); + let result = await models.Department.getLeaves(null, 'INFORMATICA'); - try { - let result = await models.Zone.getLeaves(null, '31'); - - expect(result.length).toEqual(1); - - await tx.rollback(); - } catch (e) { - await tx.rollback(); - throw e; - } + expect(result.length).toEqual(1); }); });