New Angular UI from 1806
[vid.git] / vid-webpack-master / cypress / support / elements / element.actions.ts
1 import Chainable = Cypress.Chainable;
2
3 declare namespace Cypress {
4   interface Chainable {
5     isElementContainsAttr : typeof isElementContainsAttr;
6     isElementDisabled : typeof isElementDisabled;
7     isElementEnabled : typeof isElementEnabled;
8     hasClass : typeof hasClass;
9     getElementByDataTestsId : typeof getElementByDataTestsId;
10   }
11 }
12
13 /*************************************************************************
14  isElementContainsAttr : check if element with id contains some attribute
15  *************************************************************************/
16 function isElementContainsAttr(id : string, attr: string) : void {
17   cy.get("[data-tests-id='" + id +"']")
18     .should('have.attr', attr);
19 }
20
21 /*********************************************************
22  isElementDisabled : check if element with id is disabled
23  *********************************************************/
24 function isElementDisabled(id : string) : void {
25   cy.get( "[data-tests-id='" + id +"']").should('be:disabled');
26 }
27
28 function isElementEnabled(id : string) : void {
29   cy.get( "button[data-tests-id='" + id +"']").should('be:enabled');
30 }
31
32 /****************************************************************
33  hasClass : check if element with id contains some class name
34  ****************************************************************/
35 function hasClass(id : string, className : string) : void {
36   cy.get( "[data-tests-id='" + id +"']")
37     .should('have.class', className);
38 }
39
40 function getElementByDataTestsId(dataTestsId : string) : Chainable<JQuery<HTMLElement>> {
41   return cy.get( "[data-tests-id='" + dataTestsId +"']");
42 }
43
44
45 Cypress.Commands.add('isElementContainsAttr', isElementContainsAttr);
46 Cypress.Commands.add('isElementDisabled', isElementDisabled);
47 Cypress.Commands.add('isElementEnabled', isElementEnabled);
48 Cypress.Commands.add('hasClass', hasClass);
49 Cypress.Commands.add('getElementByDataTestsId', getElementByDataTestsId);