You can not select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
		
			
				
					46 lines
				
				1.1 KiB
			
		
		
			
		
	
	
					46 lines
				
				1.1 KiB
			| 
											3 years ago
										 | /// <reference types="cypress" />
 | ||
|  | 
 | ||
|  | /** | ||
|  |  * @method abGetProperty | ||
|  |  * @description | ||
|  |  * ### Usage | ||
|  |  * | ||
|  |  * ```javascript
 | ||
|  |  * // your property in AdminJS
 | ||
|  |  * resourceOptions: { | ||
|  |  *   properties: { | ||
|  |  *     isAdmin: {...} | ||
|  |  *   } | ||
|  |  * } | ||
|  |  * ```
 | ||
|  |  * | ||
|  |  * ```javascript
 | ||
|  |  * // accessing it in test.
 | ||
|  |  * cy.abGetProperty('isAdmin', 'input[type="checkbox"]') | ||
|  |  * ```
 | ||
|  |  * | ||
|  |  * `abGetProperty` returns the wrapper Section for a given property. You can pass inner element | ||
|  |  * which allows you to select `input`, `label`, `options`, etc. inside it. | ||
|  |  * | ||
|  |  * @memberof module:cy | ||
|  |  * @param {string} path           path of the property | ||
|  |  * @param {string} [selector=null] | ||
|  |  * @example | ||
|  |  * it('shows disabled checkBox', () => { | ||
|  |  *   cy.abGetProperty('isAdmin', 'input[type="checkbox"]') | ||
|  |  *     .should('be.disabled') | ||
|  |  *     .should('not.be.checked') | ||
|  |  * | ||
|  |  *   cy.abGetProperty('isAdmin', 'label') | ||
|  |  *     .click() | ||
|  |  *     .should('not.be.checked') | ||
|  |  * }) | ||
|  |  */ | ||
|  | Cypress.Commands.add('abGetProperty', (path, selector = null) => { | ||
|  |   let propertySelector = `[data-testid$="-${path}"]` | ||
|  |   if (selector) { | ||
|  |     propertySelector = [propertySelector, selector].join(' ') | ||
|  |   } | ||
|  |   return cy.get(propertySelector) | ||
|  | }) |