diff --git a/package.json b/package.json index 6f21d5148..0213b0e69 100644 --- a/package.json +++ b/package.json @@ -5,12 +5,12 @@ "homepage": "https://ionicframework.com/", "scripts": { "ng": "ng", - "start": "ng serve", + "start": "ng serve --port 4200", "build": "ng build", "lint": "ng lint", "e2e": "ng e2e", "nice": "node server.js", - "test": "jest --detectOpenHandles --runInBand" + "test": "jest --runInBand" }, "private": true, "dependencies": { diff --git a/src/app/pages/agenda/agenda.page.html b/src/app/pages/agenda/agenda.page.html index f7cc9be84..1c14d247b 100644 --- a/src/app/pages/agenda/agenda.page.html +++ b/src/app/pages/agenda/agenda.page.html @@ -58,7 +58,7 @@ - + diff --git a/src/app/pages/gabinete-digital/expediente/expedient-task-modal/expedient-task-modal.page.ts b/src/app/pages/gabinete-digital/expediente/expedient-task-modal/expedient-task-modal.page.ts index 99ba6b078..15a84edc6 100644 --- a/src/app/pages/gabinete-digital/expediente/expedient-task-modal/expedient-task-modal.page.ts +++ b/src/app/pages/gabinete-digital/expediente/expedient-task-modal/expedient-task-modal.page.ts @@ -255,120 +255,11 @@ export class ExpedientTaskModalPage implements OnInit { this.dispatchFolder.SubjectTypes = this.selectedTypes; - - switch (this.loggeduser.Profile) { - case 'MDGPR': - if(this.taskParticipants.length > 0) { - switch (this.taskType) { - case '0': - this.postData = { - DistributionType: "Paralelo", - CountryCode: 'AO', - Priority: this.postData.Priority, - UserEmail: this.loggeduser.Email, - UsersSelected: attendees, - DispatchFolder: this.dispatchFolder, - AttachmentList: docs, - } + const loader = this.toastService.loading() - const loader = this.toastService.loading() - try { - let action_despacho = { - "serialNumber": this.task.serialNumber, - "action": "Tratado", - "ActionTypeId": 94, - "dataFields": { - "Note": "", - } - } - console.log(this.postData); - - this.taskResult = await this.processes.postDespatcho(this.postData).toPromise(); - - loader.remove() - await this.toastService.successMessage('Processo efetuado'); - this.modalController.dismiss(); - - } catch (error) { - loader.remove() - await this.toastService.badRequest('Processo não efetuado') - } finally { - loader.remove() - } - console.log('this.taskResult', this.taskResult); - break; - - case '1': - this.postData = { - DistributionType: "Paralelo", - CountryCode: 'AO', - Priority: this.postData.Priority, - UserEmail: this.loggeduser.Email, - UsersSelected: attendees, - DispatchFolder: this.dispatchFolder, - AttachmentList: docs - } - - try { - let action_parecer = { - "serialNumber": this.task.serialNumber, - "action": "Tratado", - "ActionTypeId": 92, - "dataFields": { - "Note": "", - } - } - this.taskResult = await this.processes.postParecer(this.postData).toPromise(); - loader.remove() - await this.toastService.successMessage('Pedido enviado'); - this.modalController.dismiss(action_parecer); - - } catch (error) { - loader.remove() - await this.toastService.badRequest('Processo não efetuado') - } - break; - case '2': - this.postData = { - DistributionType: "Paralelo", - CountryCode: 'AO', - Priority: this.postData.Priority, - UserEmail: this.loggeduser.Email, - UsersSelected: attendees, - DispatchFolder: this.dispatchFolder, - AttachmentList: docs - } - //console.log(this.postData); - const loader1 = this.toastService.loading() - - try { - let action_deferimento = { - "serialNumber": this.task.serialNumber, - "action": "Tratado", - "ActionTypeId": 93, - "dataFields": { - "Note": "", - } - } - this.taskResult = await this.processes.postDeferimento(this.postData).toPromise(); - await this.toastService.successMessage('Processo efetuado'); - this.modalController.dismiss(action_deferimento); - } catch (error) { - - await this.toastService.badRequest('Processo não efetuado') - } finally { - loader1.remove() - } - - console.log('this.taskResult', this.taskResult); - break; - } - } - else { - this.alertController.presentAlert("Lista de i-ntervenientes vazia. Por favor, adicione 1 ou mais intervenientes."); - } - break; - case 'PR': + switch (this.loggeduser.Profile) { + case 'MDGPR': + if(this.taskParticipants.length > 0) { switch (this.taskType) { case '0': this.postData = { @@ -380,27 +271,16 @@ export class ExpedientTaskModalPage implements OnInit { DispatchFolder: this.dispatchFolder, AttachmentList: docs, } + console.log(this.postData); - const loader = this.toastService.loading() try { - let action_despacho_pr = { - "serialNumber": this.task.serialNumber, - "action": "Tratado", - "ActionTypeId": 99999881 , - "dataFields": { - "Note": "", - } - } - loader.remove() - this.taskResult = await this.processes.postDespatchoPr(this.postData).toPromise(); - + this.taskResult = await this.processes.postDespatcho(this.postData).toPromise(); await this.toastService.successMessage('Processo efetuado'); - this.modalController.dismiss(action_despacho_pr); - + this.modalController.dismiss(); + } catch (error) { - loader.remove() await this.toastService.badRequest('Processo não efetuado') } finally { loader.remove() @@ -420,33 +300,136 @@ export class ExpedientTaskModalPage implements OnInit { AttachmentList: docs } - const loader2 = this.toastService.loading() + let action_parecer = { + "serialNumber": this.task.serialNumber, + "action": "Tratado", + "ActionTypeId": 92, + "dataFields": { + "Note": "", + } + } try { - let action_parecer_pr = { - "serialNumber": this.task.serialNumber, - "action": "Tratado", - "ActionTypeId": 99999881, - "dataFields": { - "Note": "", - } - } - - this.taskResult = await this.processes.postParecerPr(this.postData).toPromise(); + this.taskResult = await this.processes.postParecer(this.postData).toPromise(); + await this.toastService.successMessage('Pedido enviado'); + this.modalController.dismiss(action_parecer); - await this.toastService.badRequest('Processo não efetuado'); - this.modalController.dismiss(action_parecer_pr); - } catch (error) { - await this.toastService.badRequest('Processo não efetuado') } finally { - loader2.remove() + loader.remove() } break; + case '2': + this.postData = { + DistributionType: "Paralelo", + CountryCode: 'AO', + Priority: this.postData.Priority, + UserEmail: this.loggeduser.Email, + UsersSelected: attendees, + DispatchFolder: this.dispatchFolder, + AttachmentList: docs + } + //console.log(this.postData); + let action_deferimento = { + "serialNumber": this.task.serialNumber, + "action": "Tratado", + "ActionTypeId": 93, + "dataFields": { + "Note": "", + } + } + + try { + + this.taskResult = await this.processes.postDeferimento(this.postData).toPromise(); + this.toastService.successMessage('Processo efetuado'); + this.modalController.dismiss(action_deferimento); + } catch (error) { + await this.toastService.badRequest('Processo não efetuado') + } finally { + loader.remove() } + + console.log('this.taskResult', this.taskResult); break; + } } + else { + this.alertController.presentAlert("Lista de i-ntervenientes vazia. Por favor, adicione 1 ou mais intervenientes."); + } + break; + case 'PR': + switch (this.taskType) { + case '0': + this.postData = { + DistributionType: "Paralelo", + CountryCode: 'AO', + Priority: this.postData.Priority, + UserEmail: this.loggeduser.Email, + UsersSelected: attendees, + DispatchFolder: this.dispatchFolder, + AttachmentList: docs, + } + console.log(this.postData); + + let action_despacho_pr = { + "serialNumber": this.task.serialNumber, + "action": "Tratado", + "ActionTypeId": 99999881 , + "dataFields": { + "Note": "", + } + } + + try { + this.taskResult = await this.processes.postDespatchoPr(this.postData).toPromise(); + await this.toastService.successMessage('Processo efetuado'); + this.modalController.dismiss(action_despacho_pr); + } catch (error) { + await this.toastService.badRequest('Processo não efetuado') + } finally { + loader.remove() + } + + console.log('this.taskResult', this.taskResult); + break; + + case '1': + this.postData = { + DistributionType: "Paralelo", + CountryCode: 'AO', + Priority: this.postData.Priority, + UserEmail: this.loggeduser.Email, + UsersSelected: attendees, + DispatchFolder: this.dispatchFolder, + AttachmentList: docs + } + + let action_parecer_pr = { + "serialNumber": this.task.serialNumber, + "action": "Tratado", + "ActionTypeId": 99999881, + "dataFields": { + "Note": "", + } + } + + try { + + this.taskResult = await this.processes.postParecerPr(this.postData).toPromise(); + await this.toastService.badRequest('Processo não efetuado'); + this.modalController.dismiss(action_parecer_pr); + } catch (error) { + + await this.toastService.badRequest('Processo não efetuado') + } finally { + loader.remove() + } + break; + } + break; + } } getAttachments() { diff --git a/src/app/shared/agenda/new-event/new-event.page.html b/src/app/shared/agenda/new-event/new-event.page.html index b9ff5d63e..2f1add160 100644 --- a/src/app/shared/agenda/new-event/new-event.page.html +++ b/src/app/shared/agenda/new-event/new-event.page.html @@ -181,8 +181,6 @@ - - {{ this.postEvent.EventRecurrence.Type }} diff --git a/src/app/shared/agenda/new-event/new-event.page.ts b/src/app/shared/agenda/new-event/new-event.page.ts index 444e3c6f5..93bfa0e5c 100644 --- a/src/app/shared/agenda/new-event/new-event.page.ts +++ b/src/app/shared/agenda/new-event/new-event.page.ts @@ -134,8 +134,8 @@ export class NewEventPage implements OnInit { this.dateAdapter.setLocale('pt'); this.loggeduser = userService.ValidatedUser; - this.dateControlStart = new FormControl(moment(new Date())); - this.dateControlEnd = new FormControl(moment(new Date(new Date().getTime() + 15 * 60000))); + this.postEvent.StartDate = new Date(); + this.postEvent.EndDate = new Date(new Date().getTime() + 15 * 60000); } ngOnInit() { @@ -342,8 +342,6 @@ export class NewEventPage implements OnInit { restoreDatepickerData() { if (this.postEvent) { - this.dateControlStart = new FormControl(moment(this.postEvent.StartDate, "DD MM YYYY hh:mm")); - this.dateControlEnd = new FormControl(moment(this.postEvent.EndDate, "DD MM YYYY hh:mm")); this.dateControlOccurrence = new FormControl(moment(this.postEvent.EventRecurrence.LastOccurrence, "DD MM YYYY hh:mm")) } } diff --git a/test/login.spec.ts b/test/0-login.spec.ts similarity index 62% rename from test/login.spec.ts rename to test/0-login.spec.ts index ef4ec7ae8..ef6493520 100644 --- a/test/login.spec.ts +++ b/test/0-login.spec.ts @@ -4,36 +4,10 @@ describe('Puppeteer tests', () => { beforeAll(async () => { // await page.goto(process.env.PUPPETEER_HOST) + }) - test('[table] login', async () => { - // const browser = await puppeteer.launch({headless: false}); - await page.setViewport({width: 1200, height: 720}); - await page.goto(process.env.PUPPETEER_HOST); // wait until page load - await page.waitForSelector('.btn-ok') - - - await page.evaluate( () => { - let a: HTMLInputElement = document.querySelector('input[type="text"]') - a.value = '' - - let b: HTMLInputElement = document.querySelector('input[type="password"') - b.value = '' - }) - - await page.type('input[type="text"]', environment.defaultuser); - await page.type('input[type="password"]', environment.defaultuserpwd); - // click and wait for navigation - await Promise.all([ - page.click('.btn-ok'), - // page.waitForNavigation({ waitUntil: 'networkidle0' }), - ]); - - await page.waitForSelector('.circle') - - expect(3 + 2).toBe(5); - },30000); test('[table] Clear Code button and set pin', async () => { diff --git a/test/Xgenda.spec.ts b/test/Xgenda.spec.ts new file mode 100644 index 000000000..1fec9e3d3 --- /dev/null +++ b/test/Xgenda.spec.ts @@ -0,0 +1,29 @@ +import { environment } from '../src/environments/environment' + +describe('Puppeteer tests', () => { + + beforeAll(async () => { + // await page.goto(process.env.PUPPETEER_HOST) + }) + + + test('[table] create event', async () => { + + // const browser = await puppeteer.launch({headless: false}); + await page.setViewport({width: 1200, height: 720}); + await page.goto(process.env.PUPPETEER_HOST); // wait until page load + await page.waitForSelector('ion-tab-bar ion-tab-button:nth-child(3)') + await page.click('ion-tab-bar ion-tab-button:nth-child(3)') + + await page.waitForSelector('ion-content ion-row .cy-add-event') + await page.waitForSelector('app-new-event') + + expect(3 + 2).toBe(5); + },30000); + + + + + +}); + diff --git a/test/sdfasd.spec.ts b/test/sdfasd.spec.ts deleted file mode 100644 index 1788599e4..000000000 --- a/test/sdfasd.spec.ts +++ /dev/null @@ -1,17 +0,0 @@ - -import { environment } from './../src/environments/environment' - -describe('Puppeteer tests', () => { - - beforeAll(async () => { - // await page.goto(process.env.PUPPETEER_HOST) - }) - - test('login', async () => { - - - expect(3 + 2).toBe(5); - }, 30000); - -}); -