Publication

This commit is contained in:
Peter Maquiran
2021-07-14 15:38:58 +01:00
parent 8c859834aa
commit 81f10a377c
7 changed files with 47 additions and 26 deletions
-1
View File
@@ -9,7 +9,6 @@
"build": "ng build", "build": "ng build",
"lint": "ng lint", "lint": "ng lint",
"e2e": "ng e2e", "e2e": "ng e2e",
"nice": "node server.js",
"test": "jest --detectOpenHandles --runInBand", "test": "jest --detectOpenHandles --runInBand",
"test:prof": "ionic build --prod && npm run test", "test:prof": "ionic build --prod && npm run test",
"dev": "lite-server --baseDir=www" "dev": "lite-server --baseDir=www"
+3 -3
View File
@@ -7,7 +7,7 @@ export class Publication{
Title: string; Title: string;
Message: string; Message: string;
DatePublication: Date; DatePublication: Date;
OriginalFileName: string; OriginalFileName?: string;
FileBase64:string; FileBase64?:string;
FileExtension: string; FileExtension?: string;
} }
@@ -148,6 +148,8 @@ export class NewPublicationPage implements OnInit {
if(this.Form.invalid) return false if(this.Form.invalid) return false
if(this.publicationType == '3') { if(this.publicationType == '3') {
console.log(this.navParams.get('publication')); console.log(this.navParams.get('publication'));
@@ -180,7 +182,8 @@ export class NewPublicationPage implements OnInit {
} }
} }
else { else if (!this.publication.OriginalFileName) {
this.publication = { this.publication = {
DateIndex: this.publication.DateIndex, DateIndex: this.publication.DateIndex,
DocumentId:this.publication.DocumentId, DocumentId:this.publication.DocumentId,
@@ -188,9 +191,9 @@ export class NewPublicationPage implements OnInit {
Title: this.pub.Title, Title: this.pub.Title,
Message: this.pub.Message, Message: this.pub.Message,
DatePublication: this.publication.DatePublication, DatePublication: this.publication.DatePublication,
OriginalFileName: this.publication.OriginalFileName, // OriginalFileName: this.publication.OriginalFileName,
FileBase64: this.publication.FileBase64, // FileBase64: this.publication.FileBase64,
FileExtension: 'jpeg', // FileExtension: 'jpeg',
} }
/* console.log('Edit - keep image'); /* console.log('Edit - keep image');
console.log(this.publication); */ console.log(this.publication); */
@@ -264,6 +267,8 @@ export class NewPublicationPage implements OnInit {
else if(this.publicationType == '3') { else if(this.publicationType == '3') {
this.publicationTitle = 'Editar Publicação'; this.publicationTitle = 'Editar Publicação';
this.pub = this.navParams.get('publication'); this.pub = this.navParams.get('publication');
console.log(this.pub, 'pub')
} }
} }
@@ -4,7 +4,7 @@ import { EventPerson } from 'src/app/models/eventperson.model';
import { EventsService } from 'src/app/services/events.service'; import { EventsService } from 'src/app/services/events.service';
import { AttachmentsService } from 'src/app/services/attachments.service'; import { AttachmentsService } from 'src/app/services/attachments.service';
import { Event } from 'src/app/models/event.model'; 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 { removeDuplicate } from 'src/plugin/removeDuplicate.js'
import { SearchPage } from 'src/app/pages/search/search.page'; import { SearchPage } from 'src/app/pages/search/search.page';
import { SearchDocument } from "src/app/models/search-document"; import { SearchDocument } from "src/app/models/search-document";
@@ -154,7 +154,9 @@ export class NewPublicationPage implements OnInit {
if(this.Form.invalid) return false if(this.Form.invalid) return false
if(this.publicationType == '3'){
if(this.publicationType == '3') {
if(this.capturedImage != '') { if(this.capturedImage != '') {
this.publication = { this.publication = {
@@ -168,12 +170,12 @@ export class NewPublicationPage implements OnInit {
FileBase64: this.capturedImage, FileBase64: this.capturedImage,
FileExtension: 'jpeg', FileExtension: 'jpeg',
} }
console.log('Edit change image'); console.log('Edit change image');
console.log(this.publication); console.log(this.publication);
const loader = this.toastService.loading() const loader = this.toastService.loading()
try { try {
console.log(this.publication);
await this.publications.UpdatePublication(this.publication.ProcessId, this.publication).toPromise() await this.publications.UpdatePublication(this.publication.ProcessId, this.publication).toPromise()
this.toastService.successMessage("Publicação criado") this.toastService.successMessage("Publicação criado")
@@ -187,6 +189,7 @@ export class NewPublicationPage implements OnInit {
} }
else{ else{
this.publication = { this.publication = {
DateIndex: this.publication.DateIndex, DateIndex: this.publication.DateIndex,
DocumentId:this.publication.DocumentId, DocumentId:this.publication.DocumentId,
@@ -259,7 +262,7 @@ export class NewPublicationPage implements OnInit {
else if(this.publicationType == '2'){ else if(this.publicationType == '2'){
this.publicationTitle = 'Nova Publicação'; this.publicationTitle = 'Nova Publicação';
} }
else if(this.publicationType == '3'){ else if(this.publicationType == '3') {
this.publicationTitle = 'Editar Publicação'; this.publicationTitle = 'Editar Publicação';
this.pub = this.publication; this.pub = this.publication;
} }
+24 -2
View File
@@ -8,19 +8,41 @@ describe('Puppeteer tests', () => {
// await page.goto(process.env.PUPPETEER_HOST) // await page.goto(process.env.PUPPETEER_HOST)
}) })
test('Login', async()=> {
await loginTest(page)
},30000)
test('[table] Open create event component', async () => { test('[table] Open create event component', async () => {
await page.setViewport({width: 1200, height: 720}); await page.setViewport({width: 1200, height: 720});
await page.goto(process.env.PUPPETEER_HOST); // wait until page load await page.goto(process.env.PUPPETEER_HOST); // wait until page load
await page.waitForSelector('ion-app') 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 // wait for footer button
await page.click('ion-tab-bar ion-tab-button:nth-child(2)') await page.click('ion-tab-bar ion-tab-button:nth-child(2)')
await page.waitForSelector('app-agenda')
// click add event // click add event
await page.click('ion-content ion-row .cy-add-event') await page.click('ion-content ion-row .cy-add-event')
// // wait for component
await page.waitForSelector('app-new-event') await page.waitForSelector('app-new-event')
expect(3 + 2).toBe(5); expect(3 + 2).toBe(5);
+4 -12
View File
@@ -45,16 +45,12 @@ export const loginTest = async (page) => {
} }
} }
describe('Puppeteer tests', () => { describe('Puppeteer tests', () => {
beforeAll(async () => { beforeAll(async () => {
// await page.goto(process.env.PUPPETEER_HOST) // await page.goto(process.env.PUPPETEER_HOST)
}) })
test('[table] Clear Code button and set pin', async () => { test('[table] Clear Code button and set pin', async () => {
const pathname = await page.evaluate( () => window.location.pathname) const pathname = await page.evaluate( () => window.location.pathname)
@@ -67,11 +63,11 @@ describe('Puppeteer tests', () => {
await page.evaluate( () => { await page.evaluate( () => {
let a: HTMLInputElement = document.querySelector('input[type="text"]') let a: HTMLInputElement = document.querySelector('input[type="text"]')
a.value = '' a.value = ''
let b: HTMLInputElement = document.querySelector('input[type="password"') let b: HTMLInputElement = document.querySelector('input[type="password"')
b.value = '' b.value = ''
}) })
await page.type('input[type="text"]', environment.defaultuser); await page.type('input[type="text"]', environment.defaultuser);
@@ -105,9 +101,5 @@ describe('Puppeteer tests', () => {
expect(3 + 2).toBe(5); expect(3 + 2).toBe(5);
},30000); },30000);
}); });