Merge branch 'master' into events

This commit is contained in:
Wyatt Johnson
2018-01-30 11:04:42 -07:00
56 changed files with 303 additions and 138 deletions
+48 -6
View File
@@ -15,13 +15,13 @@ module.exports = {
client.end();
},
'admin logs in': client => {
'Admin logs in': client => {
const adminPage = client.page.admin();
const { testData: { admin } } = client.globals;
adminPage.navigateAndLogin(admin);
},
'admin flags users username as offensive': client => {
'Admin flags users username as offensive': client => {
const embedStream = client.page.embedStream();
const comments = embedStream.navigate().ready();
@@ -42,7 +42,7 @@ module.exports = {
.waitForElementVisible('@popUpText')
.click('@continueButton');
},
'admin goes to Reported Usernames': client => {
'Admin goes to Reported Usernames': client => {
const adminPage = client.page.admin();
const community = adminPage
@@ -54,14 +54,14 @@ module.exports = {
.waitForElementVisible('@flaggedAccountsContainer')
.waitForElementVisible('@flaggedUser');
},
'admin rejects the user flag': client => {
'Admin rejects the user flag': client => {
const community = client.page.admin().section.community;
community
.waitForElementVisible('@flaggedUserRejectButton')
.click('@flaggedUserRejectButton');
},
'admin suspends the user': client => {
'Admin suspends the user': client => {
const community = client.page.admin().section.community;
const usernameDialog = client.page.admin().section.usernameDialog;
@@ -76,7 +76,7 @@ module.exports = {
community.waitForElementNotPresent('@flaggedUser');
},
'admin logs out': client => {
'Admin logs out': client => {
client.page.admin().logout();
},
'user logs in': client => {
@@ -114,6 +114,48 @@ module.exports = {
.click('@changeUsernameSubmitButton')
.waitForElementNotPresent('@changeUsernameInput');
},
'user should not be able to comment still': client => {
const embedStream = client.page.embedStream();
const comments = embedStream.section.comments;
comments
.waitForElementNotPresent('@commentBoxTextarea')
.waitForElementNotPresent('@commentBoxPostButton');
},
'user logs out': client => {
const embedStream = client.page.embedStream();
const comments = embedStream.section.comments;
comments.logout();
},
'Admin accepts the user flag': client => {
const adminPage = client.page.admin();
const { testData: { admin } } = client.globals;
adminPage.navigateAndLogin(admin);
const community = adminPage
.navigate()
.ready()
.goToCommunity();
community
.waitForElementVisible('@flaggedAccountsContainer')
.waitForElementVisible('@flaggedUser')
.waitForElementVisible('@flaggedUserApproveButton')
.click('@flaggedUserApproveButton');
client.page.admin().logout();
},
'user logs in to check comment': client => {
const { testData: { user } } = client.globals;
const embedStream = client.page.embedStream();
embedStream
.navigate()
.ready()
.openLoginPopup(popup => popup.login(user));
},
'user should be able to comment': client => {
const embedStream = client.page.embedStream();
const comments = embedStream.section.comments;
@@ -270,6 +270,49 @@ describe('graph.mutations.createComment', () => {
});
});
describe('user with different username statuses', () => {
beforeEach(() => AssetModel.create({ id: '123' }));
[
{ status: 'UNSET', error: true },
{ status: 'SET', error: false },
{ status: 'APPROVED', error: false },
{ status: 'REJECTED', error: true },
{ status: 'CHANGED', error: true },
].forEach(({ status, error }) => {
describe(`user.status.username.status=${status}`, () => {
it(`${error ? 'can not' : 'can'} create a comment`, async () => {
const context = new Context({
user: new UserModel({ status: { username: { status } } }),
});
const { data, errors } = await graphql(schema, query, {}, context);
if (errors) {
console.error(errors);
}
expect(errors).to.be.undefined;
if (error) {
expect(data.createComment).to.have.property('errors').not.null;
expect(data.createComment).to.have.property('comment').null;
expect(data.createComment.errors).to.have.length(1);
expect(data.createComment.errors[0]).to.have.property(
'translation_key',
'NOT_AUTHORIZED'
);
} else {
if (data.createComment.errors) {
console.error(data.createComment.errors);
}
expect(data.createComment).to.have.property('errors').null;
expect(data.createComment).to.have.property('comment').not.null;
}
});
});
});
});
describe('users with different roles', () => {
beforeEach(() => AssetModel.create({ id: '123' }));