-
Notifications
You must be signed in to change notification settings - Fork 596
/
topology-edit-deployment.ts
118 lines (116 loc) · 5.31 KB
/
topology-edit-deployment.ts
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
import { authenticationTypes } from '@console/dev-console/integration-tests/support/constants';
import { topologyPO } from '@console/topology/integration-tests/support/page-objects/topology-po';
export const editDeployment = {
verifyModalTitle: () => {
cy.get(topologyPO.createSecret.formInputs.secretFormTitle).should('be.visible');
},
addSecretName: (secretName: string) => {
cy.get(topologyPO.createSecret.formInputs.secretName).clear().type(secretName);
},
selectAuthenticationType: (authenticationType: authenticationTypes | string) => {
cy.get(topologyPO.createSecret.formInputs.authenticationType).click();
switch (authenticationType) {
case 'Image registry credentials':
case authenticationTypes.ImageRegistryCredentials: {
cy.byTestActionID(authenticationType).should('be.visible').click();
break;
}
case 'Upload configuration file':
case authenticationTypes.UploadConfigurationFile: {
cy.byTestActionID(authenticationType).should('be.visible').click();
break;
}
default: {
throw new Error(`${authenticationType} is not available in action menu`);
}
}
},
addServerAddress: (serverUrl: string) => {
cy.get(topologyPO.createSecret.formInputs.registryServerAddress).clear().type(serverUrl);
},
enterUsername: (username: string) => {
cy.get(topologyPO.createSecret.formInputs.userName).clear().type(username);
},
enterPassword: (password: string) => {
cy.get(topologyPO.createSecret.formInputs.password).clear().type(password);
},
enterEmail: (email: string) => {
cy.get(topologyPO.createSecret.formInputs.email).clear().type(email);
},
saveSecret: () => {
cy.get(topologyPO.createSecret.formInputs.saveSecret).click();
},
selectDeploymentStrategyType: (strategyType: string) => {
cy.get(topologyPO.deploymentStrategy.strategyTypeDropDown).click();
if (strategyType === 'Rolling Update') {
cy.get(topologyPO.deploymentStrategy.rollingUpdate).click();
} else if (strategyType === 'Recreate') {
cy.get(topologyPO.deploymentStrategy.recreateStrategy).click();
} else if (strategyType === 'Custom') {
cy.get(topologyPO.deploymentStrategy.customUpdate).click();
}
},
selectProjectName: (projectName: string) => {
cy.get(topologyPO.deploymentStrategy.projectDropDown).click();
cy.get(`[id="${projectName}-link"]`).click();
},
selectImageStream: (imageStream: string) => {
cy.get(topologyPO.deploymentStrategy.imageStream).click();
cy.get(`[id="${imageStream}-link"]`).click();
},
selectImageStreamTag: (tag: string) => {
cy.get(topologyPO.deploymentStrategy.tag).click();
cy.get(`[id="${tag}-link"]`).click();
},
addPreCycleHook: (workloadName: string, failurePolicy: string) => {
cy.get(topologyPO.deploymentStrategy.preLifecycleHook.preExecNewPod).click();
cy.get(topologyPO.deploymentStrategy.preLifecycleHook.preExecNewPodContainerDD).click();
cy.get(`[id="${workloadName}-link"]`).click();
cy.get(topologyPO.deploymentStrategy.preLifecycleHook.runCommand)
.clear()
.type('echo "PreLifeCycle Hook"');
cy.get(topologyPO.deploymentStrategy.preLifecycleHook.failurePolicy).click();
cy.get(`[id="${failurePolicy}-link"]`).click();
cy.get(topologyPO.deploymentStrategy.tickButton).click();
cy.on('uncaught:exception', (err) => {
expect(err.message).toContain(
'When Cypress detects uncaught errors originating from your application it will automatically fail the current test.',
); // .to.include
return false;
});
},
selectProject: (projectName: string) => {
cy.get(`[id="${projectName}-link"]`).click();
},
selectImage: (imageStream: string) => {
cy.get(`[id="${imageStream}-link"]`).click();
},
selectImageTag: (tag: string) => {
cy.get(`[id="${tag}-link"]`).click();
},
addMidCycleHook: (workloadName: string, failurePolicy: string) => {
cy.get(topologyPO.deploymentStrategy.midLifecycleHook.midTagImagesField).click();
cy.get(topologyPO.deploymentStrategy.midLifecycleHook.midTagImagesFieldContainerDD).click();
cy.get(`[id="${workloadName}-link"]`).click();
cy.get(topologyPO.deploymentStrategy.midLifecycleHook.projectDropDown).click();
editDeployment.selectProject('openshift');
cy.get(topologyPO.deploymentStrategy.midLifecycleHook.imageStream).click();
editDeployment.selectImage('golang');
cy.get(topologyPO.deploymentStrategy.midLifecycleHook.imageStreamTag).click();
editDeployment.selectImageTag('latest');
cy.get(topologyPO.deploymentStrategy.midLifecycleHook.failurePolicy).click();
cy.get(`[id="${failurePolicy}-link"]`).click();
cy.get(topologyPO.deploymentStrategy.tickButton).click();
},
addPostCycleHook: (workloadName: string, failurePolicy: string) => {
cy.get(topologyPO.deploymentStrategy.postLifecycleHook.postExecNewPod).click();
cy.get(topologyPO.deploymentStrategy.postLifecycleHook.postExecNewPodContainerNameDD).click();
cy.get(`[id="${workloadName}-link"]`).click();
cy.get(topologyPO.deploymentStrategy.postLifecycleHook.runCommand)
.clear()
.type('echo "PostLifeCycle Hook"');
cy.get(topologyPO.deploymentStrategy.postLifecycleHook.failurePolicy).click();
cy.get(`[id="${failurePolicy}-link"]`).click();
cy.get(topologyPO.deploymentStrategy.tickButton).click();
},
};