3 process.env.DISABLE_API_LISTEN = '1';
5 var fixtureLoader = require('gitter-web-test-utils/lib/test-fixtures');
6 var assert = require('assert');
8 describe('chat-api', function() {
11 fixtureLoader.ensureIntegrationEnvironment('#oauthTokens');
14 if (this._skipFixtureSetup) return;
16 request = require('supertest');
17 app = require('../../../server/api');
20 var fixture = fixtureLoader.setup({
22 oAuthAccessTokenAnonymous: { client: 'oAuthClient1', user: null },
24 accessToken: 'web-internal'
27 accessToken: 'web-internal'
30 accessToken: 'web-internal'
36 extraAdmins: ['user3']
55 it('POST /v1/rooms/:roomId/chatMessages/:chatMessageId/report - own message', function() {
58 '/v1/rooms/' + fixture.troupe1.id + '/chatMessages/' + fixture.messageBad3.id + '/report'
60 .set('x-access-token', fixture.user1.accessToken)
64 it('POST /v1/rooms/:roomId/chatMessages/:chatMessageId/report - some elses message', function() {
67 '/v1/rooms/' + fixture.troupe1.id + '/chatMessages/' + fixture.messageBad2.id + '/report'
69 .set('x-access-token', fixture.user2.accessToken)
71 .then(function(result) {
72 const body = result.body;
73 assert.strictEqual(body.messageId, fixture.messageBad2.id);
74 assert.strictEqual(body.messageText, fixture.messageBad2.text);
78 it('POST /v1/rooms/:roomId/chatMessages/:chatMessageId/report - as admin', function() {
81 '/v1/rooms/' + fixture.troupe1.id + '/chatMessages/' + fixture.messageBad2.id + '/report'
83 .set('x-access-token', fixture.user3.accessToken)
85 .then(function(result) {
86 const body = result.body;
87 assert.strictEqual(body.messageId, fixture.messageBad2.id);
88 assert.strictEqual(body.messageText, fixture.messageBad2.text);