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 uriLookupService = require('gitter-web-uri-resolver/lib/uri-lookup-service');
15 describe('user-uri-lookups-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/uri-lookups.ndjson as same user gets data', async () => {
35 await uriLookupService.reserveUriForUsername(fixture.user1.id, fixture.user1.username);
36 await uriLookupService.reserveUriForUsername(
37 fixture.userNoExport1.id,
38 fixture.userNoExport1.username
42 .get(`/api_web/export/user/${fixture.user1.id}/uri-lookups.ndjson`)
43 .set('Accept', 'application/x-ndjson,application/json')
44 .set('Authorization', `Bearer ${fixture.user1.accessToken}`)
46 .then(function(result) {
48 result.text.split('\n').length,
50 'includes 1 URI lookup for user (extra newline at the end)'
52 assert(result.text.includes(fixture.user1.id), 'includes user1');
53 assert(!result.text.includes(fixture.userNoExport1.id), 'does not include userNoExport1');