3 process.env.DISABLE_MATRIX_BRIDGE = '1';
4 process.env.DISABLE_API_LISTEN = '1';
6 const assert = require('assert');
7 const fixtureLoader = require('gitter-web-test-utils/lib/test-fixtures');
9 describe('user-orgs #slow', () => {
13 if (this._skipFixtureSetup) return;
15 request = require('supertest');
16 app = require('../../server/api');
19 describe('GitHub', () => {
20 fixtureLoader.ensureIntegrationEnvironment(
22 'GITTER_INTEGRATION_ORG',
23 'GITTER_INTEGRATION_ORG_ID',
27 const fixture = fixtureLoader.setup({
30 { 'sd.type': 'GH_ORG', 'sd.linkPath': fixtureLoader.GITTER_INTEGRATION_ORG },
31 { lcUri: fixtureLoader.GITTER_INTEGRATION_COMMUNITY.toLowerCase() }
34 { 'sd.type': 'GH_ORG', 'sd.linkPath': fixtureLoader.GITTER_INTEGRATION_ORG },
35 { lcUri: fixtureLoader.GITTER_INTEGRATION_COMMUNITY.toLowerCase() + '/community' }
38 user1: '#integrationUser1'
41 it('GET /v1/user/:userId/orgs', async () => {
42 const result = await request(app)
43 .get(`/v1/user/${fixture.user1.id}/orgs`)
44 .set('x-access-token', fixture.user1.accessToken)
47 const orgs = result.body;
49 const integrationOrg = orgs.find(org => {
50 return org.id === parseInt(fixtureLoader.GITTER_INTEGRATION_ORG_ID, 10);
52 const { avatar_url, ...compareOrg } = integrationOrg;
54 assert.deepStrictEqual(compareOrg, {
56 id: parseInt(fixtureLoader.GITTER_INTEGRATION_ORG_ID, 10),
57 name: fixtureLoader.GITTER_INTEGRATION_ORG,
58 uri: 'gitter-integration-tests-organisation',
59 absoluteUri: `https://github.com/${fixtureLoader.GITTER_INTEGRATION_ORG}`,
67 describe('GitLab', () => {
68 fixtureLoader.ensureIntegrationEnvironment(
69 '#integrationGitlabUser1',
75 const fixture = fixtureLoader.setup({
76 userGitlab1: '#integrationGitlabUser1'
79 it('GET /v1/user/:userId/orgs', async () => {
80 const result = await request(app)
81 .get(`/v1/user/${fixture.userGitlab1.id}/orgs`)
82 .set('x-access-token', fixture.userGitlab1.accessToken)
85 const orgs = result.body;
87 const integrationOrg = orgs.find(org => {
88 return org.id === parseInt(fixtureLoader.GITLAB_GROUP1_ID, 10);
90 const { avatar_url, ...compareOrg } = integrationOrg;
92 assert.deepStrictEqual(compareOrg, {
94 id: parseInt(fixtureLoader.GITLAB_GROUP1_ID, 10),
95 name: fixtureLoader.GITLAB_GROUP1_URI,
96 uri: 'gitter-integration-tests-group',
97 absoluteUri: `https://gitlab.com/groups/${fixtureLoader.GITLAB_GROUP1_URI}`