mirror of
https://github.com/wassname/talk.git
synced 2026-08-12 12:30:39 +08:00
Adds privacy type to the methods to add tags.
This commit is contained in:
@@ -16,8 +16,8 @@ describe('graph.mutations.addCommentTag', () => {
|
||||
});
|
||||
|
||||
const query = `
|
||||
mutation AddCommentTag ($id: ID!, $tag: String!) {
|
||||
addCommentTag(id:$id, tag:$tag) {
|
||||
mutation AddCommentTag ($id: ID!, $tag: String!, $privacy_type: String!) {
|
||||
addCommentTag(id:$id, tag:$tag, privacy_type:$privacy_type) {
|
||||
comment {
|
||||
id
|
||||
}
|
||||
@@ -31,7 +31,7 @@ describe('graph.mutations.addCommentTag', () => {
|
||||
it('moderators can add tags to comments', async () => {
|
||||
const user = new UserModel({roles: ['MODERATOR' ]});
|
||||
const context = new Context({user});
|
||||
const response = await graphql(schema, query, {}, context, {id: comment.id, tag: 'BEST'});
|
||||
const response = await graphql(schema, query, {}, context, {id: comment.id, tag: 'BEST', privacy_type: 'PUBLIC'});
|
||||
if (response.errors && response.errors.length) {
|
||||
console.error(response.errors);
|
||||
}
|
||||
@@ -51,7 +51,7 @@ describe('graph.mutations.addCommentTag', () => {
|
||||
}).forEach(([ userDescription, user ]) => {
|
||||
it(userDescription, async function () {
|
||||
const context = new Context({user});
|
||||
const response = await graphql(schema, query, {}, context, {id: comment.id, tag: 'BEST'});
|
||||
const response = await graphql(schema, query, {}, context, {id: comment.id, tag: 'BEST', privacy_type: 'PUBLIC'});
|
||||
if (response.errors && response.errors.length) {
|
||||
console.error(response.errors);
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ describe('graph.mutations.removeCommentTag', () => {
|
||||
const context = new Context({user});
|
||||
|
||||
// add a tag first
|
||||
await CommentsService.addTag(comment.id, 'BEST');
|
||||
await CommentsService.addTag(comment.id, 'BEST', user.id, 'PUBLIC');
|
||||
const response = await graphql(schema, query, {}, context, {id: comment.id, tag: 'BEST'});
|
||||
if (response.errors && response.errors.length) {
|
||||
console.error(response.errors);
|
||||
@@ -59,7 +59,7 @@ describe('graph.mutations.removeCommentTag', () => {
|
||||
const context = new Context({user});
|
||||
|
||||
// add a tag first
|
||||
await CommentsService.addTag(comment.id, 'BEST');
|
||||
await CommentsService.addTag(comment.id, 'BEST', user ? user.id : null, 'PUBLIC');
|
||||
const response = await graphql(schema, query, {}, context, {id: comment.id, tag: 'BEST'});
|
||||
if (response.errors && response.errors.length) {
|
||||
console.error(response.errors);
|
||||
|
||||
@@ -225,7 +225,7 @@ describe('services.CommentsService', () => {
|
||||
const commentId = comments[0].id;
|
||||
const tagName = 'BEST';
|
||||
const userId = users[0].id;
|
||||
await CommentsService.addTag(commentId, tagName, userId);
|
||||
await CommentsService.addTag(commentId, tagName, userId, 'PUBLIC');
|
||||
const tags = await TagService.findByItemIdAndName(commentId, 'BEST', 'COMMENTS');
|
||||
expect(tags.length).to.equal(1);
|
||||
expect(tags[0].name).to.equal(tagName);
|
||||
@@ -237,7 +237,7 @@ describe('services.CommentsService', () => {
|
||||
const tagName = 'BEST';
|
||||
const userId = users[0].id;
|
||||
|
||||
await expect(CommentsService.addTag(commentId, tagName, userId)).to.be.rejected;
|
||||
await expect(CommentsService.addTag(commentId, tagName, userId, 'PUBLIC')).to.be.rejected;
|
||||
});
|
||||
it('can\'t add same tag.name twice', async () => {
|
||||
const commentId = comments[0].id;
|
||||
@@ -245,10 +245,10 @@ describe('services.CommentsService', () => {
|
||||
const userId = users[0].id;
|
||||
|
||||
// first time
|
||||
await CommentsService.addTag(commentId, tagName, userId);
|
||||
await CommentsService.addTag(commentId, tagName, userId, 'PUBLIC');
|
||||
|
||||
// second time should fail
|
||||
await expect(CommentsService.addTag(commentId, tagName, userId)).to.be.rejected;
|
||||
await expect(CommentsService.addTag(commentId, tagName, userId, 'PUBLIC')).to.be.rejected;
|
||||
});
|
||||
});
|
||||
|
||||
@@ -256,7 +256,7 @@ describe('services.CommentsService', () => {
|
||||
it('removes a tag', async () => {
|
||||
const commentId = comments[0].id;
|
||||
const tagName = 'BEST';
|
||||
await CommentsService.addTag(commentId, tagName, users[0].id);
|
||||
await CommentsService.addTag(commentId, tagName, users[0].id, 'PUBLIC');
|
||||
const tags = await TagService.findByItemIdAndName(commentId, tagName, 'COMMENTS');
|
||||
expect(tags.length).to.equal(1);
|
||||
|
||||
@@ -273,7 +273,7 @@ describe('services.CommentsService', () => {
|
||||
// just make sure it has no tags to start
|
||||
const tags = await TagService.findByItemIdAndName(commentId, tagName, 'COMMENTS');
|
||||
expect(tags.length).to.equal(0);
|
||||
|
||||
|
||||
// ok now to remove it
|
||||
await expect(CommentsService.removeTag(commentId, tagName)).to.be.rejected;
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user