3 process.env.DISABLE_MATRIX_BRIDGE = '1';
4 process.env.DISABLE_API_LISTEN = '1';
5 process.env.DISABLE_API_WEB_LISTEN = '1';
6 process.env.TEST_EXPORT_RATE_LIMIT = 100;
8 const fixtureLoader = require('gitter-web-test-utils/lib/test-fixtures');
9 const assert = require('assert');
10 const request = require('supertest');
12 const app = require('../../../server/web');
14 describe('room-users-export-api', function() {
15 fixtureLoader.ensureIntegrationEnvironment('#oauthTokens');
18 if (this._skipFixtureSetup) return;
21 var fixture = fixtureLoader.setup({
23 accessToken: 'web-internal'
26 accessToken: 'web-internal'
29 accessToken: 'web-internal'
32 users: ['user1', 'user2'],
35 extraAdmins: ['user1']
39 users: ['userNoExport1']
43 it('GET /api_web/export/rooms/:room_id/users.ndjson as admin works', function() {
45 .get(`/api_web/export/rooms/${fixture.troupe1.id}/users.ndjson`)
46 .set('Accept', 'application/x-ndjson,application/json')
47 .set('Authorization', `Bearer ${fixture.user1.accessToken}`)
49 .then(function(result) {
51 result.text.split('\n').length,
53 'includes 2 users (extra newline at the end)'
55 assert(result.text.includes(fixture.user1.id), 'includes user1');
56 assert(result.text.includes(fixture.user2.id), 'includes user2');
58 result.text.includes(`"username":"${fixture.user1.username}"`),
59 'make sure it serializes the user itself and not just raw troupe-user'
61 assert(!result.text.includes(fixture.userNoExport1.id), 'does not include userNoExport1');