Commit 59048205 authored by Marcelo Rivera's avatar Marcelo Rivera Committed by Mark Harding
Browse files

[Sprint/KiltedKoala] (fix): blog e2e test

parent 4be406ce
Loading
Loading
Loading
Loading
+8.1 KiB
Loading image diff...
+44 −4
Original line number Original line Diff line number Diff line
@@ -24,7 +24,49 @@ context('Blogs', () => {
    cy.get('.m-blog--edit--error').contains('Error: You must upload a banner');
    cy.get('.m-blog--edit--error').contains('Error: You must upload a banner');
  })
  })


  it("should not be able to create a new blog if the channel doesn't have an avatar", () => {
    cy.visit('/blog/edit/new');

    cy.uploadFile('minds-banner #file', '../fixtures/international-space-station-1776401_1920.jpg', 'image/jpg');

    cy.get('minds-textarea .m-editor').type('Title');

    cy.get('m-inline-editor .medium-editor-element').type('Content\n');

    // click on plus button
    cy.get('.medium-editor-element > .medium-insert-buttons > button.medium-insert-buttons-show').click();
    // click on camera
    cy.get('ul.medium-insert-buttons-addons > li > button.medium-insert-action:first-child').contains('photo_camera').click();
    // upload the image
    cy.uploadFile('.medium-media-file-input', '../fixtures/international-space-station-1776401_1920.jpg', 'image/jpg');

    // open license dropdown & select first license
    cy.get('.m-license-info select').select('All rights reserved');

    cy.wait(1000);

    cy.server();
    cy.route("POST", "**!/api/v1/blog/new").as("newBlog");

    cy.get('.m-button--submit').click({ force: true }); // TODO: Investigate why disabled flag is being detected

    cy.get('h1.m-blog--edit--error').contains('Error: Please ensure your channel has an avatar before creating a blog');
  });

  it('should be able to create a new blog', () => {
  it('should be able to create a new blog', () => {

    // upload avatar first
    cy.visit(`/${Cypress.env().username}`);

    cy.get('.m-channel--name .minds-button-edit button:first-child').click();

    cy.wait(100);

    cy.uploadFile('.minds-avatar input[type=file]', '../fixtures/avatar.jpeg', 'image/jpg');

    cy.get('.m-channel--name .minds-button-edit button:last-child').click();

    // create blog
    cy.visit('/blog/edit/new');
    cy.visit('/blog/edit/new');


    cy.uploadFile('minds-banner #file', '../fixtures/international-space-station-1776401_1920.jpg', 'image/jpg');
    cy.uploadFile('minds-banner #file', '../fixtures/international-space-station-1776401_1920.jpg', 'image/jpg');
@@ -75,8 +117,6 @@ context('Blogs', () => {


    cy.get('.m-button--submit').click({ force: true }); // TODO: Investigate why disabled flag is being detected
    cy.get('.m-button--submit').click({ force: true }); // TODO: Investigate why disabled flag is being detected


    // Blogs will not save, nor return error, if a user doesn't have an avatar

    cy.location('pathname', { timeout: 30000 })
    cy.location('pathname', { timeout: 30000 })
      .should('contains', `/${Cypress.env().username}/blog`);
      .should('contains', `/${Cypress.env().username}/blog`);


+11 −4
Original line number Original line Diff line number Diff line
@@ -235,6 +235,8 @@ export class BlogEdit {
    if (!this.validate())
    if (!this.validate())
      return;
      return;


    this.error = '';

    this.inlineEditor.prepareForSave().then(() => {
    this.inlineEditor.prepareForSave().then(() => {
      const blog = Object.assign({}, this.blog);
      const blog = Object.assign({}, this.blog);


@@ -248,9 +250,14 @@ export class BlogEdit {
      this.check_for_banner().then(() => {
      this.check_for_banner().then(() => {
        this.upload.post('api/v1/blog/' + this.guid, [this.banner], blog)
        this.upload.post('api/v1/blog/' + this.guid, [this.banner], blog)
          .then((response: any) => {
          .then((response: any) => {
            this.router.navigate(response.route ? ['/' + response.route]: ['/blog/view', response.guid]);
            this.canSave = true;
            this.inProgress = false;
            this.inProgress = false;
            this.canSave = true;

            if (response.status !== 'success') {
              this.error = response.message;
              return;
            }
            this.router.navigate(response.route ? ['/' + response.route]: ['/blog/view', response.guid]);
          })
          })
          .catch((e) => {
          .catch((e) => {
            this.canSave = true;
            this.canSave = true;