From 81f10a377c13c9a6da253f67fb3fc0eb91831617 Mon Sep 17 00:00:00 2001 From: Peter Maquiran Date: Wed, 14 Jul 2021 15:38:58 +0100 Subject: [PATCH] Publication --- package.json | 1 - src/app/models/publication.ts | 6 ++--- .../new-publication/new-publication.page.ts | 13 +++++++--- .../shared/agenda/new-event/new-event.page.ts | 2 +- .../new-publication/new-publication.page.ts | 9 ++++--- test/Agenda.spec.ts | 26 +++++++++++++++++-- test/login.spec.ts | 16 +++--------- 7 files changed, 47 insertions(+), 26 deletions(-) diff --git a/package.json b/package.json index fae6a5842..a2eee7177 100644 --- a/package.json +++ b/package.json @@ -9,7 +9,6 @@ "build": "ng build", "lint": "ng lint", "e2e": "ng e2e", - "nice": "node server.js", "test": "jest --detectOpenHandles --runInBand", "test:prof": "ionic build --prod && npm run test", "dev": "lite-server --baseDir=www" diff --git a/src/app/models/publication.ts b/src/app/models/publication.ts index 6cfebc69f..728f6a288 100644 --- a/src/app/models/publication.ts +++ b/src/app/models/publication.ts @@ -7,7 +7,7 @@ export class Publication{ Title: string; Message: string; DatePublication: Date; - OriginalFileName: string; - FileBase64:string; - FileExtension: string; + OriginalFileName?: string; + FileBase64?:string; + FileExtension?: string; } \ No newline at end of file diff --git a/src/app/pages/publications/new-publication/new-publication.page.ts b/src/app/pages/publications/new-publication/new-publication.page.ts index af5502478..33bf31197 100644 --- a/src/app/pages/publications/new-publication/new-publication.page.ts +++ b/src/app/pages/publications/new-publication/new-publication.page.ts @@ -148,6 +148,8 @@ export class NewPublicationPage implements OnInit { if(this.Form.invalid) return false + + if(this.publicationType == '3') { console.log(this.navParams.get('publication')); @@ -180,7 +182,8 @@ export class NewPublicationPage implements OnInit { } } - else { + else if (!this.publication.OriginalFileName) { + this.publication = { DateIndex: this.publication.DateIndex, DocumentId:this.publication.DocumentId, @@ -188,9 +191,9 @@ export class NewPublicationPage implements OnInit { Title: this.pub.Title, Message: this.pub.Message, DatePublication: this.publication.DatePublication, - OriginalFileName: this.publication.OriginalFileName, - FileBase64: this.publication.FileBase64, - FileExtension: 'jpeg', + // OriginalFileName: this.publication.OriginalFileName, + // FileBase64: this.publication.FileBase64, + // FileExtension: 'jpeg', } /* console.log('Edit - keep image'); console.log(this.publication); */ @@ -264,6 +267,8 @@ export class NewPublicationPage implements OnInit { else if(this.publicationType == '3') { this.publicationTitle = 'Editar Publicação'; this.pub = this.navParams.get('publication'); + + console.log(this.pub, 'pub') } } 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 f467fe0c9..a19dbb451 100644 --- a/src/app/shared/agenda/new-event/new-event.page.ts +++ b/src/app/shared/agenda/new-event/new-event.page.ts @@ -4,7 +4,7 @@ import { EventPerson } from 'src/app/models/eventperson.model'; import { EventsService } from 'src/app/services/events.service'; import { AttachmentsService } from 'src/app/services/attachments.service'; import { Event } from 'src/app/models/event.model'; -import { AnimationController, ModalController } from '@ionic/angular'; +import { ModalController } from '@ionic/angular'; import { removeDuplicate } from 'src/plugin/removeDuplicate.js' import { SearchPage } from 'src/app/pages/search/search.page'; import { SearchDocument } from "src/app/models/search-document"; diff --git a/src/app/shared/publication/new-publication/new-publication.page.ts b/src/app/shared/publication/new-publication/new-publication.page.ts index 7fab41318..af6fd2e55 100644 --- a/src/app/shared/publication/new-publication/new-publication.page.ts +++ b/src/app/shared/publication/new-publication/new-publication.page.ts @@ -154,7 +154,9 @@ export class NewPublicationPage implements OnInit { if(this.Form.invalid) return false - if(this.publicationType == '3'){ + + + if(this.publicationType == '3') { if(this.capturedImage != '') { this.publication = { @@ -168,12 +170,12 @@ export class NewPublicationPage implements OnInit { FileBase64: this.capturedImage, FileExtension: 'jpeg', } + console.log('Edit change image'); console.log(this.publication); const loader = this.toastService.loading() try { - console.log(this.publication); await this.publications.UpdatePublication(this.publication.ProcessId, this.publication).toPromise() this.toastService.successMessage("Publicação criado") @@ -187,6 +189,7 @@ export class NewPublicationPage implements OnInit { } else{ + this.publication = { DateIndex: this.publication.DateIndex, DocumentId:this.publication.DocumentId, @@ -259,7 +262,7 @@ export class NewPublicationPage implements OnInit { else if(this.publicationType == '2'){ this.publicationTitle = 'Nova Publicação'; } - else if(this.publicationType == '3'){ + else if(this.publicationType == '3') { this.publicationTitle = 'Editar Publicação'; this.pub = this.publication; } diff --git a/test/Agenda.spec.ts b/test/Agenda.spec.ts index e5f8a6d25..18f0d9f42 100644 --- a/test/Agenda.spec.ts +++ b/test/Agenda.spec.ts @@ -8,19 +8,41 @@ describe('Puppeteer tests', () => { // await page.goto(process.env.PUPPETEER_HOST) }) + test('Login', async()=> { + await loginTest(page) + },30000) + test('[table] Open create event component', async () => { await page.setViewport({width: 1200, height: 720}); await page.goto(process.env.PUPPETEER_HOST); // wait until page load await page.waitForSelector('ion-app') - await loginTest(page) + // wait for footer button + await page.click('ion-tab-bar ion-tab-button:nth-child(2)') + await page.waitForSelector('app-agenda') + + // click add event + await page.click('ion-content ion-row .cy-add-event') + // wait for component + await page.waitForSelector('app-new-event') + + expect(3 + 2).toBe(5); + },30000); + + + test('[table] Create Event', async () => { + + await page.setViewport({width: 1200, height: 720}); + await page.goto(process.env.PUPPETEER_HOST); // wait until page load + await page.waitForSelector('ion-app') // wait for footer button await page.click('ion-tab-bar ion-tab-button:nth-child(2)') + await page.waitForSelector('app-agenda') // click add event await page.click('ion-content ion-row .cy-add-event') - // + // wait for component await page.waitForSelector('app-new-event') expect(3 + 2).toBe(5); diff --git a/test/login.spec.ts b/test/login.spec.ts index fbf520bf7..cbd2a856c 100644 --- a/test/login.spec.ts +++ b/test/login.spec.ts @@ -45,16 +45,12 @@ export const loginTest = async (page) => { } } - describe('Puppeteer tests', () => { beforeAll(async () => { // await page.goto(process.env.PUPPETEER_HOST) - }) - - test('[table] Clear Code button and set pin', async () => { const pathname = await page.evaluate( () => window.location.pathname) @@ -67,11 +63,11 @@ describe('Puppeteer tests', () => { await page.evaluate( () => { - let a: HTMLInputElement = document.querySelector('input[type="text"]') - a.value = '' + let a: HTMLInputElement = document.querySelector('input[type="text"]') + a.value = '' - let b: HTMLInputElement = document.querySelector('input[type="password"') - b.value = '' + let b: HTMLInputElement = document.querySelector('input[type="password"') + b.value = '' }) await page.type('input[type="text"]', environment.defaultuser); @@ -105,9 +101,5 @@ describe('Puppeteer tests', () => { expect(3 + 2).toBe(5); },30000); - - - - });