Skip to content

Commit bfa0454

Browse files
author
Sanket Pathak
committed
Configure CI and enable create-from-add-options.feature test file
1 parent 42acfa1 commit bfa0454

File tree

12 files changed

+152
-33
lines changed

12 files changed

+152
-33
lines changed

integration-tests/cypress/support/commands/app.ts

+1
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@ Cypress.Commands.add('checkErrors', () => {
153153

154154
Cypress.Commands.add(
155155
'waitUntilEnabled',
156+
// eslint-disable-next-line @typescript-eslint/no-inferrable-types
156157
(selector: string, timeout: number = 20000): any => {
157158
const start = new Date().getTime();
158159

integration-tests/cypress/support/commands/hooks.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,20 @@
11
import { checkErrors } from '../../../../tests/support/index';
2+
import { checkDeveloperPerspective } from '../../../../tests/views/checkDeveloperPerspective';
23
import { verifyAndInstallPipelinesOperator } from '../pages/functions/installOperatorOnCluster';
34

45
before(() => {
56
cy.login();
67
cy.document().its('readyState').should('eq', 'complete');
78
verifyAndInstallPipelinesOperator();
9+
checkDeveloperPerspective();
810
});
911

1012
after(() => {
1113
const namespaces: string[] = Cypress.env('NAMESPACE') || [];
1214
cy.log(`Deleting "${namespaces}" namespace`);
1315
cy.exec(`oc delete namespace ${namespaces}`, {
1416
failOnNonZeroExit: false,
15-
timeout: 180000,
17+
timeout: 200000,
1618
});
1719
});
1820

integration-tests/cypress/support/page-objects/global-po.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ export const globalPO = {
33
addNavigation: '[data-test-id="+Add-header"]',
44
topologyNavigation: '[data-test-id="topology-header"]',
55
topologySwitcher: 'button[data-test-id="topology-switcher-view"]',
6-
userMenu: '[data-test="user-dropdown"]',
6+
userMenu: '[data-test="user-dropdown-toggle"]',
77
save: '[data-test="save-changes"]',
88
errorAlert: '[aria-label="Danger Alert"]',
99
successAlert: '[aria-label="Success Alert"]',

integration-tests/cypress/support/page-objects/operators-po.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export const operatorsPO = {
2828
},
2929
installOperators: {
3030
title: 'h1.co-m-pane__heading',
31-
noOperatorsFound: '[data-test="msg-box-title"]',
31+
noOperatorsFound: '[data-test="console-empty-state"]',
3232
noOperatorsDetails: '[data-test="msg-box-detail"]',
3333
search: 'input[data-test-id="item-filter"]',
3434
noOperatorFoundMessage: 'div.cos-status-box__title',

integration-tests/cypress/support/pages/index.ts

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
export * from '../constants/index';
2+
// export * from './app';
13
export * from './pipelines/pipelineBuilder-page';
24
export * from './pipelines/pipelineDetails-page';
35
export * from './pipelines/pipelineRun-details-page';

integration-tests/cypress/support/pages/operators-page.ts

+5-2
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,13 @@ export const operatorsPage = {
5252
cy.get('.co-installed-operators').should('be.visible');
5353
cy.get('body').then(($body) => {
5454
if (
55-
$body.find(operatorsPO.installOperators.noOperatorsDetails).length === 0
55+
$body.find(operatorsPO.installOperators.noOperatorsFound).length === 0
5656
) {
57+
cy.get(operatorsPO.installOperators.search).clear();
5758
/* eslint-disable-next-line cypress/unsafe-to-chain-command */
58-
cy.get(operatorsPO.installOperators.search).clear().type(operatorName);
59+
cy.get(operatorsPO.installOperators.search)
60+
.should('be.enabled')
61+
.type(operatorName);
5962
} else {
6063
cy.log(
6164
`${operatorName} operator is not installed in this cluster, so lets install it from operator Hub`,

integration-tests/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@
88
"test-cypress-nightly": "yarn run test-headless && yarn run cypress-merge && yarn run cypress-generate",
99
"posttest-cypress-headless": "yarn run cypress-merge && yarn run cypress-generate"
1010
}
11-
}
11+
}

test-prow-e2e.sh

+7-7
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,12 @@ trap copyArtifacts EXIT
2121

2222

2323
# don't log kubeadmin-password
24-
# set +x
25-
# BRIDGE_KUBEADMIN_PASSWORD="$(cat "${KUBEADMIN_PASSWORD_FILE:-${INSTALLER_DIR}/auth/kubeadmin-password}")"
26-
# export BRIDGE_KUBEADMIN_PASSWORD
27-
# set -x
28-
# BRIDGE_BASE_ADDRESS="$(oc get consoles.config.openshift.io cluster -o jsonpath='{.status.consoleURL}')"
29-
# export BRIDGE_BASE_ADDRESS
24+
set +x
25+
BRIDGE_KUBEADMIN_PASSWORD="$(cat "${KUBEADMIN_PASSWORD_FILE:-${INSTALLER_DIR}/auth/kubeadmin-password}")"
26+
export BRIDGE_KUBEADMIN_PASSWORD
27+
set -x
28+
BRIDGE_BASE_ADDRESS="$(oc get consoles.config.openshift.io cluster -o jsonpath='{.status.consoleURL}')"
29+
export BRIDGE_BASE_ADDRESS
3030

3131
if [ ! -d node_modules ]; then
3232
yarn install
@@ -52,7 +52,7 @@ if [ $# -eq 0 ]; then
5252
echo " test-prow-e2e.sh -h false // opens Cypress Test Runner"
5353
echo " test-prow-e2e.sh -h true // runs packages in headless mode"
5454
echo " test-prow-e2e.sh -n true // runs the whole nightly suite"
55-
# yarn run test-cypress-headless
55+
yarn run test-cypress-headless
5656
trap EXIT
5757
exit;
5858
fi

tests/support/admin.ts

+6
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { guidedTour } from '../views/guided-tour';
22
import { nav } from '../views/nav';
33

44
declare global {
5+
// eslint-disable-next-line @typescript-eslint/no-namespace
56
namespace Cypress {
67
interface Chainable {
78
initAdmin(): Chainable<Element>;
@@ -19,14 +20,19 @@ Cypress.Commands.add('initAdmin', () => {
1920
cy.log('ensure perspective switcher is set to Administrator');
2021
nav.sidenav.switcher.changePerspectiveTo('Administrator');
2122
nav.sidenav.switcher.shouldHaveText('Administrator');
23+
guidedTour.close();
2224
});
2325

2426
Cypress.Commands.add('initDeveloper', () => {
2527
cy.log('redirect to home');
2628
cy.visit('/add');
2729
cy.byTestID('loading-indicator').should('not.exist');
30+
cy.document().its('readyState').should('eq', 'complete');
2831
cy.log('ensure perspective switcher is set to Developer');
32+
guidedTour.close();
2933
nav.sidenav.switcher.changePerspectiveTo('Developer');
34+
cy.log('switched perspective to Developer');
3035
nav.sidenav.switcher.shouldHaveText('Developer');
36+
cy.log('Developer perspective confirmed ');
3137
guidedTour.close();
3238
});

tests/support/login.ts

+2-5
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,6 @@ declare global {
1616

1717
const KUBEADMIN_USERNAME = 'kubeadmin';
1818
const KUBEADMIN_IDP = 'kube:admin';
19-
const loginUsername = Cypress.env('BRIDGE_KUBEADMIN_PASSWORD')
20-
? 'user-dropdown'
21-
: 'username';
2219

2320
// This will add 'cy.login(...)'
2421
// ex: cy.login('my-user', 'my-password')
@@ -58,7 +55,7 @@ Cypress.Commands.add(
5855
);
5956
cy.get('button[type=submit]').click();
6057

61-
cy.get(`[data-test="${loginUsername}"]`).should('be.visible');
58+
cy.get('[data-test="user-dropdown-toggle"]').should('be.visible');
6259
});
6360
},
6461
);
@@ -69,7 +66,7 @@ Cypress.Commands.add('logout', () => {
6966
if (win.SERVER_FLAGS?.authDisabled) {
7067
return;
7168
}
72-
cy.get('[data-test="user-dropdown"]').click();
69+
cy.get('[data-test="user-dropdown-toggle"]').click();
7370
cy.get('[data-test="log-out"]').should('be.visible');
7471
cy.get('[data-test="log-out"]').click({ force: true });
7572
});
+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
import { guidedTour } from './guided-tour';
2+
3+
export const checkDeveloperPerspective = () => {
4+
cy.get('body').then(($body) => {
5+
cy.byLegacyTestID('perspective-switcher-toggle').then(($switcher) => {
6+
// switcher is present
7+
if ($switcher.attr('aria-hidden') !== 'true') {
8+
cy.byLegacyTestID('perspective-switcher-toggle').click();
9+
10+
// eslint-disable-next-line prettier/prettier
11+
if (
12+
$body.find('[data-test-id="perspective-switcher-menu-option"]')
13+
.length !== 0
14+
) {
15+
cy.log('perspective switcher menu enabled');
16+
cy.byLegacyTestID('perspective-switcher-menu-option').contains(
17+
'Developer',
18+
);
19+
cy.byLegacyTestID('perspective-switcher-toggle').click();
20+
return;
21+
}
22+
}
23+
24+
cy.exec(
25+
`oc patch console.operator.openshift.io/cluster --type='merge' -p '{"spec":{"customization":{"perspectives":[{"id":"dev","visibility":{"state":"Enabled"}}]}}}'`,
26+
{ failOnNonZeroExit: true },
27+
).then((result) => {
28+
cy.log(result.stderr);
29+
});
30+
cy.reload(true);
31+
cy.document().its('readyState').should('eq', 'complete');
32+
cy.exec(` oc rollout status -w deploy/console -n openshift-console`, {
33+
failOnNonZeroExit: true,
34+
}).then((result) => {
35+
cy.log(result.stderr);
36+
});
37+
cy.log('perspective switcher menu refreshed');
38+
});
39+
40+
guidedTour.close();
41+
});
42+
};

tests/views/nav.ts

+81-15
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,92 @@
1+
import { switchPerspective } from '../../integration-tests/cypress/support/constants';
2+
import { app } from '../../integration-tests/cypress/support/pages/app';
3+
import { checkDeveloperPerspective } from './checkDeveloperPerspective';
4+
15
export const nav = {
26
sidenav: {
37
switcher: {
4-
shouldHaveText: (text: string) =>
5-
/* eslint-disable-next-line cypress/unsafe-to-chain-command */
6-
cy
7-
.byLegacyTestID('perspective-switcher-toggle')
8-
.scrollIntoView()
9-
.contains(text),
10-
changePerspectiveTo: (newPerspective: string) =>
11-
/* eslint-disable-next-line cypress/unsafe-to-chain-command */
12-
cy
13-
.byLegacyTestID('perspective-switcher-toggle')
14-
.click()
15-
.byLegacyTestID('perspective-switcher-menu-option')
16-
.contains(newPerspective)
17-
.click(),
8+
shouldHaveText: (text: string) => {
9+
cy.byLegacyTestID('perspective-switcher-toggle').then(($body) => {
10+
if (text === switchPerspective.Administrator) {
11+
// if the switcher is hidden it means we are in the admin perspective
12+
if ($body.attr('aria-hidden') === 'true') {
13+
cy.log('Admin is the only perspective available');
14+
cy.byLegacyTestID('perspective-switcher-toggle').should(
15+
'not.be.visible',
16+
);
17+
return;
18+
}
19+
}
20+
cy.byLegacyTestID('perspective-switcher-toggle')
21+
.scrollIntoView()
22+
.contains(text);
23+
});
24+
},
25+
changePerspectiveTo: (newPerspective: string) => {
26+
app.waitForDocumentLoad();
27+
switch (newPerspective) {
28+
case 'Administrator':
29+
case 'administrator':
30+
case 'Admin':
31+
case 'admin':
32+
cy.byLegacyTestID('perspective-switcher-toggle').then(($body) => {
33+
if ($body.attr('aria-hidden') === 'true') {
34+
cy.log('Admin is the only perspective available');
35+
cy.byLegacyTestID('perspective-switcher-toggle').should(
36+
'not.be.visible',
37+
);
38+
return;
39+
}
40+
41+
if ($body.text().includes('Administrator')) {
42+
cy.log('Already on admin perspective');
43+
cy.byLegacyTestID('perspective-switcher-toggle')
44+
.scrollIntoView()
45+
.contains(newPerspective);
46+
} else {
47+
cy.byLegacyTestID('perspective-switcher-toggle')
48+
.click()
49+
.byLegacyTestID('perspective-switcher-menu-option')
50+
.contains(newPerspective)
51+
.click({ force: true });
52+
}
53+
});
54+
break;
55+
case 'Developer':
56+
case 'developer':
57+
case 'Dev':
58+
case 'dev':
59+
cy.byLegacyTestID('perspective-switcher-toggle')
60+
.should('be.visible')
61+
.then(($body) => {
62+
if ($body.text().includes('Developer')) {
63+
cy.log('Already on dev perspective');
64+
cy.byLegacyTestID('perspective-switcher-toggle')
65+
.scrollIntoView()
66+
.contains(newPerspective);
67+
} else {
68+
checkDeveloperPerspective();
69+
cy.byLegacyTestID('perspective-switcher-toggle')
70+
.click()
71+
.byLegacyTestID('perspective-switcher-menu-option')
72+
.contains(newPerspective)
73+
.click({ force: true });
74+
}
75+
});
76+
break;
77+
default:
78+
cy.byLegacyTestID('perspective-switcher-toggle')
79+
.click()
80+
.byLegacyTestID('perspective-switcher-menu-option')
81+
.contains(newPerspective)
82+
.click({ force: true });
83+
}
84+
},
1885
},
1986
clusters: {
2087
shouldHaveText: (text: string) =>
2188
cy.byLegacyTestID('cluster-dropdown-toggle').contains(text),
2289
changeClusterTo: (newCluster: string) =>
23-
/* eslint-disable-next-line cypress/unsafe-to-chain-command */
2490
cy
2591
.byLegacyTestID('cluster-dropdown-toggle')
2692
.click()

0 commit comments

Comments
 (0)