codeceptjs 4.0.0-beta.4 → 4.0.0-beta.6.esm-aria
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 +89 -119
- package/bin/codecept.js +53 -54
- package/docs/webapi/clearCookie.mustache +1 -1
- package/lib/actor.js +70 -102
- package/lib/ai.js +131 -121
- package/lib/assert/empty.js +11 -12
- package/lib/assert/equal.js +16 -21
- package/lib/assert/error.js +2 -2
- package/lib/assert/include.js +11 -15
- package/lib/assert/throws.js +3 -5
- package/lib/assert/truth.js +10 -7
- package/lib/assert.js +18 -18
- package/lib/codecept.js +112 -101
- package/lib/colorUtils.js +48 -50
- package/lib/command/check.js +206 -0
- package/lib/command/configMigrate.js +13 -14
- package/lib/command/definitions.js +24 -36
- package/lib/command/dryRun.js +16 -16
- package/lib/command/generate.js +38 -39
- package/lib/command/gherkin/init.js +36 -38
- package/lib/command/gherkin/snippets.js +76 -74
- package/lib/command/gherkin/steps.js +21 -18
- package/lib/command/info.js +49 -15
- package/lib/command/init.js +41 -37
- package/lib/command/interactive.js +22 -13
- package/lib/command/list.js +11 -10
- package/lib/command/run-multiple/chunk.js +50 -47
- package/lib/command/run-multiple/collection.js +5 -5
- package/lib/command/run-multiple/run.js +3 -3
- package/lib/command/run-multiple.js +27 -47
- package/lib/command/run-rerun.js +6 -7
- package/lib/command/run-workers.js +15 -66
- package/lib/command/run.js +8 -8
- package/lib/command/utils.js +22 -21
- package/lib/command/workers/runTests.js +131 -241
- package/lib/config.js +111 -49
- package/lib/container.js +589 -244
- package/lib/data/context.js +16 -18
- package/lib/data/dataScenarioConfig.js +9 -9
- package/lib/data/dataTableArgument.js +7 -7
- package/lib/data/table.js +6 -12
- package/lib/effects.js +307 -0
- package/lib/els.js +160 -0
- package/lib/event.js +24 -19
- package/lib/globals.js +141 -0
- package/lib/heal.js +89 -81
- package/lib/helper/AI.js +3 -2
- package/lib/helper/ApiDataFactory.js +19 -19
- package/lib/helper/Appium.js +47 -51
- package/lib/helper/FileSystem.js +35 -15
- package/lib/helper/GraphQL.js +1 -1
- package/lib/helper/GraphQLDataFactory.js +4 -4
- package/lib/helper/JSONResponse.js +72 -45
- package/lib/helper/Mochawesome.js +14 -11
- package/lib/helper/Playwright.js +832 -434
- package/lib/helper/Puppeteer.js +393 -292
- package/lib/helper/REST.js +32 -27
- package/lib/helper/WebDriver.js +320 -219
- package/lib/helper/errors/ConnectionRefused.js +6 -6
- package/lib/helper/errors/ElementAssertion.js +11 -16
- package/lib/helper/errors/ElementNotFound.js +5 -9
- package/lib/helper/errors/RemoteBrowserConnectionRefused.js +5 -5
- package/lib/helper/extras/Console.js +11 -11
- package/lib/helper/extras/PlaywrightLocator.js +110 -0
- package/lib/helper/extras/PlaywrightPropEngine.js +18 -18
- package/lib/helper/extras/PlaywrightRestartOpts.js +23 -23
- package/lib/helper/extras/Popup.js +22 -22
- package/lib/helper/extras/React.js +29 -30
- package/lib/helper/network/actions.js +33 -48
- package/lib/helper/network/utils.js +76 -83
- package/lib/helper/scripts/blurElement.js +6 -6
- package/lib/helper/scripts/focusElement.js +6 -6
- package/lib/helper/scripts/highlightElement.js +9 -9
- package/lib/helper/scripts/isElementClickable.js +34 -34
- package/lib/helper.js +2 -1
- package/lib/history.js +23 -20
- package/lib/hooks.js +10 -10
- package/lib/html.js +90 -100
- package/lib/index.js +48 -21
- package/lib/listener/config.js +8 -9
- package/lib/listener/emptyRun.js +54 -0
- package/lib/listener/exit.js +10 -12
- package/lib/listener/{retry.js → globalRetry.js} +10 -10
- package/lib/listener/globalTimeout.js +166 -0
- package/lib/listener/helpers.js +43 -24
- package/lib/listener/mocha.js +4 -5
- package/lib/listener/result.js +11 -0
- package/lib/listener/steps.js +26 -23
- package/lib/listener/store.js +20 -0
- package/lib/locator.js +213 -192
- package/lib/mocha/asyncWrapper.js +264 -0
- package/lib/mocha/bdd.js +167 -0
- package/lib/mocha/cli.js +341 -0
- package/lib/mocha/factory.js +160 -0
- package/lib/{interfaces → mocha}/featureConfig.js +33 -13
- package/lib/{interfaces → mocha}/gherkin.js +75 -45
- package/lib/mocha/hooks.js +121 -0
- package/lib/mocha/index.js +21 -0
- package/lib/mocha/inject.js +46 -0
- package/lib/{interfaces → mocha}/scenarioConfig.js +32 -8
- package/lib/mocha/suite.js +89 -0
- package/lib/mocha/test.js +178 -0
- package/lib/mocha/types.d.ts +42 -0
- package/lib/mocha/ui.js +229 -0
- package/lib/output.js +86 -64
- package/lib/parser.js +44 -44
- package/lib/pause.js +160 -139
- package/lib/plugin/analyze.js +403 -0
- package/lib/plugin/{autoLogin.js → auth.js} +137 -43
- package/lib/plugin/autoDelay.js +19 -15
- package/lib/plugin/coverage.js +22 -27
- package/lib/plugin/customLocator.js +5 -5
- package/lib/plugin/customReporter.js +53 -0
- package/lib/plugin/heal.js +49 -17
- package/lib/plugin/pageInfo.js +140 -0
- package/lib/plugin/pauseOnFail.js +4 -3
- package/lib/plugin/retryFailedStep.js +60 -19
- package/lib/plugin/screenshotOnFail.js +80 -83
- package/lib/plugin/stepByStepReport.js +70 -31
- package/lib/plugin/stepTimeout.js +7 -13
- package/lib/plugin/subtitles.js +10 -9
- package/lib/recorder.js +167 -126
- package/lib/rerun.js +94 -50
- package/lib/result.js +161 -0
- package/lib/secret.js +18 -17
- package/lib/session.js +95 -89
- package/lib/step/base.js +239 -0
- package/lib/step/comment.js +10 -0
- package/lib/step/config.js +50 -0
- package/lib/step/func.js +46 -0
- package/lib/step/helper.js +50 -0
- package/lib/step/meta.js +99 -0
- package/lib/step/record.js +74 -0
- package/lib/step/retry.js +11 -0
- package/lib/step/section.js +55 -0
- package/lib/step.js +18 -332
- package/lib/steps.js +54 -0
- package/lib/store.js +37 -5
- package/lib/template/heal.js +2 -11
- package/lib/timeout.js +60 -0
- package/lib/transform.js +8 -8
- package/lib/translation.js +32 -18
- package/lib/utils.js +354 -250
- package/lib/workerStorage.js +16 -16
- package/lib/workers.js +366 -282
- package/package.json +107 -95
- package/translations/de-DE.js +5 -4
- package/translations/fr-FR.js +5 -4
- package/translations/index.js +23 -9
- package/translations/it-IT.js +5 -4
- package/translations/ja-JP.js +5 -4
- package/translations/nl-NL.js +76 -0
- package/translations/pl-PL.js +5 -4
- package/translations/pt-BR.js +5 -4
- package/translations/ru-RU.js +5 -4
- package/translations/utils.js +18 -0
- package/translations/zh-CN.js +5 -4
- package/translations/zh-TW.js +5 -4
- package/typings/index.d.ts +177 -186
- package/typings/promiseBasedTypes.d.ts +3573 -5941
- package/typings/types.d.ts +4042 -6370
- package/lib/cli.js +0 -256
- package/lib/helper/ExpectHelper.js +0 -391
- package/lib/helper/Nightmare.js +0 -1504
- package/lib/helper/Protractor.js +0 -1863
- package/lib/helper/SoftExpectHelper.js +0 -381
- package/lib/helper/TestCafe.js +0 -1414
- package/lib/helper/clientscripts/nightmare.js +0 -213
- package/lib/helper/extras/PlaywrightReactVueLocator.js +0 -43
- package/lib/helper/testcafe/testControllerHolder.js +0 -42
- package/lib/helper/testcafe/testcafe-utils.js +0 -62
- package/lib/interfaces/bdd.js +0 -81
- package/lib/listener/artifacts.js +0 -19
- package/lib/listener/timeout.js +0 -109
- package/lib/mochaFactory.js +0 -113
- package/lib/plugin/allure.js +0 -15
- package/lib/plugin/commentStep.js +0 -136
- package/lib/plugin/debugErrors.js +0 -67
- package/lib/plugin/eachElement.js +0 -127
- package/lib/plugin/fakerTransform.js +0 -49
- package/lib/plugin/retryTo.js +0 -127
- package/lib/plugin/selenoid.js +0 -384
- package/lib/plugin/standardActingHelpers.js +0 -3
- package/lib/plugin/tryTo.js +0 -115
- package/lib/plugin/wdio.js +0 -249
- package/lib/scenario.js +0 -224
- package/lib/ui.js +0 -236
- package/lib/within.js +0 -70
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* StepConfig is a configuration object for a step.
|
|
3
|
+
* It is used to create a new step that is a combination of other steps.
|
|
4
|
+
*/
|
|
5
|
+
class StepConfig {
|
|
6
|
+
constructor(opts = {}) {
|
|
7
|
+
/** @member {{ opts: Record<string, any>, timeout: number|undefined, retry: number|undefined }} */
|
|
8
|
+
this.config = {
|
|
9
|
+
opts,
|
|
10
|
+
timeout: undefined,
|
|
11
|
+
retry: undefined,
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Set the options for the step.
|
|
17
|
+
* @param {object} opts - The options for the step.
|
|
18
|
+
* @returns {StepConfig} - The step configuration object.
|
|
19
|
+
*/
|
|
20
|
+
opts(opts) {
|
|
21
|
+
this.config.opts = opts
|
|
22
|
+
return this
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Set the timeout for the step.
|
|
27
|
+
* @param {number} timeout - The timeout for the step.
|
|
28
|
+
* @returns {StepConfig} - The step configuration object.
|
|
29
|
+
*/
|
|
30
|
+
timeout(timeout) {
|
|
31
|
+
this.config.timeout = timeout
|
|
32
|
+
return this
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Set the retry for the step.
|
|
37
|
+
* @param {number} retry - The retry for the step.
|
|
38
|
+
* @returns {StepConfig} - The step configuration object.
|
|
39
|
+
*/
|
|
40
|
+
retry(retry) {
|
|
41
|
+
this.config.retry = retry
|
|
42
|
+
return this
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
getConfig() {
|
|
46
|
+
return this.config
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export default StepConfig
|
package/lib/step/func.js
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import BaseStep from './base.js'
|
|
2
|
+
import store from '../store.js'
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Function executed as a step
|
|
6
|
+
*/
|
|
7
|
+
class FuncStep extends BaseStep {
|
|
8
|
+
// this is actual function that should be executed within step
|
|
9
|
+
setCallable(fn) {
|
|
10
|
+
this.fn = fn
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
// helper is optional, if we need to allow step to access helper methods
|
|
14
|
+
setHelper(helper) {
|
|
15
|
+
this.helper = helper
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
run() {
|
|
19
|
+
if (!this.fn) throw new Error('Function is not set')
|
|
20
|
+
|
|
21
|
+
// we wrap that function to track time and status
|
|
22
|
+
// and disable it in dry run mode
|
|
23
|
+
this.args = Array.prototype.slice.call(arguments)
|
|
24
|
+
this.startTime = +Date.now()
|
|
25
|
+
|
|
26
|
+
if (store.dryRun) {
|
|
27
|
+
this.setStatus('success')
|
|
28
|
+
// should we add Proxy and dry run resolver here?
|
|
29
|
+
return Promise.resolve(true)
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
let result
|
|
33
|
+
try {
|
|
34
|
+
result = this.fn.apply(this.helper, this.args)
|
|
35
|
+
this.setStatus('success')
|
|
36
|
+
this.endTime = +Date.now()
|
|
37
|
+
} catch (err) {
|
|
38
|
+
this.endTime = +Date.now()
|
|
39
|
+
this.setStatus('failed')
|
|
40
|
+
throw err
|
|
41
|
+
}
|
|
42
|
+
return result
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export default FuncStep
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import Step from './base.js'
|
|
2
|
+
import store from '../store.js'
|
|
3
|
+
|
|
4
|
+
class HelperStep extends Step {
|
|
5
|
+
constructor(helper, name) {
|
|
6
|
+
super(name)
|
|
7
|
+
/** @member {CodeceptJS.Helper} helper corresponding helper */
|
|
8
|
+
this.helper = helper
|
|
9
|
+
/** @member {string} helperMethod name of method to be executed */
|
|
10
|
+
this.helperMethod = name
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* @param {...any} args
|
|
15
|
+
* @return {*}
|
|
16
|
+
*/
|
|
17
|
+
run() {
|
|
18
|
+
this.args = Array.prototype.slice.call(arguments)
|
|
19
|
+
this.startTime = +Date.now()
|
|
20
|
+
|
|
21
|
+
if (store.dryRun) {
|
|
22
|
+
this.setStatus('success')
|
|
23
|
+
return Promise.resolve(new Proxy({}, dryRunResolver()))
|
|
24
|
+
}
|
|
25
|
+
let result
|
|
26
|
+
try {
|
|
27
|
+
if (this.helperMethod !== 'say') {
|
|
28
|
+
result = this.helper[this.helperMethod].apply(this.helper, this.args)
|
|
29
|
+
}
|
|
30
|
+
this.setStatus('success')
|
|
31
|
+
this.endTime = +Date.now()
|
|
32
|
+
} catch (err) {
|
|
33
|
+
this.endTime = +Date.now()
|
|
34
|
+
this.setStatus('failed')
|
|
35
|
+
throw err
|
|
36
|
+
}
|
|
37
|
+
return result
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export default HelperStep
|
|
42
|
+
|
|
43
|
+
function dryRunResolver() {
|
|
44
|
+
return {
|
|
45
|
+
get(target, prop) {
|
|
46
|
+
if (prop === 'toString') return () => '<VALUE>'
|
|
47
|
+
return new Proxy({}, dryRunResolver())
|
|
48
|
+
},
|
|
49
|
+
}
|
|
50
|
+
}
|
package/lib/step/meta.js
ADDED
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import Step from './base.js'
|
|
2
|
+
import event from '../event.js'
|
|
3
|
+
import { humanizeString } from '../utils.js'
|
|
4
|
+
|
|
5
|
+
class MetaStep extends Step {
|
|
6
|
+
constructor(actor, method) {
|
|
7
|
+
if (!method) method = ''
|
|
8
|
+
super(method)
|
|
9
|
+
|
|
10
|
+
/** @member {boolean} collsapsed hide children steps from output */
|
|
11
|
+
this.collapsed = false
|
|
12
|
+
|
|
13
|
+
this.actor = actor
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/** @return {boolean} */
|
|
17
|
+
isBDD() {
|
|
18
|
+
if (this.actor && this.actor.match && this.actor.match(/^(Given|When|Then|And)/)) {
|
|
19
|
+
return true
|
|
20
|
+
}
|
|
21
|
+
return false
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
toCliStyled() {
|
|
25
|
+
return this.toString()
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
toString() {
|
|
29
|
+
const actorText = this.actor
|
|
30
|
+
|
|
31
|
+
if (this.isBDD()) {
|
|
32
|
+
return `${this.prefix}${actorText} ${this.name} "${this.humanizeArgs()}${this.suffix}"`
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
if (actorText === 'I') {
|
|
36
|
+
return `${this.prefix}${actorText} ${this.humanize()} ${this.humanizeArgs()}${this.suffix}`
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
if (!this.actor) {
|
|
40
|
+
return `${this.name} ${this.humanizeArgs()}${this.suffix}`.trim()
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
return `On ${this.prefix}${actorText}: ${this.humanize()} ${this.humanizeArgs()}${this.suffix}`.trim()
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
humanize() {
|
|
47
|
+
return humanizeString(this.name)
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
setTrace() {}
|
|
51
|
+
|
|
52
|
+
setContext(context) {
|
|
53
|
+
this.context = context
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/** @return {*} */
|
|
57
|
+
run(fn) {
|
|
58
|
+
this.status = 'queued'
|
|
59
|
+
this.setArguments(Array.from(arguments).slice(1))
|
|
60
|
+
let result
|
|
61
|
+
|
|
62
|
+
const registerStep = step => {
|
|
63
|
+
this.setMetaStep(null)
|
|
64
|
+
step.setMetaStep(this)
|
|
65
|
+
}
|
|
66
|
+
event.dispatcher.prependListener(event.step.before, registerStep)
|
|
67
|
+
// Handle async and sync methods.
|
|
68
|
+
if (fn.constructor.name === 'AsyncFunction') {
|
|
69
|
+
result = fn
|
|
70
|
+
.apply(this.context, this.args)
|
|
71
|
+
.then(result => {
|
|
72
|
+
return result
|
|
73
|
+
})
|
|
74
|
+
.catch(error => {
|
|
75
|
+
this.setStatus('failed')
|
|
76
|
+
throw error
|
|
77
|
+
})
|
|
78
|
+
.finally(() => {
|
|
79
|
+
this.endTime = Date.now()
|
|
80
|
+
event.dispatcher.removeListener(event.step.before, registerStep)
|
|
81
|
+
})
|
|
82
|
+
} else {
|
|
83
|
+
try {
|
|
84
|
+
this.startTime = Date.now()
|
|
85
|
+
result = fn.apply(this.context, this.args)
|
|
86
|
+
} catch (error) {
|
|
87
|
+
this.setStatus('failed')
|
|
88
|
+
throw error
|
|
89
|
+
} finally {
|
|
90
|
+
this.endTime = Date.now()
|
|
91
|
+
event.dispatcher.removeListener(event.step.before, registerStep)
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
return result
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
export default MetaStep
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import event from '../event.js'
|
|
2
|
+
import recorder from '../recorder.js'
|
|
3
|
+
import StepConfig from './config.js'
|
|
4
|
+
import output from '../output.js'
|
|
5
|
+
import store from '../store.js'
|
|
6
|
+
import { TIMEOUT_ORDER } from '../timeout.js'
|
|
7
|
+
import retryStep from './retry.js'
|
|
8
|
+
function recordStep(step, args) {
|
|
9
|
+
step.status = 'queued'
|
|
10
|
+
|
|
11
|
+
// apply step configuration
|
|
12
|
+
const lastArg = args[args.length - 1]
|
|
13
|
+
if (lastArg instanceof StepConfig) {
|
|
14
|
+
const stepConfig = args.pop()
|
|
15
|
+
const { opts, timeout, retry } = stepConfig.getConfig()
|
|
16
|
+
|
|
17
|
+
if (opts) {
|
|
18
|
+
output.debug(`Step ${step.name}: options applied ${JSON.stringify(opts)}`)
|
|
19
|
+
store.stepOptions = opts
|
|
20
|
+
step.opts = opts
|
|
21
|
+
}
|
|
22
|
+
if (timeout) {
|
|
23
|
+
output.debug(`Step ${step.name} timeout ${timeout}s`)
|
|
24
|
+
step.setTimeout(timeout * 1000, TIMEOUT_ORDER.codeLimitTime)
|
|
25
|
+
}
|
|
26
|
+
if (retry) retryStep(retry)
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
step.setArguments(args)
|
|
30
|
+
// run async before step hooks
|
|
31
|
+
event.emit(event.step.before, step)
|
|
32
|
+
|
|
33
|
+
const task = `${step.name}: ${step.humanizeArgs()}`
|
|
34
|
+
let val
|
|
35
|
+
|
|
36
|
+
// run step inside promise
|
|
37
|
+
recorder.add(
|
|
38
|
+
task,
|
|
39
|
+
() => {
|
|
40
|
+
if (!step.startTime) {
|
|
41
|
+
// step can be retries
|
|
42
|
+
event.emit(event.step.started, step)
|
|
43
|
+
step.startTime = +Date.now()
|
|
44
|
+
}
|
|
45
|
+
return (val = step.run(...args))
|
|
46
|
+
},
|
|
47
|
+
false,
|
|
48
|
+
undefined,
|
|
49
|
+
step.timeout,
|
|
50
|
+
)
|
|
51
|
+
|
|
52
|
+
event.emit(event.step.after, step)
|
|
53
|
+
|
|
54
|
+
recorder.add('step passed', () => {
|
|
55
|
+
step.endTime = +Date.now()
|
|
56
|
+
event.emit(event.step.passed, step, val)
|
|
57
|
+
event.emit(event.step.finished, step)
|
|
58
|
+
})
|
|
59
|
+
|
|
60
|
+
recorder.catch(err => {
|
|
61
|
+
step.status = 'failed'
|
|
62
|
+
step.endTime = +Date.now()
|
|
63
|
+
event.emit(event.step.failed, step, err)
|
|
64
|
+
event.emit(event.step.finished, step)
|
|
65
|
+
throw err
|
|
66
|
+
})
|
|
67
|
+
|
|
68
|
+
recorder.add('return result', () => val)
|
|
69
|
+
// run async after step hooks
|
|
70
|
+
|
|
71
|
+
return recorder.promise()
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export default recordStep
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import recorder from '../recorder.js'
|
|
2
|
+
import event from '../event.js'
|
|
3
|
+
|
|
4
|
+
function retryStep(opts) {
|
|
5
|
+
if (opts === undefined) opts = 1
|
|
6
|
+
recorder.retry(opts)
|
|
7
|
+
// remove retry once the step passed
|
|
8
|
+
recorder.add(() => event.dispatcher.once(event.step.finished, () => recorder.retries.pop()))
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export default retryStep
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import MetaStep from './meta.js'
|
|
2
|
+
import event from '../event.js'
|
|
3
|
+
|
|
4
|
+
let currentSection
|
|
5
|
+
|
|
6
|
+
class Section {
|
|
7
|
+
constructor(name = '') {
|
|
8
|
+
this.name = name
|
|
9
|
+
|
|
10
|
+
this.metaStep = new MetaStep(null, name)
|
|
11
|
+
|
|
12
|
+
this.attachMetaStep = step => {
|
|
13
|
+
if (currentSection !== this) return
|
|
14
|
+
if (!step) return
|
|
15
|
+
const metaStep = getRootMetaStep(step)
|
|
16
|
+
|
|
17
|
+
if (metaStep !== this.metaStep) {
|
|
18
|
+
metaStep.metaStep = this.metaStep
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
hidden() {
|
|
24
|
+
this.metaStep.collapsed = true
|
|
25
|
+
return this
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
start() {
|
|
29
|
+
if (currentSection) currentSection.end()
|
|
30
|
+
currentSection = this
|
|
31
|
+
event.dispatcher.prependListener(event.step.before, this.attachMetaStep)
|
|
32
|
+
event.dispatcher.once(event.test.finished, () => this.end())
|
|
33
|
+
return this
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
end() {
|
|
37
|
+
currentSection = null
|
|
38
|
+
event.dispatcher.off(event.step.started, this.attachMetaStep)
|
|
39
|
+
return this
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* @returns {Section}
|
|
44
|
+
*/
|
|
45
|
+
static current() {
|
|
46
|
+
return currentSection
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function getRootMetaStep(step) {
|
|
51
|
+
if (step.metaStep) return getRootMetaStep(step.metaStep)
|
|
52
|
+
return step
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export default Section
|