summaryrefslogtreecommitdiffstats
path: root/cypress-docker/test/src/cypress/support/homeCommands.js
blob: 9e7f54e2c71f0faf008aaa322264de188b4d4c78 (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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
// functionality
function sdcIsOwnerFalse() {
  cy.visit(
    "home?userId=ym903w&userRole=DESIGNER&displayType=context&contextType=SERVICES&uu" +
      "id=06c7d927-4e2f-47e1-a29d-b6ed229ebc0a&lifecycleState=NOT_CERTIFIED_CHECKOUT&is" +
      "Owner=false&version=0.1"
  );
}

function sdcUserNotCheckout() {
  cy.visit(
    "home?userId=ym903w&userRole=DESIGNER&displayType=context&contextType=SERVICES&uu" +
      "id=06c7d927-4e2f-47e1-a29d-b6ed229ebc0a&lifecycleState=READY_FOR_CERTIFICATION&i" +
      "sOwner=true&version=0.1"
  );
}

function homePage() {
  cy.visit(
    "home?userId=ym903w&userRole=DESIGNER&displayType=context&contextType=SERVICES&uu" +
      "id=06c7d927-4e2f-47e1-a29d-b6ed229ebc0a&lifecycleState=NOT_CERTIFIED_CHECKOUT&is" +
      "Owner=true&version=0.1"
  );
}

function homePageCertified() {
  cy.visit(
    "home?userId=ym903w&userRole=DESIGNER&displayType=context&contextType=SERVICES&uu" +
      "id=06c7d927-4e2f-47e1-a29d-b6ed229ebc0a&lifecycleState=CERTIFIED_CHECKOUT&isOwne" +
      "r=true&version=0.1"
  );
}

function deleteMonitoringComponent() {
  cy
    .server()
    .route({
      method: "DELETE",
      url:
        Cypress.env("backendUrl") + "/SERVICES/**/**/**/deleteVfcmtReference",
      response: "{}"
    })
    .as("deleteMonitoringComponent");
}

function saveMonitoringComponent() {
  cy
    .server()
    .route({
      method: "POST",
      url: Cypress.env("backendUrl") + "/SERVICES/**/**/saveComposition/**",
      response: "{}"
    })
    .as("saveMonitoringComponent");
}

function submitMonitoringComponent() {
  cy
    .server()
    .route({
      method: "POST",
      url: Cypress.env("backendUrl") + "/SERVICES/createBluePrint/**/**/**/",
      response: "{}"
    })
    .as("submitMonitoringComponent");
}

function deleteMonitoringComponentWithBlueprint() {
  cy
    .server()
    .route({
      method: "DELETE",
      url:
        Cypress.env("backendUrl") + "/SERVICES/**/**/**/deleteVfcmtReference",
      response: "{}"
    })
    .as("deleteMonitoringComponentWithBlueprint");
}

function getMCList() {
  cy
    .server()
    .route({
      method: "GET",
      url: Cypress.env("backendUrl") + "/SERVICES/**/**/monitoringComponents",
      response: "fixture:McTable"
    })
    .as("mcList");
  // monitoringComponentsMock
}

function getMC() {
  cy
    .server()
    .route({
      method: "GET",
      url: Cypress.env("backendUrl") + "/getMC/**",
      response: "fixture:getMCMock"
    })
    .as("getMC");
}

function getMCListEmpty() {
  cy
    .server()
    .route({
      method: "GET",
      url: Cypress.env("backendUrl") + "/SERVICES/**/**/monitoringComponents",
      response: "{}"
    })
    .as("mcListEmpty");
}

function getTemplateApiError() {
  cy.server().route({
    method: "GET",
    url:
      Cypress.env("backendUrl") +
      "/service/06c7d927-4e2f-47e1-a29d-b6ed229ebc0a",
    status: 500,
    response: {
      requestError: {
        policyException: {
          messageId: "POL5000",
          text: "Error: Internal Server Error. Please try again later.",
          variables: [],
          formattedErrorMessage:
            "Error: Internal Server Error. Please try again later."
        }
      },
      notes: 'Error: Requested "123" resource was not found.'
    }
  });
  cy.homePage();
  cy.get('button[data-tests-id="btn-create-mc"]').click();
}

// Add cypress commands
Cypress.Commands.add("homePage", homePage);
Cypress.Commands.add("getTemplateApiError", getTemplateApiError);
Cypress.Commands.add("homePageCertified", homePageCertified);
Cypress.Commands.add("sdcIsOwnerFalse", sdcIsOwnerFalse);
Cypress.Commands.add("sdcUserNotCheckout", sdcUserNotCheckout);
Cypress.Commands.add("getMCList", getMCList);
Cypress.Commands.add("getMCListEmpty", getMCListEmpty);
Cypress.Commands.add("deleteMonitoringComponent", deleteMonitoringComponent);
Cypress.Commands.add(
  "deleteMonitoringComponentWithBlueprint",
  deleteMonitoringComponentWithBlueprint
);
Cypress.Commands.add("submitMonitoringComponent", submitMonitoringComponent);
Cypress.Commands.add("saveMonitoringComponent", saveMonitoringComponent);
Cypress.Commands.add("getMC", getMC);