agendash 2.0.0 → 3.1.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/README.md +59 -22
- package/app.js +9 -5
- package/bin/agendash-standalone-fastify.js +61 -0
- package/bin/agendash-standalone-hapi.js +36 -18
- package/bin/agendash-standalone-koa.js +30 -14
- package/bin/agendash-standalone.js +44 -19
- package/lib/controllers/agendash.js +228 -110
- package/lib/csp.js +28 -0
- package/lib/middlewares/README.md +3 -1
- package/lib/middlewares/express.js +43 -17
- package/lib/middlewares/fastify.js +77 -0
- package/lib/middlewares/hapi.js +58 -33
- package/lib/middlewares/koa.js +29 -20
- package/package.json +37 -35
- package/public/app/js/confirmDelete.js +14 -13
- package/public/app/js/confirmDeleteMulti.js +14 -13
- package/public/app/js/confirmRequeue.js +14 -13
- package/public/app/js/confirmRequeueMulti.js +15 -14
- package/public/app/js/confirms.js +4 -4
- package/public/app/js/jobdetail.js +9 -9
- package/public/app/js/joblist.js +50 -43
- package/public/app/js/main.js +109 -72
- package/public/app/js/newJob.js +37 -23
- package/public/app/js/sidebar.js +51 -26
- package/public/app/js/topbar.js +15 -5
- package/.editorconfig +0 -7
- package/.idea/agendash.iml +0 -12
- package/.idea/inspectionProfiles/Project_Default.xml +0 -6
- package/.idea/jsLibraryMappings.xml +0 -6
- package/.idea/misc.xml +0 -92
- package/.idea/modules.xml +0 -8
- package/.idea/vcs.xml +0 -6
- package/.travis.yml +0 -27
- package/.vscode/launch.json +0 -15
- package/History.md +0 -106
- package/renovate.json +0 -5
- package/test/test-express.js +0 -82
- package/test/test-hapi.js +0 -106
- package/test/test-koa.js +0 -85
package/.idea/misc.xml
DELETED
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
-
<project version="4">
|
|
3
|
-
<component name="MarkdownProjectSettings" wasCopied="true">
|
|
4
|
-
<PreviewSettings splitEditorLayout="SPLIT" splitEditorPreview="PREVIEW" useGrayscaleRendering="false" zoomFactor="1.0" maxImageWidth="0" showGitHubPageIfSynced="false" allowBrowsingInPreview="false" synchronizePreviewPosition="true" highlightPreviewType="NONE" highlightFadeOut="5" highlightOnTyping="true" synchronizeSourcePosition="true" verticallyAlignSourceAndPreviewSyncPosition="true" showSearchHighlightsInPreview="false" showSelectionInPreview="true" openRemoteLinks="true" replaceUnicodeEmoji="false" lastLayoutSetsDefault="false">
|
|
5
|
-
<PanelProvider>
|
|
6
|
-
<provider providerId="com.vladsch.idea.multimarkdown.editor.swing.html.panel" providerName="Default - Swing" />
|
|
7
|
-
</PanelProvider>
|
|
8
|
-
</PreviewSettings>
|
|
9
|
-
<ParserSettings gitHubSyntaxChange="false" emojiShortcuts="0" emojiImages="0">
|
|
10
|
-
<PegdownExtensions>
|
|
11
|
-
<option name="ABBREVIATIONS" value="false" />
|
|
12
|
-
<option name="ANCHORLINKS" value="true" />
|
|
13
|
-
<option name="ASIDE" value="false" />
|
|
14
|
-
<option name="ATXHEADERSPACE" value="true" />
|
|
15
|
-
<option name="AUTOLINKS" value="true" />
|
|
16
|
-
<option name="DEFINITIONS" value="false" />
|
|
17
|
-
<option name="DEFINITION_BREAK_DOUBLE_BLANK_LINE" value="false" />
|
|
18
|
-
<option name="FENCED_CODE_BLOCKS" value="true" />
|
|
19
|
-
<option name="FOOTNOTES" value="false" />
|
|
20
|
-
<option name="HARDWRAPS" value="false" />
|
|
21
|
-
<option name="HTML_DEEP_PARSER" value="false" />
|
|
22
|
-
<option name="INSERTED" value="false" />
|
|
23
|
-
<option name="QUOTES" value="false" />
|
|
24
|
-
<option name="RELAXEDHRULES" value="true" />
|
|
25
|
-
<option name="SMARTS" value="false" />
|
|
26
|
-
<option name="STRIKETHROUGH" value="true" />
|
|
27
|
-
<option name="SUBSCRIPT" value="false" />
|
|
28
|
-
<option name="SUPERSCRIPT" value="false" />
|
|
29
|
-
<option name="SUPPRESS_HTML_BLOCKS" value="false" />
|
|
30
|
-
<option name="SUPPRESS_INLINE_HTML" value="false" />
|
|
31
|
-
<option name="TABLES" value="true" />
|
|
32
|
-
<option name="TASKLISTITEMS" value="true" />
|
|
33
|
-
<option name="TOC" value="false" />
|
|
34
|
-
<option name="WIKILINKS" value="true" />
|
|
35
|
-
</PegdownExtensions>
|
|
36
|
-
<ParserOptions>
|
|
37
|
-
<option name="ADMONITION_EXT" value="false" />
|
|
38
|
-
<option name="ATTRIBUTES_EXT" value="false" />
|
|
39
|
-
<option name="COMMONMARK_LISTS" value="true" />
|
|
40
|
-
<option name="DUMMY" value="false" />
|
|
41
|
-
<option name="EMOJI_SHORTCUTS" value="true" />
|
|
42
|
-
<option name="ENUMERATED_REFERENCES_EXT" value="false" />
|
|
43
|
-
<option name="FLEXMARK_FRONT_MATTER" value="false" />
|
|
44
|
-
<option name="GFM_LOOSE_BLANK_LINE_AFTER_ITEM_PARA" value="false" />
|
|
45
|
-
<option name="GFM_TABLE_RENDERING" value="true" />
|
|
46
|
-
<option name="GITBOOK_URL_ENCODING" value="false" />
|
|
47
|
-
<option name="GITHUB_LISTS" value="false" />
|
|
48
|
-
<option name="GITHUB_WIKI_LINKS" value="true" />
|
|
49
|
-
<option name="HEADER_ID_NO_DUPED_DASHES" value="false" />
|
|
50
|
-
<option name="JEKYLL_FRONT_MATTER" value="false" />
|
|
51
|
-
<option name="NO_TEXT_ATTRIBUTES" value="false" />
|
|
52
|
-
<option name="PARSE_HTML_ANCHOR_ID" value="false" />
|
|
53
|
-
<option name="SIM_TOC_BLANK_LINE_SPACER" value="true" />
|
|
54
|
-
</ParserOptions>
|
|
55
|
-
</ParserSettings>
|
|
56
|
-
<HtmlSettings headerTopEnabled="false" headerBottomEnabled="false" bodyTopEnabled="false" bodyBottomEnabled="false" embedUrlContent="false" addPageHeader="true" embedImages="false" embedHttpImages="false" imageUriSerials="false">
|
|
57
|
-
<GeneratorProvider>
|
|
58
|
-
<provider providerId="com.vladsch.idea.multimarkdown.editor.swing.html.generator" providerName="Default Swing HTML Generator" />
|
|
59
|
-
</GeneratorProvider>
|
|
60
|
-
<headerTop />
|
|
61
|
-
<headerBottom />
|
|
62
|
-
<bodyTop />
|
|
63
|
-
<bodyBottom />
|
|
64
|
-
</HtmlSettings>
|
|
65
|
-
<CssSettings previewScheme="UI_SCHEME" cssUri="" isCssUriEnabled="false" isCssUriSerial="true" isCssTextEnabled="false" isDynamicPageWidth="true">
|
|
66
|
-
<StylesheetProvider>
|
|
67
|
-
<provider providerId="com.vladsch.idea.multimarkdown.editor.swing.html.css" providerName="Default Swing Stylesheet" />
|
|
68
|
-
</StylesheetProvider>
|
|
69
|
-
<ScriptProviders />
|
|
70
|
-
<cssText />
|
|
71
|
-
<cssUriHistory />
|
|
72
|
-
</CssSettings>
|
|
73
|
-
<HtmlExportSettings updateOnSave="false" parentDir="" targetDir="" cssDir="" scriptDir="" plainHtml="false" imageDir="" copyLinkedImages="false" imageUniquifyType="0" targetExt="" useTargetExt="false" noCssNoScripts="false" linkToExportedHtml="true" exportOnSettingsChange="true" regenerateOnProjectOpen="false" linkFormatType="HTTP_ABSOLUTE" />
|
|
74
|
-
<LinkMapSettings>
|
|
75
|
-
<textMaps />
|
|
76
|
-
</LinkMapSettings>
|
|
77
|
-
</component>
|
|
78
|
-
<component name="accountSettings">
|
|
79
|
-
<option name="activeProfile" value="profile:default" />
|
|
80
|
-
<option name="activeRegion" value="ap-southeast-2" />
|
|
81
|
-
<option name="recentlyUsedProfiles">
|
|
82
|
-
<list>
|
|
83
|
-
<option value="profile:default" />
|
|
84
|
-
</list>
|
|
85
|
-
</option>
|
|
86
|
-
<option name="recentlyUsedRegions">
|
|
87
|
-
<list>
|
|
88
|
-
<option value="ap-southeast-2" />
|
|
89
|
-
</list>
|
|
90
|
-
</option>
|
|
91
|
-
</component>
|
|
92
|
-
</project>
|
package/.idea/modules.xml
DELETED
package/.idea/vcs.xml
DELETED
package/.travis.yml
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
language: node_js
|
|
2
|
-
node_js:
|
|
3
|
-
- 10
|
|
4
|
-
- 12
|
|
5
|
-
- 14
|
|
6
|
-
env:
|
|
7
|
-
- AGENDA_VERSION=^4.0.0
|
|
8
|
-
- AGENDA_VERSION=^3.1.0
|
|
9
|
-
matrix:
|
|
10
|
-
fast_finish: true
|
|
11
|
-
script: npm test
|
|
12
|
-
install: npm ci
|
|
13
|
-
services:
|
|
14
|
-
- mongodb
|
|
15
|
-
sudo: false
|
|
16
|
-
addons:
|
|
17
|
-
apt:
|
|
18
|
-
sources:
|
|
19
|
-
- mongodb-upstart
|
|
20
|
-
packages:
|
|
21
|
-
- mongodb-org-server
|
|
22
|
-
- mongodb-org-shell
|
|
23
|
-
before_script:
|
|
24
|
-
- mongo --version
|
|
25
|
-
- mongod --version
|
|
26
|
-
- 'if [ "$AGENDA_VERSION" ]; then npm install agenda@$AGENDA_VERSION; fi'
|
|
27
|
-
- 'until nc -z 127.0.0.1 27017 ; do echo Waiting for MongoDB; sleep 1; done'
|
package/.vscode/launch.json
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
// Use IntelliSense to learn about possible attributes.
|
|
3
|
-
// Hover to view descriptions of existing attributes.
|
|
4
|
-
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
|
5
|
-
"version": "0.2.0",
|
|
6
|
-
"configurations": [
|
|
7
|
-
{
|
|
8
|
-
"type": "chrome",
|
|
9
|
-
"request": "launch",
|
|
10
|
-
"name": "Launch Chrome against localhost",
|
|
11
|
-
"url": "http://localhost:3002",
|
|
12
|
-
"webRoot": "${workspaceFolder}"
|
|
13
|
-
}
|
|
14
|
-
]
|
|
15
|
-
}
|
package/History.md
DELETED
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
2.0.0 - First public release of v2 as Agendash proper
|
|
2
|
-
====
|
|
3
|
-
|
|
4
|
-
Complete rewrite of Agendash in Vue.js!
|
|
5
|
-
|
|
6
|
-
Supports Node.js 10 and up.
|
|
7
|
-
|
|
8
|
-
2.0.0-beta0.8.2 / 2020-12-04 - As agendash2, in parallel repository https://github.com/agenda/agendash-v2
|
|
9
|
-
====
|
|
10
|
-
* fix: search by job name, small side bar design fix and toggle improvements (thanks @simllll)
|
|
11
|
-
* fix: joblist reset fix (thanks @simllll)
|
|
12
|
-
* fix: improve design on desktop + close sidebar on mobile when clicked on something (thanks @simllll)
|
|
13
|
-
* feat: enable options.query as number (thanks @Enubia @simllll)
|
|
14
|
-
* feat: multiselect checkboxes (thanks @Enubia @simllll)
|
|
15
|
-
|
|
16
|
-
2.0.0-beta0.1.0 / 2020-04-30 - First public release of Agendash2 in parallel repository https://github.com/agenda/agendash-v2
|
|
17
|
-
====
|
|
18
|
-
* New frontend written from scratch in Vue.js
|
|
19
|
-
* Add search
|
|
20
|
-
* Add pagination
|
|
21
|
-
* Change default refresh interval to 60 seconds
|
|
22
|
-
|
|
23
|
-
1.0.0 / 2019-02-25
|
|
24
|
-
====
|
|
25
|
-
* Add Hapi v17 middleware, drop support for Node.js v6 & v7 (#81) by umens (**BREAKING**)
|
|
26
|
-
* Support Agenda version 2 by alexkwolfe (**BREAKING**)
|
|
27
|
-
|
|
28
|
-
0.5.0 / 2019-02-25
|
|
29
|
-
====
|
|
30
|
-
|
|
31
|
-
* Update dependencies (#69, #70) (**BREAKING**)
|
|
32
|
-
* Agenda `>=0.7.0 <1.0.0` → `^1.0.3` and thus require MongoDB v3+
|
|
33
|
-
* async `^1.0.0` → `^2.6.0`
|
|
34
|
-
* Drop support for Node.js v4 and v5 (might still work but we're stopping testing these) (**BREAKING**)
|
|
35
|
-
* Switch testing with Mocha to [Ava](https://www.npmjs.com/package/ava) (#70)
|
|
36
|
-
* Docker support (#54) by WoLfulus
|
|
37
|
-
* Fix 404 errors when deleting and re-queuing jobs (#61) by koresar
|
|
38
|
-
|
|
39
|
-
0.4.0 / 2016-10-27
|
|
40
|
-
==================
|
|
41
|
-
|
|
42
|
-
* (simison) Agenda dependency version `<1.0.0` to avoid breaking dependency.
|
|
43
|
-
* (loris) Fix #24 - Added indexes for faster queries.
|
|
44
|
-
* Fix #28 - Removed dependency on Mongo Driver.
|
|
45
|
-
* Added API tests with mocha and supertest. No frontend tests.
|
|
46
|
-
|
|
47
|
-
0.3.2 / 2016-06-30
|
|
48
|
-
==================
|
|
49
|
-
|
|
50
|
-
* (HugoCornu) Fix #19 "Schedule Job" - Don't repeat job if user didn't want it repeated
|
|
51
|
-
|
|
52
|
-
0.3.1 / 2016-04-12
|
|
53
|
-
==================
|
|
54
|
-
|
|
55
|
-
* (simison) Add engines key to package.json
|
|
56
|
-
|
|
57
|
-
0.3.0 / 2016-04-04
|
|
58
|
-
==================
|
|
59
|
-
|
|
60
|
-
* (bh-chaker) Schedule Job Feature - create new jobs from the UI
|
|
61
|
-
* Limit to 200 jobs on page, no UI for configuration
|
|
62
|
-
|
|
63
|
-
0.2.1 / 2016-03-25
|
|
64
|
-
==================
|
|
65
|
-
|
|
66
|
-
* (vziukas) Recurring job count and labels
|
|
67
|
-
* Fixed "queued" label colors
|
|
68
|
-
|
|
69
|
-
0.2.0 / 2016-03-18
|
|
70
|
-
==================
|
|
71
|
-
|
|
72
|
-
* (vziukas) Configurable title
|
|
73
|
-
* Middleware option moved to "options" object
|
|
74
|
-
|
|
75
|
-
0.1.1 / 2016-03-17
|
|
76
|
-
==================
|
|
77
|
-
|
|
78
|
-
* (vziukas) multiple instances of agendash can each have a separate agenda
|
|
79
|
-
|
|
80
|
-
0.1.0 / 2016-03-15
|
|
81
|
-
==================
|
|
82
|
-
|
|
83
|
-
* (rapidia) remove "arrow function" syntax for non-chrome browsers
|
|
84
|
-
* (ebourmalo) Fix the middleware usage and use a proper structure
|
|
85
|
-
|
|
86
|
-
0.0.5 / 2016-02-24
|
|
87
|
-
==================
|
|
88
|
-
|
|
89
|
-
* Batch requeue and delete
|
|
90
|
-
* Select All and Select None
|
|
91
|
-
|
|
92
|
-
0.0.4 / 2016-02-24
|
|
93
|
-
==================
|
|
94
|
-
|
|
95
|
-
* Select multiple jobs
|
|
96
|
-
|
|
97
|
-
0.0.2 / 2016-02-23
|
|
98
|
-
==================
|
|
99
|
-
|
|
100
|
-
* version bump so npm will update docs
|
|
101
|
-
* Added screenshots
|
|
102
|
-
|
|
103
|
-
0.0.1 / 2016-02-23
|
|
104
|
-
==================
|
|
105
|
-
|
|
106
|
-
* Initial Release
|
package/test/test-express.js
DELETED
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
const test = require('ava');
|
|
2
|
-
const supertest = require('supertest');
|
|
3
|
-
const express = require('express');
|
|
4
|
-
const Agenda = require('agenda');
|
|
5
|
-
|
|
6
|
-
const agenda = new Agenda().database('mongodb://127.0.0.1/agendash-test-db', 'agendash-test-collection', {useUnifiedTopology: true});
|
|
7
|
-
|
|
8
|
-
const app = express();
|
|
9
|
-
app.use('/', require('../app')(agenda));
|
|
10
|
-
|
|
11
|
-
const request = supertest(app);
|
|
12
|
-
|
|
13
|
-
test.before.cb(t => {
|
|
14
|
-
agenda.on('ready', () => {
|
|
15
|
-
t.end();
|
|
16
|
-
});
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
test.beforeEach(async() => {
|
|
20
|
-
await agenda._collection.deleteMany({}, null);
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
test.serial('GET /api with no jobs should return the correct overview', async t => {
|
|
24
|
-
const response = await request.get('/api?limit=200&skip=0');
|
|
25
|
-
|
|
26
|
-
t.is(response.body.overview[0].displayName, 'All Jobs');
|
|
27
|
-
t.is(response.body.jobs.length, 0);
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
test.serial('POST /api/jobs/create should confirm the job exists', async t => {
|
|
31
|
-
const response = await request.post('/api/jobs/create')
|
|
32
|
-
.send({
|
|
33
|
-
jobName: 'Test Job',
|
|
34
|
-
jobSchedule: 'in 2 minutes',
|
|
35
|
-
jobRepeatEvery: '',
|
|
36
|
-
jobData: {}
|
|
37
|
-
})
|
|
38
|
-
.set('Accept', 'application/json');
|
|
39
|
-
|
|
40
|
-
t.true('created' in response.body);
|
|
41
|
-
|
|
42
|
-
agenda._collection.count({}, null, (error, result) => {
|
|
43
|
-
t.falsy(error);
|
|
44
|
-
if (result !== 1) {
|
|
45
|
-
throw new Error('Expected one document in database');
|
|
46
|
-
}
|
|
47
|
-
});
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
test.serial('POST /api/jobs/delete should delete the job', async t => {
|
|
51
|
-
const job = await agenda.create('Test Job', {})
|
|
52
|
-
.schedule('in 4 minutes')
|
|
53
|
-
.save();
|
|
54
|
-
|
|
55
|
-
const response = await request.post('/api/jobs/delete')
|
|
56
|
-
.send({
|
|
57
|
-
jobIds: [job.attrs._id]
|
|
58
|
-
})
|
|
59
|
-
.set('Accept', 'application/json');
|
|
60
|
-
|
|
61
|
-
t.true('deleted' in response.body);
|
|
62
|
-
|
|
63
|
-
const count = await agenda._collection.count({}, null);
|
|
64
|
-
t.is(count, 0);
|
|
65
|
-
});
|
|
66
|
-
|
|
67
|
-
test.serial('POST /api/jobs/requeue should requeue the job', async t => {
|
|
68
|
-
const job = await agenda.create('Test Job', {})
|
|
69
|
-
.schedule('in 4 minutes')
|
|
70
|
-
.save();
|
|
71
|
-
|
|
72
|
-
const response = await request.post('/api/jobs/requeue')
|
|
73
|
-
.send({
|
|
74
|
-
jobIds: [job.attrs._id]
|
|
75
|
-
})
|
|
76
|
-
.set('Accept', 'application/json');
|
|
77
|
-
|
|
78
|
-
t.false('newJobs' in response.body);
|
|
79
|
-
|
|
80
|
-
const count = await agenda._collection.count({}, null);
|
|
81
|
-
t.is(count, 2);
|
|
82
|
-
});
|
package/test/test-hapi.js
DELETED
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
const nodeVersionIsSupported = Number(process.versions.node.split('.')[0]) > 10;
|
|
2
|
-
|
|
3
|
-
const test = require('ava');
|
|
4
|
-
const supertest = require('supertest');
|
|
5
|
-
const Agenda = require('agenda');
|
|
6
|
-
|
|
7
|
-
const agenda = new Agenda().database('mongodb://127.0.0.1/agendash-test-db', 'agendash-test-collection');
|
|
8
|
-
let request;
|
|
9
|
-
// eslint-disable-next-line eslint-comments/disable-enable-pair
|
|
10
|
-
/* eslint-disable ava/no-unknown-modifiers */
|
|
11
|
-
const testType = nodeVersionIsSupported ? 'serial' : 'skip';
|
|
12
|
-
|
|
13
|
-
test.before.cb(t => {
|
|
14
|
-
if (!nodeVersionIsSupported) {
|
|
15
|
-
return t.end();
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
const Hapi = require('@hapi/hapi');
|
|
19
|
-
const server = Hapi.server({
|
|
20
|
-
port: 3000,
|
|
21
|
-
host: 'localhost'
|
|
22
|
-
});
|
|
23
|
-
server.register(require('@hapi/inert'));
|
|
24
|
-
server.register(require('../app')(agenda, {
|
|
25
|
-
middleware: 'hapi'
|
|
26
|
-
}));
|
|
27
|
-
|
|
28
|
-
request = supertest(server.listener);
|
|
29
|
-
|
|
30
|
-
agenda.on('ready', () => {
|
|
31
|
-
t.end();
|
|
32
|
-
});
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
test.beforeEach(async() => {
|
|
36
|
-
await agenda._collection.deleteMany({}, null);
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
test[testType]('GET /api with no jobs should return the correct overview', async t => {
|
|
40
|
-
const response = await request.get('/api?limit=200&skip=0');
|
|
41
|
-
|
|
42
|
-
t.is(response.body.overview[0].displayName, 'All Jobs');
|
|
43
|
-
t.is(response.body.jobs.length, 0);
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
test[testType]('POST /api/jobs/create should confirm the job exists', async t => {
|
|
47
|
-
const response = await request.post('/api/jobs/create')
|
|
48
|
-
.send({
|
|
49
|
-
jobName: 'Test Job',
|
|
50
|
-
jobSchedule: 'in 2 minutes',
|
|
51
|
-
jobRepeatEvery: '',
|
|
52
|
-
jobData: {}
|
|
53
|
-
})
|
|
54
|
-
.set('Accept', 'application/json');
|
|
55
|
-
|
|
56
|
-
t.true('created' in response.body);
|
|
57
|
-
|
|
58
|
-
agenda._collection.count({}, null, (error, result) => {
|
|
59
|
-
t.falsy(error);
|
|
60
|
-
if (result !== 1) {
|
|
61
|
-
throw new Error('Expected one document in database');
|
|
62
|
-
}
|
|
63
|
-
});
|
|
64
|
-
});
|
|
65
|
-
|
|
66
|
-
test[testType]('POST /api/jobs/delete should delete the job', async t => {
|
|
67
|
-
const job = await agenda.create('Test Job', {})
|
|
68
|
-
.schedule('in 4 minutes')
|
|
69
|
-
.save();
|
|
70
|
-
|
|
71
|
-
const response = await request.post('/api/jobs/delete')
|
|
72
|
-
.send({
|
|
73
|
-
jobIds: [job.attrs._id]
|
|
74
|
-
})
|
|
75
|
-
.set('Accept', 'application/json');
|
|
76
|
-
|
|
77
|
-
t.true('deleted' in response.body);
|
|
78
|
-
|
|
79
|
-
const count = await agenda._collection.count({}, null);
|
|
80
|
-
t.is(count, 0);
|
|
81
|
-
});
|
|
82
|
-
|
|
83
|
-
test[testType]('POST /api/jobs/requeue should requeue the job', async t => {
|
|
84
|
-
const job = await new Promise((resolve, reject) => {
|
|
85
|
-
agenda.create('Test Job', {})
|
|
86
|
-
.schedule('in 4 minutes')
|
|
87
|
-
.save()
|
|
88
|
-
.then(job => {
|
|
89
|
-
resolve(job);
|
|
90
|
-
})
|
|
91
|
-
.catch(error => {
|
|
92
|
-
reject(error);
|
|
93
|
-
});
|
|
94
|
-
});
|
|
95
|
-
|
|
96
|
-
const response = await request.post('/api/jobs/requeue')
|
|
97
|
-
.send({
|
|
98
|
-
jobIds: [job.attrs._id]
|
|
99
|
-
})
|
|
100
|
-
.set('Accept', 'application/json');
|
|
101
|
-
|
|
102
|
-
t.false('newJobs' in response.body);
|
|
103
|
-
|
|
104
|
-
const count = await agenda._collection.count({}, null);
|
|
105
|
-
t.is(count, 2);
|
|
106
|
-
});
|
package/test/test-koa.js
DELETED
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
const test = require('ava');
|
|
2
|
-
const supertest = require('supertest');
|
|
3
|
-
const Koa = require('koa');
|
|
4
|
-
const Agenda = require('agenda');
|
|
5
|
-
|
|
6
|
-
const agenda = new Agenda().database('mongodb://127.0.0.1/agendash-test-db', 'agendash-test-collection');
|
|
7
|
-
|
|
8
|
-
const app = new Koa();
|
|
9
|
-
const middlewares = require('../app')(agenda, {
|
|
10
|
-
middleware: 'koa'
|
|
11
|
-
});
|
|
12
|
-
for (const middleware of middlewares) {
|
|
13
|
-
app.use(middleware);
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
const request = supertest.agent(app.listen());
|
|
17
|
-
|
|
18
|
-
test.before.cb(t => {
|
|
19
|
-
agenda.on('ready', () => {
|
|
20
|
-
t.end();
|
|
21
|
-
});
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
test.beforeEach(async() => {
|
|
25
|
-
await agenda._collection.deleteMany({}, null);
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
test.serial('GET /api with no jobs should return the correct overview', async t => {
|
|
29
|
-
const response = await request.get('/api');
|
|
30
|
-
|
|
31
|
-
t.is(response.body.overview[0].displayName, 'All Jobs');
|
|
32
|
-
t.is(response.body.jobs.length, 0);
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
test.serial('POST /api/jobs/create should confirm the job exists', async t => {
|
|
36
|
-
const response = await request.post('/api/jobs/create')
|
|
37
|
-
.send({
|
|
38
|
-
jobName: 'Test Job',
|
|
39
|
-
jobSchedule: 'in 2 minutes',
|
|
40
|
-
jobRepeatEvery: '',
|
|
41
|
-
jobData: {}
|
|
42
|
-
})
|
|
43
|
-
.set('Accept', 'application/json');
|
|
44
|
-
|
|
45
|
-
t.true('created' in response.body);
|
|
46
|
-
|
|
47
|
-
const result = await agenda._collection.count({});
|
|
48
|
-
if (result !== 1) {
|
|
49
|
-
throw new Error('Expected one document in database');
|
|
50
|
-
}
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
test.serial('POST /api/jobs/delete should delete the job', async t => {
|
|
54
|
-
const job = await agenda.create('Test Job', {})
|
|
55
|
-
.schedule('in 4 minutes')
|
|
56
|
-
.save();
|
|
57
|
-
|
|
58
|
-
const response = await request.post('/api/jobs/delete')
|
|
59
|
-
.send({
|
|
60
|
-
jobIds: [job.attrs._id]
|
|
61
|
-
})
|
|
62
|
-
.set('Accept', 'application/json');
|
|
63
|
-
|
|
64
|
-
t.true('deleted' in response.body);
|
|
65
|
-
|
|
66
|
-
const count = await agenda._collection.count({}, null);
|
|
67
|
-
t.is(count, 0);
|
|
68
|
-
});
|
|
69
|
-
|
|
70
|
-
test.serial('POST /api/jobs/requeue should requeue the job', async t => {
|
|
71
|
-
const job = await agenda.create('Test Job', {})
|
|
72
|
-
.schedule('in 4 minutes')
|
|
73
|
-
.save();
|
|
74
|
-
|
|
75
|
-
const response = await request.post('/api/jobs/requeue')
|
|
76
|
-
.send({
|
|
77
|
-
jobIds: [job.attrs._id]
|
|
78
|
-
})
|
|
79
|
-
.set('Accept', 'application/json');
|
|
80
|
-
|
|
81
|
-
t.false('newJobs' in response.body);
|
|
82
|
-
|
|
83
|
-
const count = await agenda._collection.count({}, null);
|
|
84
|
-
t.is(count, 2);
|
|
85
|
-
});
|