New Angular UI from 1806
[vid.git] / vid-webpack-master / cypress / support / steps / login.step.ts
1 // add new command to the existing Cypress interface
2 declare namespace Cypress {
3   interface Chainable {
4     login: typeof login,
5     openIframe : typeof openIframe
6   }
7 }
8
9 let currentLoginCookies : any = null;
10
11
12 function login(): void {
13   if(currentLoginCookies){
14     cy.setCookie('JSESSIONID', currentLoginCookies.value, {
15       expiry : currentLoginCookies.expiry,
16       path : currentLoginCookies.path,
17       domain : currentLoginCookies.domain
18     });
19   }else {
20     const constant = {
21       "LOGIN_ID" : "#loginId",
22       "PASSWORD_ID" : "#password",
23       "LOGIN_BTN_ID" : "#loginBtn"
24     };
25
26     cy.visit('/login_external.htm');
27     cy.get(constant.LOGIN_ID).type("us16807000")
28       .get(constant.PASSWORD_ID).type("us16807000")
29       .get(constant.LOGIN_BTN_ID).click();
30
31     cy.getCookie("JSESSIONID").then((res) => {
32       currentLoginCookies = res;
33     });
34   }
35
36 }
37
38 function openIframe(iframeUrl : string): void {
39   cy.visit(iframeUrl);
40 }
41
42 Cypress.Commands.add('login', login);
43 Cypress.Commands.add('openIframe', openIframe);