-
-
Notifications
You must be signed in to change notification settings - Fork 730
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
DavertMik
committed
Jan 14, 2025
1 parent
7b97a55
commit 4c97322
Showing
14 changed files
with
278 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
const MetaStep = require('./meta') | ||
const event = require('../event') | ||
|
||
let currentSection | ||
|
||
class Section { | ||
constructor(name = '') { | ||
this.name = name | ||
|
||
this.metaStep = new MetaStep(null, name) | ||
|
||
this.attachMetaStep = step => { | ||
if (currentSection !== this) return | ||
if (!step) return | ||
const metaStep = getRootMetaStep(step) | ||
|
||
if (metaStep !== this.metaStep) { | ||
metaStep.metaStep = this.metaStep | ||
} | ||
} | ||
} | ||
|
||
hidden() { | ||
this.metaStep.collapsed = true | ||
return this | ||
} | ||
|
||
start() { | ||
if (currentSection) currentSection.end() | ||
currentSection = this | ||
event.dispatcher.prependListener(event.step.before, this.attachMetaStep) | ||
event.dispatcher.once(event.test.finished, () => this.end()) | ||
return this | ||
} | ||
|
||
end() { | ||
currentSection = null | ||
event.dispatcher.off(event.step.started, this.attachMetaStep) | ||
return this | ||
} | ||
|
||
/** | ||
* @returns {Section} | ||
*/ | ||
static current() { | ||
return currentSection | ||
} | ||
} | ||
|
||
function getRootMetaStep(step) { | ||
if (step.metaStep) return getRootMetaStep(step.metaStep) | ||
return step | ||
} | ||
|
||
module.exports = Section |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
exports.config = { | ||
tests: './*_test.js', | ||
output: './output', | ||
helpers: { | ||
FileSystem: {}, | ||
CustomHelper: { | ||
require: './customHelper.js', | ||
}, | ||
}, | ||
include: { | ||
userPage: './userPage.js', | ||
}, | ||
bootstrap: false, | ||
mocha: {}, | ||
name: 'step-sections tests', | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
class CustomHelper extends Helper { | ||
act() { | ||
this.debug(JSON.stringify(arguments)) | ||
} | ||
} | ||
|
||
module.exports = CustomHelper |
34 changes: 34 additions & 0 deletions
34
test/data/sandbox/configs/step-sections/step-sections_test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
const { Section, SectionEnd } = require('codeceptjs/steps') | ||
|
||
Feature('step-sections') | ||
|
||
Scenario('test using of basic step-sections', ({ I }) => { | ||
I.amInPath('.') | ||
|
||
Section('User Journey') | ||
I.act('Hello, World!') | ||
|
||
Section() | ||
I.act('Nothing to say') | ||
}) | ||
|
||
Scenario('test using of step-sections and page objects', ({ I, userPage }) => { | ||
Section('User Journey') | ||
userPage.actOnPage() | ||
|
||
I.act('One more step') | ||
|
||
Section() | ||
|
||
I.act('Nothing to say') | ||
}) | ||
|
||
Scenario('test using of hidden step-sections', ({ I, userPage }) => { | ||
Section('User Journey').hidden() | ||
userPage.actOnPage() | ||
I.act('One more step') | ||
|
||
SectionEnd() | ||
|
||
I.act('Nothing to say') | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
const { I } = inject() | ||
|
||
module.exports = { | ||
actOnPage: () => { | ||
I.act('actOnPage') | ||
I.act('see on this page') | ||
}, | ||
} |
Oops, something went wrong.