Follow @roschaefer PR review suggestions

- create mapping for expectedValues in post.js
- check from image/jpeg and compress, if not just pass to backend as is
This commit is contained in:
mattwr18 2020-02-14 19:49:00 +01:00
parent fa02a4dd33
commit d8d1db389a
2 changed files with 10 additions and 8 deletions

View File

@ -5,7 +5,7 @@ import orderBy from 'lodash/orderBy'
const languages = orderBy(locales, 'name') const languages = orderBy(locales, 'name')
const narratorAvatar = const narratorAvatar =
"https://s3.amazonaws.com/uifaces/faces/twitter/nerrsoft/128.jpg"; "https://s3.amazonaws.com/uifaces/faces/twitter/nerrsoft/128.jpg";
let expectedValue = { title: 'new post', content: 'new post content', src: 'onourjourney' }
When("I type in a comment with {int} characters", size => { When("I type in a comment with {int} characters", size => {
var c=""; var c="";
for (var i = 0; i < size; i++) { for (var i = 0; i < size; i++) {
@ -119,13 +119,15 @@ Then("I add all required fields", () => {
}) })
Then("the post was saved successfully with the {string} teaser image", condition => { Then("the post was saved successfully with the {string} teaser image", condition => {
if (condition === 'change')
expectedValue = { title: 'to be updated', content: 'successfully updated', src: 'humanconnection' }
cy.get(".ds-card-content > .ds-heading") cy.get(".ds-card-content > .ds-heading")
.should("contain", condition === 'new' ? 'new post' : 'to be updated') .should("contain", expectedValue.title)
.get(".content") .get(".content")
.should("contain", condition === 'new' ? 'new post content' : 'successfully updated') .should("contain", expectedValue.content)
.get('.post-page img') .get('.post-page img')
.should("have.attr", "src") .should("have.attr", "src")
.and("contains", condition === 'new' ? "onourjourney" : "humanconnection") .and("contains", expectedValue.src)
}) })
Then("the first image should be removed from the preview", () => { Then("the first image should be removed from the preview", () => {

View File

@ -114,13 +114,13 @@ export default {
}, },
cropImage() { cropImage() {
this.showCropper = false this.showCropper = false
if (this.file.type === 'image/png' || this.file.type === 'image/svg+xml') { if (this.file.type === 'image/jpeg') {
this.uploadSvgOrPng()
} else {
this.uploadJpeg() this.uploadJpeg()
} else {
this.uploadOtherImageType()
} }
}, },
uploadSvgOrPng() { uploadOtherImageType() {
this.imageAspectRatio = this.file.width / this.file.height || 1.0 this.imageAspectRatio = this.file.width / this.file.height || 1.0
this.image = new Image() this.image = new Image()
this.image.src = this.file.dataURL this.image.src = this.file.dataURL