-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #485 from remarkablemark/feat/assertions
feat(queries): add "When I find headings by text" and "When I find heading by text"
- Loading branch information
Showing
5 changed files
with
93 additions
and
5 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
import { When } from '@badeball/cypress-cucumber-preprocessor'; | ||
|
||
import { getCypressElement, setCypressElement } from '../utils'; | ||
|
||
/** | ||
* When I find headings by text: | ||
* | ||
* ```gherkin | ||
* When I find headings by text {string} | ||
* ``` | ||
* | ||
* @example | ||
* | ||
* ```gherkin | ||
* When I find headings by text "Heading" | ||
* ``` | ||
* | ||
* @remarks | ||
* | ||
* This precedes steps like {@link When_I_click | "When I click"}. For example: | ||
* | ||
* ```gherkin | ||
* When I find headings by text "Heading" | ||
* And I get 1st element | ||
* And I click | ||
* ``` | ||
* | ||
* @see | ||
* | ||
* - {@link When_I_find_heading_by_text | When I find heading by text} | ||
*/ | ||
export function When_I_find_headings_by_text(text: string) { | ||
const selector = ['h1', 'h2', 'h3', 'h4', 'h5', 'h6'] | ||
.map((tag) => `${tag}:contains('${text}'):visible`) | ||
.join(','); | ||
setCypressElement(cy.get(selector)); | ||
} | ||
|
||
When('I find headings by text {string}', When_I_find_headings_by_text); | ||
|
||
/** | ||
* When I find heading by text: | ||
* | ||
* ```gherkin | ||
* When I find heading by text {string} | ||
* ``` | ||
* | ||
* Finds first heading element that matches text. | ||
* | ||
* @example | ||
* | ||
* ```gherkin | ||
* When I find heading by text "Heading" | ||
* ``` | ||
* | ||
* @remarks | ||
* | ||
* This precedes steps like {@link When_I_click | "When I click"}. For example: | ||
* | ||
* ```gherkin | ||
* When I find heading by text "heading" | ||
* And I click | ||
* ``` | ||
* | ||
* @see | ||
* | ||
* - {@link When_I_find_headings_by_text | When I find headings by text} | ||
*/ | ||
export function When_I_find_heading_by_text(text: string) { | ||
When_I_find_headings_by_text(text); | ||
setCypressElement(getCypressElement().first()); | ||
} | ||
|
||
When('I find heading by text {string}', When_I_find_heading_by_text); |
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