volunteer-contributions-fetch 2.5.0 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.env.example +1 -0
- package/.eslintrc +2 -0
- package/.github/workflows/release.yml +4 -4
- package/.github/workflows/test.yml +4 -6
- package/.husky/commit-msg +0 -3
- package/.husky/pre-commit +1 -0
- package/LICENSE +1 -2
- package/README.md +12 -10
- package/example/index.js +36 -0
- package/fixtures/community-portal.js +3 -9
- package/fixtures/wiki.js +2 -7
- package/index.js +1 -5
- package/lib/bugzilla.js +13 -18
- package/lib/bugzilla.test.js +52 -50
- package/lib/community-portal.js +8 -13
- package/lib/community-portal.test.js +63 -68
- package/lib/contributions.js +1 -5
- package/lib/contributions.test.js +8 -7
- package/lib/discourse.js +10 -16
- package/lib/discourse.test.js +46 -50
- package/lib/fetch.js +11 -13
- package/lib/fetch.test.js +86 -97
- package/lib/github-fetcher.js +10 -18
- package/lib/github.js +46 -23
- package/lib/github.test.js +340 -319
- package/lib/utils.js +1 -5
- package/lib/utils.test.js +11 -11
- package/lib/validator.js +8 -9
- package/lib/validator.test.js +37 -33
- package/lib/wiki.js +10 -15
- package/lib/wiki.test.js +35 -41
- package/package.json +16 -15
- package/lib/github-fetcher.test.js +0 -6
- /package/{commitlint.config.js → commitlint.config.cjs} +0 -0
package/.env.example
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
GITHUB_TOKEN=""
|
package/.eslintrc
CHANGED
|
@@ -7,16 +7,16 @@ on:
|
|
|
7
7
|
|
|
8
8
|
jobs:
|
|
9
9
|
release:
|
|
10
|
-
runs-on: ubuntu-
|
|
10
|
+
runs-on: ubuntu-latest
|
|
11
11
|
permissions:
|
|
12
12
|
contents: write
|
|
13
13
|
id-token: write
|
|
14
14
|
issues: write
|
|
15
15
|
steps:
|
|
16
|
-
- uses: actions/checkout@
|
|
17
|
-
- uses: actions/setup-node@
|
|
16
|
+
- uses: actions/checkout@v4
|
|
17
|
+
- uses: actions/setup-node@v4
|
|
18
18
|
with:
|
|
19
|
-
node-version:
|
|
19
|
+
node-version: 20
|
|
20
20
|
- run: npm ci
|
|
21
21
|
- run: npm test
|
|
22
22
|
- name: Release
|
|
@@ -6,13 +6,11 @@ jobs:
|
|
|
6
6
|
build:
|
|
7
7
|
runs-on: ubuntu-latest
|
|
8
8
|
steps:
|
|
9
|
-
- uses: actions/checkout@
|
|
9
|
+
- uses: actions/checkout@v4
|
|
10
|
+
- name: Use Node.js 20
|
|
11
|
+
uses: actions/setup-node@v4
|
|
10
12
|
with:
|
|
11
|
-
|
|
12
|
-
- name: Use Node.js 16
|
|
13
|
-
uses: actions/setup-node@v3
|
|
14
|
-
with:
|
|
15
|
-
node-version: 18
|
|
13
|
+
node-version: 20
|
|
16
14
|
- name: Install Dependencies
|
|
17
15
|
run: npm ci
|
|
18
16
|
- name: Linting
|
package/.husky/commit-msg
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
npm test
|
package/LICENSE
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
|
|
2
1
|
The MIT License (MIT)
|
|
3
2
|
|
|
4
|
-
Copyright (c)
|
|
3
|
+
Copyright (c) 2024 Michael Kohler
|
|
5
4
|
|
|
6
5
|
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
7
6
|
|
package/README.md
CHANGED
|
@@ -27,16 +27,12 @@ Currently the following sources are supported. Feel free to contribute a PR if y
|
|
|
27
27
|
|
|
28
28
|
Each of the sources can be enabled separately. See the configuration section below.
|
|
29
29
|
|
|
30
|
-
###
|
|
31
|
-
|
|
32
|
-
The following sources are planned:
|
|
30
|
+
### Possible future sources
|
|
33
31
|
|
|
34
32
|
- Phabricator
|
|
35
33
|
- Revision created
|
|
36
34
|
- Revision updated
|
|
37
35
|
|
|
38
|
-
### Possible future sources
|
|
39
|
-
|
|
40
36
|
The following sources would be interesting for (at least) Mozilla contributors, however they do not expose an activity API endpoint to easily gather information for a certain user.
|
|
41
37
|
|
|
42
38
|
- support.mozilla.org
|
|
@@ -53,7 +49,7 @@ npm install volunteer-contribution-fetch
|
|
|
53
49
|
Then you can create a file in your project which runs the fetch operation and provides the necessary config:
|
|
54
50
|
|
|
55
51
|
```js
|
|
56
|
-
|
|
52
|
+
import { fetchAll } from 'volunteer-contributions-fetch';
|
|
57
53
|
|
|
58
54
|
const config = {}; // See below for documentation and a sample config
|
|
59
55
|
|
|
@@ -62,10 +58,10 @@ fetchAll(config);
|
|
|
62
58
|
|
|
63
59
|
### Usage without output file
|
|
64
60
|
|
|
65
|
-
This can also be used without having to rely on an `outputFile`. For this case the `fetchAll` function returns all contributions. Additionally you can also pass existing contributions to the function and these will be considered as well. The return value and the parameter of the function
|
|
61
|
+
This can also be used without having to rely on an `outputFile`. For this case the `fetchAll` function returns all contributions. Additionally you can also pass existing contributions to the function and these will be considered as well. The return value and the parameter of the function work the same as having an `outputFile`.
|
|
66
62
|
|
|
67
63
|
```js
|
|
68
|
-
|
|
64
|
+
import { fetchAll } from 'volunteer-contributions-fetch';
|
|
69
65
|
|
|
70
66
|
const config = {}; // See below for documentation and a sample config
|
|
71
67
|
const existingContributions = [{ ... }];
|
|
@@ -74,7 +70,7 @@ const results = fetchAll(config, existingContributions);
|
|
|
74
70
|
// results is now all existing contributions plus any newly fetched contribution
|
|
75
71
|
```
|
|
76
72
|
|
|
77
|
-
Note that passing existing contributions this way will be ignored if a `outputFile` is used.
|
|
73
|
+
Note that passing existing contributions this way will be ignored if a `outputFile` is used. Instead the existing contributions will be read from the `outputFile` if it already exists.
|
|
78
74
|
|
|
79
75
|
## Configuration
|
|
80
76
|
|
|
@@ -240,7 +236,13 @@ npm test
|
|
|
240
236
|
|
|
241
237
|
### Testing changes
|
|
242
238
|
|
|
243
|
-
|
|
239
|
+
First copy the example env file and adjust it to reflect your tokens.
|
|
240
|
+
|
|
241
|
+
```bash
|
|
242
|
+
cp .env.example .env
|
|
243
|
+
```
|
|
244
|
+
|
|
245
|
+
You then can use `npm run example` which uses `fetchAll` if you would like to test changes within this project. The configuration for this can be adjusted in `example/index.js`. A full sample config can be found in the configuration section above. Please make sure to not include testing config file changes when committing! The file is not ignored to make it so that new checkouts do not have to copy around a file first.
|
|
244
246
|
|
|
245
247
|
### Deployments
|
|
246
248
|
|
package/example/index.js
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { fetchAll } from '../lib/fetch.js';
|
|
2
|
+
|
|
3
|
+
const config = {
|
|
4
|
+
github: {
|
|
5
|
+
allowPrivate: true,
|
|
6
|
+
enabled: true,
|
|
7
|
+
username: 'MichaelKohler',
|
|
8
|
+
stopDate: '2025-01-01',
|
|
9
|
+
filter: 'mozilla',
|
|
10
|
+
types: {
|
|
11
|
+
commit: 'GitHub Commit',
|
|
12
|
+
privateCommit: 'Commit in private repository',
|
|
13
|
+
createdPR: 'Created PR',
|
|
14
|
+
createdIssue: 'Created Issue Report',
|
|
15
|
+
commentedPR: 'Commented on a Pull Request',
|
|
16
|
+
approvedPR: 'Approved a Pull Request',
|
|
17
|
+
changesRequestedPR: 'Requested changes on a Pull Request',
|
|
18
|
+
reviewedPR: 'Reviewed a Pull Request',
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
const existingContributions = [
|
|
24
|
+
{
|
|
25
|
+
createdAt: '2008-03-10T00:21:39.000Z',
|
|
26
|
+
description: 'Fix sorting and labels for the bookmark library restore menu',
|
|
27
|
+
link: 'https://bugzilla.mozilla.org/show_bug.cgi?id=421834#c0',
|
|
28
|
+
type: 'Created a Bug Report',
|
|
29
|
+
source: 'bugzilla-created',
|
|
30
|
+
},
|
|
31
|
+
];
|
|
32
|
+
|
|
33
|
+
const contributions = await fetchAll(config, existingContributions);
|
|
34
|
+
|
|
35
|
+
// eslint-disable-next-line no-console
|
|
36
|
+
console.log(contributions);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const allData = {
|
|
1
|
+
export const allData = {
|
|
2
2
|
window: {
|
|
3
3
|
document: {
|
|
4
4
|
querySelectorAll: (query) => {
|
|
@@ -122,7 +122,7 @@ const allData = {
|
|
|
122
122
|
},
|
|
123
123
|
};
|
|
124
124
|
|
|
125
|
-
const noData = {
|
|
125
|
+
export const noData = {
|
|
126
126
|
window: {
|
|
127
127
|
document: {
|
|
128
128
|
querySelectorAll: (query) => {
|
|
@@ -140,7 +140,7 @@ const noData = {
|
|
|
140
140
|
},
|
|
141
141
|
};
|
|
142
142
|
|
|
143
|
-
const futureData = {
|
|
143
|
+
export const futureData = {
|
|
144
144
|
window: {
|
|
145
145
|
document: {
|
|
146
146
|
querySelectorAll: (query) => {
|
|
@@ -263,9 +263,3 @@ const futureData = {
|
|
|
263
263
|
},
|
|
264
264
|
},
|
|
265
265
|
};
|
|
266
|
-
|
|
267
|
-
module.exports = {
|
|
268
|
-
allData,
|
|
269
|
-
noData,
|
|
270
|
-
futureData,
|
|
271
|
-
};
|
package/fixtures/wiki.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const firstMonth = `
|
|
1
|
+
export const firstMonth = `
|
|
2
2
|
<rss version="2.0">
|
|
3
3
|
<channel>
|
|
4
4
|
<title>MozillaWiki - User contributions [en]</title>
|
|
@@ -29,7 +29,7 @@ const firstMonth = `
|
|
|
29
29
|
</rss>
|
|
30
30
|
`;
|
|
31
31
|
|
|
32
|
-
const secondMonth = `
|
|
32
|
+
export const secondMonth = `
|
|
33
33
|
<rss version="2.0">
|
|
34
34
|
<channel>
|
|
35
35
|
<title>MozillaWiki - User contributions [en]</title>
|
|
@@ -50,8 +50,3 @@ const secondMonth = `
|
|
|
50
50
|
</channel>
|
|
51
51
|
</rss>
|
|
52
52
|
`;
|
|
53
|
-
|
|
54
|
-
module.exports = {
|
|
55
|
-
firstMonth,
|
|
56
|
-
secondMonth,
|
|
57
|
-
};
|
package/index.js
CHANGED
package/lib/bugzilla.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
const axios = require('axios');
|
|
1
|
+
import Debug from 'debug';
|
|
3
2
|
|
|
4
|
-
|
|
3
|
+
import { getPadded } from './utils.js';
|
|
4
|
+
|
|
5
|
+
const debug = Debug('contributions:bugzilla');
|
|
5
6
|
|
|
6
7
|
const BUGZILLA_CREATED_CATEGORY = 'bugzilla-created';
|
|
7
8
|
const BUGZILLA_COMMENTED_CATEGORY = 'bugzilla-comments';
|
|
@@ -12,12 +13,7 @@ const TYPE_COMMENTED = 'Commented on a Bug Report';
|
|
|
12
13
|
const RESULTS_PER_PAGE = 500;
|
|
13
14
|
const FETCH_TIMEOUT = 120000;
|
|
14
15
|
|
|
15
|
-
|
|
16
|
-
gather,
|
|
17
|
-
validate,
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
function validate(config) {
|
|
16
|
+
export function validate(config) {
|
|
21
17
|
debug('Validating Bugzilla config');
|
|
22
18
|
|
|
23
19
|
if (!config) {
|
|
@@ -37,7 +33,7 @@ function validate(config) {
|
|
|
37
33
|
}
|
|
38
34
|
}
|
|
39
35
|
|
|
40
|
-
async function gather({ bugzilla }, existingContributions = []) {
|
|
36
|
+
export async function gather({ bugzilla }, existingContributions = []) {
|
|
41
37
|
if (!bugzilla || (bugzilla && !bugzilla.enabled)) {
|
|
42
38
|
debug('Bugzilla source not enabled, skipping');
|
|
43
39
|
return [];
|
|
@@ -92,11 +88,11 @@ async function* bugPageGenerator(bugzilla, stopDate) {
|
|
|
92
88
|
const bugsUrl = `${bugzilla.baseUrl}/rest/bug?${query}`;
|
|
93
89
|
debug(`Fetching from ${bugsUrl}`);
|
|
94
90
|
// eslint-disable-next-line no-await-in-loop
|
|
95
|
-
const
|
|
96
|
-
|
|
97
|
-
url: bugsUrl,
|
|
98
|
-
timeout: FETCH_TIMEOUT,
|
|
91
|
+
const response = await fetch(bugsUrl, {
|
|
92
|
+
signal: AbortSignal.timeout(FETCH_TIMEOUT),
|
|
99
93
|
});
|
|
94
|
+
// eslint-disable-next-line no-await-in-loop
|
|
95
|
+
const data = await response.json();
|
|
100
96
|
debug(`Got ${data.bugs.length} bugs results`);
|
|
101
97
|
// If we have less results than the max result, we're at the end
|
|
102
98
|
if (data.bugs.length < RESULTS_PER_PAGE) {
|
|
@@ -115,11 +111,10 @@ async function* getComments(bugzilla, bugs, titleMap) {
|
|
|
115
111
|
const commentsUrl = `${bugzilla.baseUrl}/rest/bug/${bug.id}/comment`;
|
|
116
112
|
debug(`Fetching from ${commentsUrl}`);
|
|
117
113
|
// eslint-disable-next-line no-await-in-loop
|
|
118
|
-
const
|
|
119
|
-
|
|
120
|
-
url: commentsUrl,
|
|
121
|
-
timeout: FETCH_TIMEOUT,
|
|
114
|
+
const response = await fetch(commentsUrl, {
|
|
115
|
+
signal: AbortSignal.timeout(FETCH_TIMEOUT),
|
|
122
116
|
});
|
|
117
|
+
const data = await response.json();
|
|
123
118
|
|
|
124
119
|
const ownComments = data.bugs[bug.id].comments.filter(
|
|
125
120
|
(comment) => comment.creator === bugzilla.username
|
package/lib/bugzilla.test.js
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
const axios = require('axios');
|
|
3
|
-
const sinon = require('sinon');
|
|
1
|
+
import { afterEach, beforeEach, expect, test, vi } from 'vitest';
|
|
4
2
|
|
|
5
|
-
|
|
3
|
+
import { gather, validate } from './bugzilla.js';
|
|
6
4
|
|
|
7
5
|
const config = {
|
|
8
6
|
bugzilla: {
|
|
@@ -13,10 +11,7 @@ const config = {
|
|
|
13
11
|
},
|
|
14
12
|
};
|
|
15
13
|
|
|
16
|
-
|
|
17
|
-
// eslint-disable-next-line no-param-reassign
|
|
18
|
-
t.context.sandbox = sinon.createSandbox();
|
|
19
|
-
|
|
14
|
+
beforeEach(() => {
|
|
20
15
|
const firstBugsPage = {
|
|
21
16
|
bugs: new Array(500).fill(0).map(() => ({
|
|
22
17
|
created_at: new Date('2022-04-13'),
|
|
@@ -64,61 +59,64 @@ test.beforeEach((t) => {
|
|
|
64
59
|
},
|
|
65
60
|
};
|
|
66
61
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
62
|
+
const mockedFetch = vi
|
|
63
|
+
.fn()
|
|
64
|
+
.mockResolvedValueOnce({ json: vi.fn().mockResolvedValue(firstBugsPage) })
|
|
65
|
+
.mockResolvedValueOnce({ json: vi.fn().mockResolvedValue(secondBugsPage) })
|
|
66
|
+
.mockResolvedValue({ json: vi.fn().mockResolvedValue(comments) });
|
|
67
|
+
|
|
68
|
+
vi.stubGlobal('fetch', mockedFetch);
|
|
71
69
|
});
|
|
72
70
|
|
|
73
|
-
|
|
74
|
-
|
|
71
|
+
afterEach(() => {
|
|
72
|
+
vi.restoreAllMocks();
|
|
75
73
|
});
|
|
76
74
|
|
|
77
|
-
test
|
|
78
|
-
|
|
75
|
+
test('should validate config - undefined', () => {
|
|
76
|
+
expect(() => validate(undefined)).not.toThrow();
|
|
79
77
|
});
|
|
80
78
|
|
|
81
|
-
test
|
|
79
|
+
test('should validate config - missing completely', () => {
|
|
82
80
|
const emptyConfig = {};
|
|
83
|
-
|
|
81
|
+
expect(() => validate(emptyConfig)).not.toThrow();
|
|
84
82
|
});
|
|
85
83
|
|
|
86
|
-
test
|
|
84
|
+
test('should validate config - missing baseUrl', () => {
|
|
87
85
|
const failConfig = {
|
|
88
86
|
enabled: true,
|
|
89
87
|
username: 'A',
|
|
90
88
|
stopDate: new Date(),
|
|
91
89
|
};
|
|
92
90
|
|
|
93
|
-
|
|
91
|
+
expect(() => validate(failConfig)).toThrow();
|
|
94
92
|
});
|
|
95
93
|
|
|
96
|
-
test
|
|
94
|
+
test('should validate config - missing username', () => {
|
|
97
95
|
const failConfig = {
|
|
98
96
|
enabled: true,
|
|
99
97
|
baseUrl: 'A',
|
|
100
98
|
stopDate: new Date(),
|
|
101
99
|
};
|
|
102
100
|
|
|
103
|
-
|
|
101
|
+
expect(() => validate(failConfig)).toThrow();
|
|
104
102
|
});
|
|
105
103
|
|
|
106
|
-
test
|
|
104
|
+
test('should validate config - missing stopDate', () => {
|
|
107
105
|
const failConfig = {
|
|
108
106
|
enabled: true,
|
|
109
107
|
baseUrl: 'A',
|
|
110
108
|
username: 'user',
|
|
111
109
|
};
|
|
112
110
|
|
|
113
|
-
|
|
111
|
+
expect(() => validate(failConfig)).toThrow();
|
|
114
112
|
});
|
|
115
113
|
|
|
116
|
-
test
|
|
117
|
-
const contributions = await
|
|
118
|
-
|
|
114
|
+
test('should fetch', async () => {
|
|
115
|
+
const contributions = await gather(config);
|
|
116
|
+
expect(contributions.length).toBe((500 + 1) * 2);
|
|
119
117
|
});
|
|
120
118
|
|
|
121
|
-
test
|
|
119
|
+
test('should not fetch if disabled - by enable property', async () => {
|
|
122
120
|
const specificTypeConfig = {
|
|
123
121
|
bugzilla: {
|
|
124
122
|
...config.bugzilla,
|
|
@@ -126,31 +124,28 @@ test.serial('should not fetch if disabled - by enable property', async (t) => {
|
|
|
126
124
|
},
|
|
127
125
|
};
|
|
128
126
|
|
|
129
|
-
const contributions = await
|
|
127
|
+
const contributions = await gather(specificTypeConfig);
|
|
130
128
|
|
|
131
|
-
|
|
129
|
+
expect(contributions.length).toBe(0);
|
|
132
130
|
});
|
|
133
131
|
|
|
134
|
-
test
|
|
135
|
-
|
|
136
|
-
async (t) => {
|
|
137
|
-
const contributions = await bugzilla.gather({});
|
|
132
|
+
test('should not fetch if disabled - by leaving off config value', async () => {
|
|
133
|
+
const contributions = await gather({});
|
|
138
134
|
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
);
|
|
135
|
+
expect(contributions.length).toBe(0);
|
|
136
|
+
});
|
|
142
137
|
|
|
143
|
-
test
|
|
144
|
-
const contributions = await
|
|
138
|
+
test('should format', async () => {
|
|
139
|
+
const contributions = await gather(config);
|
|
145
140
|
|
|
146
|
-
|
|
141
|
+
expect(contributions[0]).toStrictEqual({
|
|
147
142
|
createdAt: new Date('2022-04-13'),
|
|
148
143
|
description: 'SecondSummary',
|
|
149
144
|
link: 'https://bugzilla.mozilla.org/show_bug.cgi?id=1#c0',
|
|
150
145
|
type: 'Created a Bug Report',
|
|
151
146
|
source: 'bugzilla-created',
|
|
152
147
|
});
|
|
153
|
-
|
|
148
|
+
expect(contributions[1]).toStrictEqual({
|
|
154
149
|
createdAt: new Date('2022-04-13'),
|
|
155
150
|
description: 'SecondSummary',
|
|
156
151
|
link: 'https://bugzilla.mozilla.org/show_bug.cgi?id=1#c1',
|
|
@@ -159,7 +154,7 @@ test.serial('should format', async (t) => {
|
|
|
159
154
|
});
|
|
160
155
|
});
|
|
161
156
|
|
|
162
|
-
test
|
|
157
|
+
test('should format with custom types', async () => {
|
|
163
158
|
const specificTypeConfig = {
|
|
164
159
|
bugzilla: {
|
|
165
160
|
...config.bugzilla,
|
|
@@ -170,13 +165,17 @@ test.serial('should format with custom types', async (t) => {
|
|
|
170
165
|
},
|
|
171
166
|
};
|
|
172
167
|
|
|
173
|
-
const contributions = await
|
|
168
|
+
const contributions = await gather(specificTypeConfig);
|
|
174
169
|
|
|
175
|
-
|
|
176
|
-
|
|
170
|
+
expect(contributions[0].type).toBe(
|
|
171
|
+
specificTypeConfig.bugzilla.types.createdType
|
|
172
|
+
);
|
|
173
|
+
expect(contributions[1].type).toBe(
|
|
174
|
+
specificTypeConfig.bugzilla.types.commentedType
|
|
175
|
+
);
|
|
177
176
|
});
|
|
178
177
|
|
|
179
|
-
test
|
|
178
|
+
test('should ignore comments older than stopDate', async () => {
|
|
180
179
|
const bugsPage = {
|
|
181
180
|
bugs: [
|
|
182
181
|
{
|
|
@@ -208,9 +207,12 @@ test.serial('should ignore comments older than stopDate', async (t) => {
|
|
|
208
207
|
},
|
|
209
208
|
};
|
|
210
209
|
|
|
211
|
-
|
|
212
|
-
|
|
210
|
+
const mockedFetch = vi
|
|
211
|
+
.fn()
|
|
212
|
+
.mockResolvedValueOnce({ json: vi.fn().mockResolvedValue(bugsPage) })
|
|
213
|
+
.mockResolvedValueOnce({ json: vi.fn().mockResolvedValue(oldComments) });
|
|
214
|
+
vi.stubGlobal('fetch', mockedFetch);
|
|
213
215
|
|
|
214
|
-
const contributions = await
|
|
215
|
-
|
|
216
|
+
const contributions = await gather(config);
|
|
217
|
+
expect(contributions.length).toBe(0);
|
|
216
218
|
});
|
package/lib/community-portal.js
CHANGED
|
@@ -1,20 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import Debug from 'debug';
|
|
2
|
+
import { JSDOM } from 'jsdom';
|
|
3
3
|
|
|
4
|
-
const
|
|
5
|
-
|
|
4
|
+
const debug = Debug('contributions:community-portal');
|
|
5
|
+
|
|
6
|
+
export const EVENTS_CATEGORY = 'community-portal-events';
|
|
7
|
+
export const CAMPAIGNS_CATEGORY = 'community-portal-campaigns';
|
|
6
8
|
|
|
7
9
|
const TYPE_PARTICIPATION = 'Participated in an event';
|
|
8
10
|
const TYPE_CAMPAIGN = 'Participated in a campaign';
|
|
9
11
|
|
|
10
|
-
|
|
11
|
-
EVENTS_CATEGORY,
|
|
12
|
-
CAMPAIGNS_CATEGORY,
|
|
13
|
-
gather,
|
|
14
|
-
validate,
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
function validate(config) {
|
|
12
|
+
export function validate(config) {
|
|
18
13
|
debug('Validating Community Portal config');
|
|
19
14
|
|
|
20
15
|
if (!config) {
|
|
@@ -30,7 +25,7 @@ function validate(config) {
|
|
|
30
25
|
}
|
|
31
26
|
}
|
|
32
27
|
|
|
33
|
-
async function gather({ communityPortal }) {
|
|
28
|
+
export async function gather({ communityPortal }) {
|
|
34
29
|
if (!communityPortal || (communityPortal && !communityPortal.enabled)) {
|
|
35
30
|
debug('Community Portal source not enabled, skipping');
|
|
36
31
|
return [];
|