Commit a3357f1a authored by Brian Hatchet's avatar Brian Hatchet :speech_balloon:

Fixed tests up to groups

1 merge request!499Feat/closed channels 602
Pipeline #77420589 passed with stages
in 45 minutes and 52 seconds
......@@ -2,14 +2,19 @@
context('Blogs', () => {
before(() => {
cy.clearCookies();
cy.getCookie('minds_sess')
.then((sessionCookie) => {
if (sessionCookie === null) {
cy.login(true);
return cy.login(true);
}
});
});
beforeEach(()=> {
cy.preserveCookies();
});
it('should not be able to create a new blog if no title or banner are specified', () => {
cy.visit('/blog/edit/new');
......
......@@ -5,13 +5,14 @@ context('Boost Console', () => {
cy.getCookie('minds_sess')
.then((sessionCookie) => {
if (sessionCookie === null) {
cy.login(true);
return cy.login(true);
}
});
});
beforeEach(() => {
cy.preserveCookies();
cy.visit('/newsfeed/subscribed');
newBoost(postContent, 100);
});
......
......@@ -4,7 +4,7 @@ context('Boost Impressions', () => {
cy.getCookie('minds_sess')
.then((sessionCookie) => {
if (sessionCookie === null) {
cy.login(true);
return cy.login(true);
}
});
cy.visit('/newsfeed/subscriptions');
......@@ -12,6 +12,10 @@ context('Boost Impressions', () => {
.should('eq', `/newsfeed/subscriptions`);
});
beforeEach(()=> {
cy.preserveCookies();
});
it('should register views on scroll', () => {
//stub endpoint
cy.server();
......
......@@ -3,11 +3,15 @@ context('Channel', () => {
cy.getCookie('minds_sess')
.then((sessionCookie) => {
if (sessionCookie === null) {
cy.login(true);
return cy.login(true);
}
});
cy.visit(`/${Cypress.env().username}`);
})
});
beforeEach(()=> {
cy.preserveCookies();
});
it('should change channel mode to public', () => {
cy.get('.m-channel-mode-selector--dropdown')
......
/**
* @author Ben Hayward
* @author Ben Hayward
* @create date 2019-08-09 14:42:51
* @modify date 2019-08-09 14:42:51
* @desc Spec tests for comment threads.
......@@ -12,25 +12,19 @@ context('Comment Threads', () => {
3: 'test tier 3',
};
const hamburgerMenu = '.m-v2-topbar__UserMenu > m-user-menu > div.m-user-menu.m-dropdown > a';
const logoutButton = '.m-user-menu.m-dropdown > ul > li:nth-child(11) > a';
const postMenu = 'minds-activity:nth-child(2) > div > m-post-menu > button > i';
const deletePostOption = 'minds-activity:nth-child(2) m-post-menu > ul > li:nth-child(4)';
const deletePostButton = 'm-modal-confirm div:nth-child(1) > div > button.mdl-button--colored';
const postMenu = 'minds-activity:first > div > m-post-menu > button > i';
const deletePostOption = "m-post-menu > ul > li:visible:contains('Delete')";
const deletePostButton = ".m-modal-confirm-buttons > button:contains('Delete')";
const channelButton = '.m-v2-topbar__Top > div > a > minds-avatar > div';
const postCommentButton = 'm-comment__poster > div > div.minds-body > div > div > a.m-post-button';
const thumbsUpButtons = '.m-comment__toolbar minds-button-thumbs-up';
const thumbsDownButtons = '.m-comment__toolbar minds-button-thumbs-down';
const thumbsUpCounters = '.m-comment__toolbar > div > minds-button-thumbs-up > a > span';
const thumbsDownCounters = '.m-comment__toolbar > div > minds-button-thumbs-down > a > span';
// pass in tier / tree depth.
const replyButton = (index) => `minds-activity:nth-child(${index}) .m-comment__toolbar > div > span`;
const commentButton = (index) => `minds-activity:nth-child(${index}) minds-button-comment`;
const commentInput = (index) => `minds-activity:nth-child(${index}) m-text-input--autocomplete-container > minds-textarea > div`;
const commentContent = (index) => `minds-activity:nth-child(${index}) m-comments__tree .m-comment__bubble > p`;
const replyButton = `minds-activity:first .m-comment__toolbar > div > span`;
const commentButton = `minds-activity:first minds-button-comment`;
const commentInput = `minds-activity:first m-text-input--autocomplete-container > minds-textarea > div`;
const commentContent = `minds-activity:first m-comments__tree .m-comment__bubble > p`;
before(() => {
//make a post new.
......@@ -46,61 +40,62 @@ context('Comment Threads', () => {
.should('eq', `/newsfeed/subscriptions`);
cy.post('test post');
cy.get(commentButton(1)).click();
});
beforeEach(()=> {
cy.preserveCookies();
});
/*after(() => {
after(() => {
//delete the post
cy.wait(1000);
cy.get(postMenu).click();
cy.get(deletePostOption).click();
cy.get(deletePostButton).click();
});*/
it('should allow a user to post a tier 1 comment', () => {
cy.get(commentInput(1)).type(testMessage[1]);
cy.get(postCommentButton).click();
cy.get(commentContent(1)).contains(testMessage[1]);
});
it('should allow a user to post a tier 2 comment', () => {
//expand top comment, then top reply button.
cy.get(replyButton(1)).click();
cy.get(commentInput(1)).first().type(testMessage[2]);
cy.get(postCommentButton).first().click();
cy.get(commentContent(1)).contains(testMessage[2]);
});
it('should post three tiers of comments', () => {
//Reveal the conversation
cy.get(commentButton).click();
it('should allow a user to post a tier 3 comment', () => {
cy.get('minds-activity:nth-child(1)')
.find('m-comments__tree m-comments__thread m-comment')
.find('m-comments__thread m-comment:nth-child(2) .m-comment__toolbar > div > span').last().click();
//Add the first level of comments
cy.get(commentInput).type(testMessage[1]);
cy.get(postCommentButton).click();
cy.get(commentContent).contains(testMessage[1]);
//expand top comment, then top reply button.
// cy.get(replyButton(1)).click();
cy.wait(1000);
//Add the second level of comments
cy.get(replyButton).click();
cy.get(commentInput)
.first()
.type(testMessage[2]);
cy.get(postCommentButton)
.first()
.click();
cy.get(commentContent).contains(testMessage[2])
//check the comments.
cy.get(commentInput(1)).first().type(testMessage[3]);
cy.get(postCommentButton).first().click();
cy.get(commentContent(1)).contains(testMessage[3]);
});
it('should allow the user to vote up and down comments', () => {
//expand top comment, then top reply button.
cy.get(replyButton(1)).click();
cy.wait(1000);
//Add the third level of comments
cy.get('minds-activity:first')
.find('m-comments__tree m-comments__thread m-comment')
.find('m-comments__thread m-comment:nth-child(2) .m-comment__toolbar > div > span')
.last()
.click();
cy.get(commentInput)
.first()
.type(testMessage[3]);
cy.get(postCommentButton)
.first()
.click();
cy.get(commentContent).contains(testMessage[3]);
//there are two reply buttons now, use the last one.
cy.get(replyButton(1)).last().click();
cy.wait(1000);
//click thumbs up and down
cy.get(thumbsDownButtons).click({multiple: true});
cy.get(thumbsUpButtons).click({multiple: true});
cy.get('.m-comment__toolbar')
.find('minds-button-thumbs-up')
.click({multiple: true});
cy.get('.m-comment__toolbar')
.find('minds-button-thumbs-down')
.click({multiple: true});
// check the values
cy.get(thumbsUpCounters)
......
......@@ -3,12 +3,16 @@ context('Discovery', () => {
cy.getCookie('minds_sess')
.then((sessionCookie) => {
if (sessionCookie === null) {
cy.login(true);
return cy.login(true);
}
});
cy.visit('/newsfeed/global/top');
});
beforeEach(()=> {
cy.preserveCookies();
});
it('should allow a user to post on the discovery page', () => {
cy.post("test!!");
});
......
......@@ -24,22 +24,27 @@
// -- This is will overwrite an existing command --
// Cypress.Commands.overwrite("visit", (originalFn, url, options) => { ... })
// Staging requires cookie to be set
Cypress.Cookies.defaults({
whitelist: 'staging'
});
Cypress.Commands.add('login', (canary) => {
cy.setCookie('staging', "1"); // Run in stagin mode. Note: does not impact review sites
cy.visit('/login');
cy.get('.m-btn--login').click();
cy.server();
cy.route("POST", "/api/v1/authenticate").as("postLogin");
cy.get('minds-form-login .m-login-box .mdl-cell:first-child input').type(Cypress.env().username);
cy.get('minds-form-login .m-login-box .mdl-cell:last-child input').type(Cypress.env().password);
cy.get('minds-form-login .m-btn--login').click();
cy.wait('@postLogin').then((xhr) => {
expect(xhr.status).to.equal(200);
expect(xhr.response.body.status).to.equal('success');
});
});
Cypress.Commands.add('preserveCookies', () => {
Cypress.Cookies.preserveOnce('staging', 'minds_sess', 'mwa', 'XSRF-TOKEN');
});
Cypress.Commands.add('uploadFile', (selector, fileName, type = '') => {
......
......@@ -19,6 +19,4 @@ import './commands'
// Alternatively you can use CommonJS syntax:
// require('./commands')
Cypress.Cookies.defaults({
whitelist: ['minds_sess', 'mwa', 'XSRF-TOKEN']
})
Cypress.Cookies.debug(true);
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