Skip to content

Commit f9b4199

Browse files
authored
[RFR] Add SourcePlatform.edit() method (#1709)
* Add SourcePlatform.edit() method Signed-off-by: Nandini Chandra <[email protected]> * Add SourcePlatform.edit() method Signed-off-by: Nandini Chandra <[email protected]> * Add SourcePlatform.edit() method Signed-off-by: Nandini Chandra <[email protected]> * Address additional review comments Signed-off-by: Nandini Chandra <[email protected]> * Address additional review comments Signed-off-by: Nandini Chandra <[email protected]> * Address review comments Signed-off-by: Nandini Chandra <[email protected]> --------- Signed-off-by: Nandini Chandra <[email protected]>
1 parent 9136486 commit f9b4199

File tree

2 files changed

+80
-19
lines changed

2 files changed

+80
-19
lines changed

cypress/e2e/models/administration/source-platform/source-platform.ts

Lines changed: 40 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import {
1919
clickByText,
2020
clickItemInKebabMenu,
2121
inputText,
22+
performRowActionByIcon,
2223
selectFormItems,
2324
selectItemsPerPage,
2425
selectUserPerspective,
@@ -82,7 +83,7 @@ export class SourcePlatform {
8283

8384
create(cancel = false): void {
8485
SourcePlatform.open();
85-
cy.contains("button", "Create new platform", { timeout: 20000 })
86+
cy.contains("button", "Create new platform", { timeout: 8000 })
8687
.should("be.visible")
8788
.and("not.be.disabled")
8889
.click();
@@ -97,12 +98,49 @@ export class SourcePlatform {
9798
}
9899
}
99100

100-
// TODO: Add update method and corresponding test
101101
delete(cancel = false): void {
102102
SourcePlatform.open();
103103
clickItemInKebabMenu(this.name, "Delete");
104104
if (cancel) {
105105
cancelForm();
106106
} else click(commonView.confirmButton);
107107
}
108+
109+
edit(
110+
updatedValues: Partial<{
111+
name: string;
112+
url: string;
113+
credentials: string;
114+
}>,
115+
cancel = false
116+
): void {
117+
SourcePlatform.open();
118+
performRowActionByIcon(this.name, commonView.pencilAction);
119+
120+
if (cancel) {
121+
cancelForm();
122+
return;
123+
}
124+
125+
const { name, url, credentials } = updatedValues;
126+
127+
if (name && name !== this.name) {
128+
this.fillName(name);
129+
this.name = name;
130+
}
131+
132+
if (url && url !== this.url) {
133+
this.fillUrl(url);
134+
this.url = url;
135+
}
136+
137+
if (credentials && credentials !== this.credentials) {
138+
this.selectCredentials(credentials);
139+
this.credentials = credentials;
140+
}
141+
142+
if (Object.keys(updatedValues).length > 0) {
143+
submitForm();
144+
}
145+
}
108146
}

cypress/e2e/tests/administration/source-platform/crud.test.ts

Lines changed: 40 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,14 @@ limitations under the License.
1616
/// <reference types="cypress" />
1717

1818
import * as data from "../../../../utils/data_utils";
19-
import { checkSuccessAlert, exists, login, notExists } from "../../../../utils/utils";
19+
import { checkSuccessAlert, deleteByList, exists, login, notExists } from "../../../../utils/utils";
2020
import { CredentialsSourceControlUsername } from "../../../models/administration/credentials/credentialsSourceControlUsername";
2121
import { SourcePlatform } from "../../../models/administration/source-platform/source-platform";
2222
import { CredentialType, UserCredentials } from "../../../types/constants";
2323
import { successAlertMessage } from "../../../views/common.view";
24+
import * as selectors from "../../../views/source-platform.view";
2425

25-
let cloudFoundryCreds: CredentialsSourceControlUsername;
26+
let cloudFoundryCreds: Array<CredentialsSourceControlUsername> = [];
2627

2728
describe(["@tier2"], "CRUD operations on Cloud Foundry Source platform", () => {
2829
before("Login", function () {
@@ -36,25 +37,30 @@ describe(["@tier2"], "CRUD operations on Cloud Foundry Source platform", () => {
3637
}
3738
login();
3839
cy.visit("/");
39-
cloudFoundryCreds = new CredentialsSourceControlUsername(
40-
data.getRandomCredentialsData(
41-
CredentialType.sourceControl,
42-
UserCredentials.usernamePassword,
43-
false,
44-
null,
45-
null,
46-
true
47-
)
48-
);
49-
cloudFoundryCreds.create();
40+
for (let i = 0; i < 2; i++) {
41+
const creds = new CredentialsSourceControlUsername(
42+
data.getRandomCredentialsData(
43+
CredentialType.sourceControl,
44+
UserCredentials.usernamePassword,
45+
false,
46+
null,
47+
null,
48+
true
49+
)
50+
);
51+
creds.name = `CF-CREDS-${data.getRandomNumber(1, 500)}`;
52+
creds.create();
53+
cloudFoundryCreds.push(creds);
54+
}
5055
});
5156

52-
it("Perform CRUD Tests on Cloud Foundry Source platform", function () {
57+
it.skip("Perform CRUD Tests on Cloud Foundry Source platform", function () {
58+
// TODO : Unskip tests once Infra ticket MTA-6241 is resolved
5359
const platform = new SourcePlatform(
54-
"CF-" + data.getRandomNumber(1, 200),
60+
`CF-${data.getRandomNumber(1, 500)}`,
5561
"Cloud Foundry",
5662
Cypress.env("cloudfoundry_url"),
57-
cloudFoundryCreds.name
63+
cloudFoundryCreds[0].name
5864
);
5965

6066
platform.create();
@@ -65,11 +71,28 @@ describe(["@tier2"], "CRUD operations on Cloud Foundry Source platform", () => {
6571
);
6672
exists(platform.name);
6773

74+
const newName = `CF-updatedName-${data.getRandomNumber(1, 500)}`;
75+
platform.edit({ name: newName });
76+
exists(newName);
77+
78+
const newURL = "https://api.bosh-updated-lite.com";
79+
platform.edit({ url: newURL });
80+
cy.get(selectors.url).should("have.value", newURL);
81+
82+
const newCreds = cloudFoundryCreds[1].name;
83+
platform.edit({ credentials: newCreds });
84+
cy.get(selectors.credentials).should("have.value", newCreds);
85+
6886
platform.delete();
87+
checkSuccessAlert(
88+
successAlertMessage,
89+
`Success alert:Platform ${platform.name} was successfully deleted.`,
90+
true
91+
);
6992
notExists(platform.name);
7093
});
7194

7295
after("Clear test data", function () {
73-
cloudFoundryCreds.delete();
96+
deleteByList(cloudFoundryCreds);
7497
});
7598
});

0 commit comments

Comments
 (0)