Skip to content

Commit b6dfc27

Browse files
authored
Automate discovery of CF apps (#1726)
* Automate discover of CF apps Signed-off-by: Nandini Chandra <[email protected]> * Automate discovery of CF apps Signed-off-by: Nandini Chandra <[email protected]> * Automate discovery of CF apps Signed-off-by: Nandini Chandra <[email protected]> * Address CodeRabbit comments Signed-off-by: Nandini Chandra <[email protected]> * Address review comments Signed-off-by: Nandini Chandra <[email protected]> * Fix tier Signed-off-by: Nandini Chandra <[email protected]> --------- Signed-off-by: Nandini Chandra <[email protected]>
1 parent 59a7a0e commit b6dfc27

File tree

3 files changed

+116
-1
lines changed

3 files changed

+116
-1
lines changed

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

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,14 @@ import {
1919
clickByText,
2020
clickItemInKebabMenu,
2121
inputText,
22+
next,
2223
performRowActionByIcon,
2324
selectFormItems,
2425
selectItemsPerPage,
2526
selectUserPerspective,
2627
submitForm,
2728
} from "../../../../utils/utils";
28-
import { administration, SEC } from "../../../types/constants";
29+
import { administration, SEC, trTag } from "../../../types/constants";
2930
import * as commonView from "../../../views/common.view";
3031
import { navMenu } from "../../../views/menu.view";
3132
import * as sourcePlatform from "../../../views/source-platform.view";
@@ -143,4 +144,31 @@ export class SourcePlatform {
143144
submitForm();
144145
}
145146
}
147+
148+
discover(appName: string, space: string, cancel = false): void {
149+
SourcePlatform.open();
150+
clickItemInKebabMenu(this.name, "Discover applications");
151+
if (cancel) {
152+
cancelForm();
153+
return;
154+
}
155+
156+
cy.contains("button", "Add a name").click();
157+
inputText(`input[name="names.0.value"]`, appName);
158+
159+
cy.contains("button", "Add a space").click();
160+
inputText(`input[name="spaces.0.value"]`, space);
161+
next();
162+
163+
cy.contains("button", "Discover applications").click();
164+
cy.contains("button", "Close").click();
165+
166+
// Page reload is required here
167+
SourcePlatform.open();
168+
cy.contains(this.name)
169+
.closest(trTag)
170+
.within(() => {
171+
cy.get(commonView.successIcon, { timeout: 60000 });
172+
});
173+
}
146174
}
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
/*
2+
Copyright © 2021 the Konveyor Contributors (https://konveyor.io/)
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
/// <reference types="cypress" />
17+
18+
import * as data from "../../../../utils/data_utils";
19+
import { deleteApplicationTableRows, exists, login, sidedrawerTab } from "../../../../utils/utils";
20+
import { CredentialsSourceControlUsername } from "../../../models/administration/credentials/credentialsSourceControlUsername";
21+
import { SourcePlatform } from "../../../models/administration/source-platform/source-platform";
22+
import { CredentialType, UserCredentials } from "../../../types/constants";
23+
24+
let cfCreds: CredentialsSourceControlUsername;
25+
let cfInstance: SourcePlatform;
26+
27+
describe(["@tier1"], "Cloud Foundry discovery", () => {
28+
before("Verify Cloud Foundry env variables are present", function () {
29+
if (
30+
!Cypress.env("cloudfoundry_user") ||
31+
!Cypress.env("cloudfoundry_password") ||
32+
!Cypress.env("cloudfoundry_url")
33+
) {
34+
throw new Error(`One or more required Cloud Foundry env variables are missing in cypress.config.ts :
35+
\ncloudfoundry_user\ncloudfoundry_password\ncloudfoundry_url`);
36+
}
37+
login();
38+
cy.visit("/");
39+
deleteApplicationTableRows();
40+
cfCreds = new CredentialsSourceControlUsername(
41+
data.getRandomCredentialsData(
42+
CredentialType.sourceControl,
43+
UserCredentials.usernamePassword,
44+
false,
45+
null,
46+
null,
47+
true
48+
)
49+
);
50+
cfCreds.name = `CF-CREDS-${data.getRandomNumber(1, 500)}`;
51+
cfCreds.create();
52+
53+
cfInstance = new SourcePlatform(
54+
`CF-${data.getRandomNumber(1, 500)}`,
55+
"Cloud Foundry",
56+
Cypress.env("cloudfoundry_url"),
57+
cfCreds.name
58+
);
59+
cfInstance.create();
60+
});
61+
62+
it("Discover a single CF application", function () {
63+
const CFApp = "hello-spring-cloud";
64+
cfInstance.discover(CFApp, "space");
65+
66+
// Click 'Applications' link for the CF instance
67+
cy.contains(cfInstance.name)
68+
.closest("tr")
69+
.find('a[href*="applications"]')
70+
.click({ force: true });
71+
exists(CFApp);
72+
73+
// Verify discovery manifest is generated for the CF app
74+
sidedrawerTab(CFApp, "Platform");
75+
cy.contains("Application discovery manifest")
76+
.parents(".drawer-tab-content__section")
77+
.find('[class*="code-editor__code"]')
78+
.should("exist");
79+
});
80+
81+
after("Clear test data", function () {
82+
deleteApplicationTableRows();
83+
cfInstance.delete();
84+
cfCreds.delete();
85+
});
86+
});

cypress/e2e/views/common.view.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ export const filteredBy = "#filtered-by";
2929
export const itemsPerPageMenuOptions = "ul.pf-v5-c-menu__list";
3030
export const expandRow = "button[aria-label=Details]";
3131
export const successAlertMessage = ".pf-m-success";
32+
export const successIcon = "span.pf-v5-c-icon__content.pf-m-success";
3233
export const errorAlertMessage = ".pf-m-error";
3334
export const pageTitle = "section.pf-v5-c-page__main-section.pf-m-light h1";
3435
export const infoAlertMessage = ".pf-m-info";

0 commit comments

Comments
 (0)