ToolJet/cypress-tests/cypress/constants/selectors/restAPI.js
Mekhla Asopa 3fde1e14b2
Added data-cy for data source (#12815)
* added datasource data-cy

* add method to get data-cy

* update the required fix

* fix format

* fix selectors

* fix selector for appSlug spec

---------

Co-authored-by: Akshay <[email protected]>
2025-05-09 10:18:07 +05:30

44 lines
1.6 KiB
JavaScript

export const cyParamName = (paramName = "") => {
return String(paramName)
.toLowerCase()
.replace(/\(s\)/g, "")
.replace(/\s+/g, "-");
};
export const restAPISelector = {
accordionHeader: (header) => {
return `[data-cy="widget-accordion-${cyParamName(header)}"]`;
},
subHeaderLabel: (header) => {
return `[data-cy="label-${cyParamName(header)}"]`;
},
subSection: (header) => {
return `[data-cy="${cyParamName(header)}-section"]`;
},
keyInputField: (header, index) => {
return `[data-cy="${cyParamName(header)}-key-input-field-${cyParamName(index)}"]`;
},
valueInputField: (header, index) => {
return `[data-cy="${cyParamName(header)}-value-input-field-${cyParamName(index)}"]`;
},
deleteButton: (header, index) => {
return `[data-cy="${cyParamName(header)}-delete-button-${cyParamName(index)}"]`;
},
addMoreButton: (header) => {
return `[data-cy="${cyParamName(header)}-add-button"]`;
},
dropdownLabel: (label) => {
return `[data-cy="${cyParamName(label)}-dropdown-label"]`;
},
inputField: (fieldName) => {
return `[data-cy="${cyParamName(fieldName)}-input-field"]`;
},
button: (buttonName) => {
return `[data-cy="button-${cyParamName(buttonName)}"]`;
},
authenticationAllUsersToggleSwitch:
'[data-cy="authentication-required-for-all-users-toggle-switch"]',
retryNetworkToggleSwitch: '[data-cy="retry-network-errors-toggle-input"]',
retryNetworkToggleText: '[data-cy="retry-network-errors-toggle-text"]',
retryNetworkToggleSubtext: '[data-cy="retry-network-errors-toggle-subtext"]',
readDocumentationLinkText: '[data-cy="link-read-documentation"]',
};