Commit b3966e9f authored by Juan Manuel Solaro's avatar Juan Manuel Solaro

(feat) e2e tests for scheduled activities

1 merge request!494WIP: epic/post-scheduler
Pipeline #78418806 running with stages
......@@ -50,6 +50,8 @@ context('Blogs', () => {
cy.get('.m-button--submit').click({ force: true }); // TODO: Investigate why disabled flag is being detected
cy.wait(1000);
cy.get('h1.m-blog--edit--error').contains('Error: Please ensure your channel has an avatar before creating a blog');
});
......@@ -131,6 +133,107 @@ context('Blogs', () => {
cy.get('m-post-menu button.minds-more').click();
cy.get('m-post-menu ul.minds-dropdown-menu li').contains('Delete').click();
cy.get('m-post-menu m-modal-confirm .mdl-button--colored').click();
});
})
it('should be able to create a new scheduled 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.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');
// click on hashtags dropdown
cy.get('.m-category-info m-hashtags-selector .m-dropdown--label-container').click();
// select #ART
cy.get('.m-category-info m-dropdown m-form-tags-input > div > span').contains('#art').click();
// type in another hashtag manually
cy.get('.m-category-info m-hashtags-selector m-form-tags-input input').type('hashtag{enter}').click();
// click away
cy.get('.m-category-info m-hashtags-selector .minds-bg-overlay').click();
// select visibility
cy.get('.m-visibility-info select').select('Loggedin');
// open metadata form
cy.get('.m-blog-edit--toggle-wrapper .m-blog-edit--toggle').contains('Metadata').click();
// set url slug
cy.get('.m-blog-edit--field input[name=slug]').type('123');
// set meta title
cy.get('.m-blog-edit--field input[name=custom_meta_title]').type('Test');
// set meta description
cy.get('.m-blog-edit--field textarea[name=custom_meta_description]').type('This is a test blog');
// set meta author
cy.get('.m-blog-edit--field input[name=custom_meta_author]').type('Minds Test');
// set as nsfw
cy.get('.m-mature-info a').click();
cy.get('.m-mature-info a span').contains('Mature content');
// set scheduled date
cy.get('.m-poster-date-selector--input').click();
cy.get('td.c-datepicker__day-body.c-datepicker__day--selected + td').click();
cy.get('a.c-btn.c-btn--flat.js-ok').click();
// get setted date to compare
let scheduledDate;
cy.get('div.m-poster-date-selector--input div.m-tooltip--bubble')
.invoke('text').then((text) => {
scheduledDate = text;
});
cy.wait(1000);
cy.get('.m-button--submit').click({ force: true }); // TODO: Investigate why disabled flag is being detected
cy.location('pathname', { timeout: 30000 })
.should('contains', `/${Cypress.env().username}/blog`);
cy.get('.m-blog--title').contains('Title');
cy.get('.minds-blog-body p').contains('Content');
cy.get('.m-license-info span').contains('all-rights-reserved');
cy.wait(1000);
// compare setted date with time_created
cy.get('div.m-blog-container div.mdl-grid div.minds-body span')
.invoke('text').then((text) => {
const time_created = new Date(text).getTime();
scheduledDate = new Date(scheduledDate).getTime();
expect(scheduledDate).to.equal(time_created);
});
// cleanup
//open dropdown
cy.get('m-post-menu button.minds-more').click();
cy.get('m-post-menu ul.minds-dropdown-menu li').contains('Delete').click();
cy.get('m-post-menu m-modal-confirm .mdl-button--colored').click();
});
})
......@@ -38,6 +38,60 @@ context('Newsfeed', () => {
cy.get('.minds-list > minds-activity:first-child m-post-menu m-modal-confirm .mdl-button--colored').click();
})
it('should post an activity picking a scheduled date', () => {
cy.get('minds-newsfeed-poster').should('be.visible');
cy.get('minds-newsfeed-poster textarea').type('This is a post');
// set scheduled date
cy.get('.m-poster-date-selector--input').click();
cy.get('td.c-datepicker__day-body.c-datepicker__day--selected + td').click();
cy.get('a.c-btn.c-btn--flat.js-ok').click();
// get setted date to compare
let scheduledDate;
cy.get('div.m-poster-date-selector--input div.m-tooltip--bubble')
.invoke('text').then((text) => {
scheduledDate = text;
});
cy.get('.m-posterActionBar__PostButton').click();
cy.wait(100);
// compare setted date with time_created
cy.get('.minds-list > minds-activity:first-child div.mdl-card__supporting-text > div.body > a.permalink > span')
.invoke('text').then((text) => {
const time_created = new Date(text).getTime();
scheduledDate = new Date(scheduledDate).getTime();
expect(scheduledDate).to.equal(time_created);
});
// cleanup
cy.get('.minds-list > minds-activity:first-child m-post-menu .minds-more').click();
cy.get('.minds-list > minds-activity:first-child m-post-menu .minds-dropdown-menu .mdl-menu__item:nth-child(4)').click();
cy.get('.minds-list > minds-activity:first-child m-post-menu m-modal-confirm .mdl-button--colored').click();
})
it('should list scheduled activies', () => {
cy.server();
cy.route("GET", '**/api/v2/feeds/scheduled/**/count?').as("scheduledCount");
cy.route("GET", '**/api/v2/feeds/scheduled/**/activities?**').as("scheduledActivities");
cy.visit(`/${Cypress.env().username}`);
cy.wait('@scheduledCount', { requestTimeout: 2000 }).then((xhr) => {
expect(xhr.status).to.equal(200, 'feeds/scheduled/**/count request status');
});
cy.get('div.m-mindsListTools__scheduled').click();
cy.wait('@scheduledActivities', { requestTimeout: 2000 }).then((xhr) => {
expect(xhr.status).to.equal(200, 'feeds/scheduled/**/activities request status');
});
})
it('should post an activity with an image attachment', () => {
cy.get('minds-newsfeed-poster').should('be.visible');
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment