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');
13 const recentRoomCore = require('gitter-web-rooms/lib/recent-room-core');
15 describe('user-room-last-access-times-export-api', function() {
16 fixtureLoader.ensureIntegrationEnvironment('#oauthTokens');
19 if (this._skipFixtureSetup) return;
22 var fixture = fixtureLoader.setup({
24 accessToken: 'web-internal'
27 accessToken: 'web-internal'
34 it('GET /api_web/export/user/:user_id/room-last-access-times.ndjson as same user gets data', async () => {
35 await recentRoomCore.saveUserTroupeLastAccess(fixture.user1.id, fixture.troupe1.id, new Date());
36 await recentRoomCore.saveUserTroupeLastAccess(fixture.user1.id, fixture.troupe2.id, new Date());
37 await recentRoomCore.saveUserTroupeLastAccess(
38 fixture.userNoExport1.id,
39 fixture.troupeNoExport1.id,
44 .get(`/api_web/export/user/${fixture.user1.id}/room-last-access-times.ndjson`)
45 .set('Accept', 'application/x-ndjson,application/json')
46 .set('Authorization', `Bearer ${fixture.user1.accessToken}`)
48 .then(function(result) {
50 result.text.split('\n').length,
52 'includes 2 rooms (extra newline at the end)'
54 assert(result.text.includes(fixture.troupe1.id), 'includes troupe1');
55 assert(result.text.includes(fixture.troupe2.id), 'includes troupe2');
57 !result.text.includes(fixture.troupeNoExport1.id),
58 'does not include troupeNoExport1'