Fix for Penetration test _ Session and cookie management
[vid.git] / vid-webpack-master / cypress / support / steps / genericForm / genericFormAction.steps.ts
1 declare namespace Cypress {
2   interface Chainable {
3     genericFormSubmitForm: typeof genericFormSubmitForm
4     selectMultiselectValue: typeof selectMultiselectValue
5     selectPlatformValue: typeof selectPlatformValue
6     selectLobValue: typeof selectLobValue
7     checkMultiSelectValue: typeof checkMultiSelectValue
8     checkPlatformValue: typeof checkPlatformValue
9     checkLobValue: typeof checkLobValue
10
11   }
12 }
13
14
15 function selectMultiselectValue(dataTestsId: string , selectOptionId: string) {
16   cy.getElementByDataTestsId(dataTestsId).find('.c-btn').eq(0).click({force: true})
17   cy.getElementByDataTestsId(selectOptionId).click();
18   cy.getElementByDataTestsId(dataTestsId).find('.c-btn').eq(0).click({force: true})
19 }
20
21 function selectPlatformValue(selectOptionId: string) {
22   selectMultiselectValue("multi-selectPlatform", "multi-selectPlatform-" + selectOptionId)
23 }
24
25 function selectLobValue(selectOptionId: string) {
26   selectMultiselectValue("multi-lineOfBusiness", "multi-lineOfBusiness-" + selectOptionId)
27
28 }
29
30 function checkPlatformValue(value: string){
31   return checkMultiSelectValue("multi-selectPlatform", value)
32 }
33
34 function checkLobValue(value: string){
35   return checkMultiSelectValue("multi-lineOfBusiness", value)
36 }
37
38 function checkMultiSelectValue(dataTestsId: string, value: string) {
39   return cy.getElementByDataTestsId(dataTestsId).should("contain", value)
40 }
41
42 function genericFormSubmitForm(): Chainable<any> {
43   return cy.getElementByDataTestsId('form-set').click({force: true});
44 }
45
46
47 Cypress.Commands.add('genericFormSubmitForm', genericFormSubmitForm);
48 Cypress.Commands.add('selectMultiselectValue', selectMultiselectValue);
49 Cypress.Commands.add('selectPlatformValue', selectPlatformValue);
50 Cypress.Commands.add('selectLobValue', selectLobValue);
51 Cypress.Commands.add('checkMultiSelectValue', checkMultiSelectValue);
52 Cypress.Commands.add('checkPlatformValue', checkPlatformValue);
53 Cypress.Commands.add('checkLobValue', checkLobValue);
54