-
Notifications
You must be signed in to change notification settings - Fork 0
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 #102 from joomcode/fix/use-testId-instead-of-locat…
…orId fix: rename `locatorId` to `testId` everywhere
- Loading branch information
Showing
26 changed files
with
140 additions
and
168 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 |
---|---|---|
@@ -1,20 +1,9 @@ | ||
import {attributesOptions} from 'autotests/constants'; | ||
import {createSelectorFunction} from 'e2ed/selectors'; | ||
|
||
import type {CreateSelector} from 'e2ed/types'; | ||
|
||
/** | ||
* Main functions for creating selectors and working with selectors. | ||
* Main function for creating selectors and working with selectors. | ||
*/ | ||
export const createSelector: CreateSelector = createSelectorFunction({ | ||
getLocatorAttributeName: (parameter) => { | ||
if (parameter === 'id') { | ||
return 'data-testid'; | ||
} | ||
|
||
if (parameter === 'runhash') { | ||
return 'data-runhash'; | ||
} | ||
|
||
return `data-test-${parameter}`; | ||
}, | ||
}); | ||
export const createSelector: CreateSelector = createSelectorFunction(attributesOptions); |
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
export {createSelector} from './createSelector'; | ||
export {htmlElementSelector} from './htmlElementSelector'; | ||
export {inputSelector} from './inputSelector'; | ||
export {cssSelector, locator, testId} from './locator'; | ||
export {getCssSelector, getTestId, locator} from './locator'; |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,7 +1,7 @@ | ||
// eslint-disable-next-line no-restricted-syntax | ||
export * from 'create-locator'; | ||
// eslint-disable-next-line import/no-internal-modules | ||
export {createTestUtils} from 'create-locator/createTestUtils'; | ||
export {createTestLocator} from 'create-locator/createTestLocator'; | ||
export type {PARAMETERS} from 'create-locator/oldTypes'; | ||
// eslint-disable-next-line import/no-internal-modules | ||
export {getCssSelectorFromAttributesChain} from 'create-locator/getCssSelectorFromAttributesChain'; |
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 |
---|---|---|
@@ -1,19 +1,25 @@ | ||
import {setCustomInspectOnFunction} from '../utils/fn'; | ||
import {DESCRIPTION_KEY} from '../constants/internal'; | ||
import {generalLog} from '../utils/generalLog'; | ||
import {createSelectorCreator} from '../utils/selectors'; | ||
import {createCustomMethods, createGetTrap, Selector as SelectorClass} from '../utils/selectors'; | ||
import {setReadonlyProperty} from '../utils/setReadonlyProperty'; | ||
|
||
import type {CreateSelector, CreateSelectorFunctionOptions} from '../types/internal'; | ||
import type {CreateSelector, CreateSelectorFunctionOptions, Selector} from '../types/internal'; | ||
|
||
/** | ||
* Creates `createSelector` function. | ||
*/ | ||
export const createSelectorFunction = ({ | ||
getLocatorAttributeName, | ||
}: CreateSelectorFunctionOptions): CreateSelector => { | ||
setCustomInspectOnFunction(getLocatorAttributeName); | ||
generalLog('Create selector functions', {getLocatorAttributeName}); | ||
export const createSelectorFunction = ( | ||
attributesOptions: CreateSelectorFunctionOptions, | ||
): CreateSelector => { | ||
generalLog('Create selector function', {attributesOptions}); | ||
|
||
const createSelector = createSelectorCreator(getLocatorAttributeName); | ||
const customMethods = createCustomMethods(attributesOptions); | ||
|
||
return createSelector; | ||
return (locator) => { | ||
const selector = new SelectorClass(locator) as unknown as Selector; | ||
|
||
setReadonlyProperty(selector, DESCRIPTION_KEY, locator); | ||
|
||
return new Proxy(selector, {get: createGetTrap(customMethods)}); | ||
}; | ||
}; |
Oops, something went wrong.