-
-
Notifications
You must be signed in to change notification settings - Fork 27
/
Copy pathedit_commands_common_parameters.js
62 lines (56 loc) · 2.02 KB
/
edit_commands_common_parameters.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
import 'should'
import { wdTest, randomString, shouldNotBeCalled } from '#test/lib/utils'
describe('edit commands common parameters', () => {
describe('summary', () => {
it('should accept a summary', async () => {
const id = 'Q1111'
const summary = randomString()
await wdTest(`set-label ${id} la foo ${randomString()} --summary ${summary}`)
const lastRev = await getLastRev(id)
lastRev.comment.should.endWith(summary)
})
it('should accept a summary in an edit object', async () => {
const id = 'Q1111'
const summary = randomString()
await wdTest(`edit-entity '{"id":"${id}","labels":{"la":"${randomString()}"},"summary":"${summary}"}'`)
const lastRev = await getLastRev(id)
lastRev.comment.should.endWith(summary)
})
})
describe('maxlag', () => {
// This test works if it reaches its timeout, as wikibase-edit will retry
it('should accept a maxlag', async () => {
const id = 'Q1111'
try {
await wdTest(`set-label ${id} la ${randomString()} --maxlag -1`).then(shouldNotBeCalled)
} catch (err) {
err.stderr.should.containEql('"code":"maxlag"')
err.stderr.should.containEql('seconds lagged')
}
})
})
describe('baserevid', () => {
it('should accept a baserevid', async () => {
const id = 'Q1111'
await wdTest(`set-label ${id} la ${randomString()} --baserevid 1`)
.then(shouldNotBeCalled)
.catch(err => {
err.stderr.should.containEql('nosuchrevid')
})
})
it('should accept a baserevid in an edit object', async () => {
const id = 'Q1111'
const editObj = `{"id":"${id}","labels":{"la":"${randomString()}"},"baserevid":1}`
await wdTest(`edit-entity '${editObj}'`)
.then(shouldNotBeCalled)
.catch(err => {
err.stderr.should.containEql('nosuchrevid')
})
})
})
})
const getLastRev = async id => {
const { stdout } = await wdTest(`revisions ${id} --limit 1`)
const { revisions } = JSON.parse(stdout)
return revisions[0]
}