aboutsummaryrefslogtreecommitdiffstats
path: root/vid-webpack-master/cypress/support/steps/genericForm/genericFormAction.steps.ts
blob: b9c051e54185d0c3ff4b211134b95d26c4ef8a15 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
declare namespace Cypress {
  interface Chainable {
    genericFormSubmitForm: typeof genericFormSubmitForm
    selectMultiselectValue: typeof selectMultiselectValue
    selectPlatformValue: typeof selectPlatformValue
    selectLobValue: typeof selectLobValue
    checkMultiSelectValue: typeof checkMultiSelectValue
    checkPlatformValue: typeof checkPlatformValue
    checkLobValue: typeof checkLobValue

  }
}


function selectMultiselectValue(dataTestsId: string , selectOptionId: string) {
  cy.getElementByDataTestsId(dataTestsId).find('.c-btn').eq(0).click({force: true})
  cy.getElementByDataTestsId(selectOptionId).click();
  cy.getElementByDataTestsId(dataTestsId).find('.c-btn').eq(0).click({force: true})
}

function selectPlatformValue(selectOptionId: string) {
  selectMultiselectValue("multi-selectPlatform", "multi-selectPlatform-" + selectOptionId)
}

function selectLobValue(selectOptionId: string) {
  selectMultiselectValue("multi-lineOfBusiness", "multi-lineOfBusiness-" + selectOptionId)

}

function checkPlatformValue(value: string){
  return checkMultiSelectValue("multi-selectPlatform", value)
}

function checkLobValue(value: string){
  return checkMultiSelectValue("multi-lineOfBusiness", value)
}

function checkMultiSelectValue(dataTestsId: string, value: string) {
  return cy.getElementByDataTestsId(dataTestsId).should("contain", value)
}

function genericFormSubmitForm(): Chainable<any> {
  return cy.getElementByDataTestsId('form-set').click({force: true});
}


Cypress.Commands.add('genericFormSubmitForm', genericFormSubmitForm);
Cypress.Commands.add('selectMultiselectValue', selectMultiselectValue);
Cypress.Commands.add('selectPlatformValue', selectPlatformValue);
Cypress.Commands.add('selectLobValue', selectLobValue);
Cypress.Commands.add('checkMultiSelectValue', checkMultiSelectValue);
Cypress.Commands.add('checkPlatformValue', checkPlatformValue);
Cypress.Commands.add('checkLobValue', checkLobValue);