From 6c4be4169dbace19d91abfb855c0f48f2a749d41 Mon Sep 17 00:00:00 2001 From: Mark Date: Wed, 29 Nov 2023 23:08:38 -0500 Subject: [PATCH] refactor(queries): modularize last from element --- src/queries/element.ts | 34 ---------------------------------- src/queries/index.ts | 1 + src/queries/last.ts | 37 +++++++++++++++++++++++++++++++++++++ 3 files changed, 38 insertions(+), 34 deletions(-) create mode 100644 src/queries/last.ts diff --git a/src/queries/element.ts b/src/queries/element.ts index 8ec79caa0..d07a3e65c 100644 --- a/src/queries/element.ts +++ b/src/queries/element.ts @@ -2,40 +2,6 @@ import { When } from '@badeball/cypress-cucumber-preprocessor'; import { getCypressElement, setCypressElement } from '../utils'; -/** - * When I get last element: - * - * ```gherkin - * When I get last element - * ``` - * - * @example - * - * ```gherkin - * When I get last element - * ``` - * - * @remarks - * - * This follows steps like {@link When_I_find_links_by_text | "When I find links by text"} and precedes steps like {@link When_I_click | "When I click"}. For example: - * - * ```gherkin - * When I find links by text "Link" - * And I get last element - * And I click - * ``` - * - * @see - * - * - {@link When_I_get_first_element | When I get first element} - * - {@link When_I_get_nth_element | When I get nth element} - */ -export function When_I_get_last_element() { - setCypressElement(getCypressElement().last()); -} - -When('I get last element', When_I_get_last_element); - /** * When I get nth element: * diff --git a/src/queries/index.ts b/src/queries/index.ts index 137f2fd57..7109e925e 100644 --- a/src/queries/index.ts +++ b/src/queries/index.ts @@ -11,6 +11,7 @@ export * from './get'; export * from './heading'; export * from './input'; export * from './label'; +export * from './last'; export * from './link'; export * from './name'; export * from './placeholder'; diff --git a/src/queries/last.ts b/src/queries/last.ts new file mode 100644 index 000000000..f5d1adcd2 --- /dev/null +++ b/src/queries/last.ts @@ -0,0 +1,37 @@ +import { When } from '@badeball/cypress-cucumber-preprocessor'; + +import { getCypressElement, setCypressElement } from '../utils'; + +/** + * When I get last element: + * + * ```gherkin + * When I get last element + * ``` + * + * @example + * + * ```gherkin + * When I get last element + * ``` + * + * @remarks + * + * This follows steps like {@link When_I_find_links_by_text | "When I find links by text"} and precedes steps like {@link When_I_click | "When I click"}. For example: + * + * ```gherkin + * When I find links by text "Link" + * And I get last element + * And I click + * ``` + * + * @see + * + * - {@link When_I_get_nth_element | When I get nth element} + * - {@link When_I_get_first_element | When I get first element} + */ +export function When_I_get_last_element() { + setCypressElement(getCypressElement().last()); +} + +When('I get last element', When_I_get_last_element);