Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make sure no other tests or steps enable/disable the dev perspective, otherwise your variable will be out of sync. Alternatively instead of keeping an internal variable, have a single source of truth--fetch data from the oc cli.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point — the module-level devPerspectiveDisabled flag could get out of sync if other steps also modify perspective visibility.

The simplest fix that addresses your concern: make the After hook unconditionally re-enable the Developer perspective without checking the flag. The oc patch to enable it is idempotent — if the perspective is already enabled, the patch is a no-op ("no change"). This eliminates the state-tracking concern entirely:

After(() => {
  cy.exec(
    `oc patch console.operator.openshift.io/cluster --type='merge' -p '{"spec":{"customization":{"perspectives":[{"id":"dev","visibility":{"state":"Enabled"}}]}}}'`,
    { failOnNonZeroExit: false },
  );
});

Would you prefer this unconditional approach, or the oc CLI check for the current state? I can push the update either way.

Also, the E2E job has failed twice due to build08 Boskos lease proxy 503 errors (infrastructure issue — the Cypress tests never actually ran). Would you mind retesting with /test e2e-gcp-console when the infrastructure recovers?


AI-generated. Review for accuracy.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unconditional is fine

Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
import { Given, When, Then } from 'cypress-cucumber-preprocessor/steps';
import { Given, When, Then, After } from 'cypress-cucumber-preprocessor/steps';
import { detailsPage } from '@console/cypress-integration-tests/views/details-page';
import { modal } from '@console/cypress-integration-tests/views/modal';
import { switchPerspective, devNavigationMenu, adminNavigationMenu } from '../../constants';
import { perspective, projectNameSpace, navigateTo, app } from '../../pages';
import { checkDeveloperPerspective } from '../../pages/functions/checkDeveloperPerspective';

// Tracks whether the Developer perspective was disabled during a scenario so that
// the After hook can re-enable it on cleanup, preventing cascade failures in
// subsequent test files that depend on the Developer perspective being available.
let devPerspectiveDisabled = false;

Given('user has logged in as a basic user', () => {
cy.logout();
const idp = Cypress.expose('BRIDGE_HTPASSWD_IDP') || 'test';
Expand All @@ -21,6 +26,7 @@ Given('user is at developer perspective', () => {
});

Given('user has only admin perspective enabled', () => {
devPerspectiveDisabled = true;
cy.exec(
`oc patch console.operator.openshift.io/cluster --type='merge' -p '{"spec":{"customization":{"perspectives":[{"id":"dev","visibility":{"state":"Disabled"}}]}}}'`,
{ failOnNonZeroExit: true },
Expand Down Expand Up @@ -89,6 +95,34 @@ When('user is at namespace {string}', (projectName: string) => {
projectNameSpace.selectOrCreateProject(projectName);
});

Given('user has logged in as admin user', () => {
cy.login();
perspective.switchTo(switchPerspective.Administrator);
});

When('user refreshes the page', () => {
cy.reload();
});

// Defensive teardown: re-enable the Developer perspective after any scenario
// that disabled it. This prevents cascade failures where a crash in the
// enable-dev-perspective feature leaves the perspective disabled for all
// subsequent tests (e.g. add-flow-ci.feature).
After(() => {
if (devPerspectiveDisabled) {
devPerspectiveDisabled = false;
cy.exec(
`oc patch console.operator.openshift.io/cluster --type='merge' -p '{"spec":{"customization":{"perspectives":[{"id":"dev","visibility":{"state":"Enabled"}}]}}}'`,
{ failOnNonZeroExit: false },
).then((result) => {
cy.log('After hook: re-enabled Developer perspective');
cy.log(result.stdout);
if (result.stderr) {
cy.log(result.stderr);
}
});
cy.exec('oc rollout status -w deploy/console -n openshift-console', {
failOnNonZeroExit: false,
});
}
});
Original file line number Diff line number Diff line change
@@ -1,13 +1,5 @@
import { Given, Then, When } from 'cypress-cucumber-preprocessor/steps';
import { nav } from '@console/cypress-integration-tests/views/nav';
import { switchPerspective } from '../../constants';
import { app, perspective } from '../../pages';

Given('user has logged in as admin user', () => {
cy.login();
perspective.switchTo(switchPerspective.Administrator);
nav.sidenav.switcher.shouldHaveText(switchPerspective.Administrator);
});
import { app } from '../../pages';

Given('user is at Search page in Home section', () => {
cy.get('[data-quickstart-id="qs-nav-home"]')
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
import { Given, When, Then } from 'cypress-cucumber-preprocessor/steps';
import { switchPerspective } from '../../constants';
import { app, perspective } from '../../pages';

Given('user is at admin perspective', () => {
perspective.switchTo(switchPerspective.Administrator);
});

Given('user is at Search page in Home section', () => {
cy.get('[data-quickstart-id="qs-nav-home"]')
.scrollIntoView()
.then(($body) => {
if ($body.attr('aria-expanded') === 'false') {
cy.wrap($body).click();
cy.get('[data-test="nav"][href*="/search"]').click({ force: true });
} else {
cy.get('[data-test="nav"][href*="/search"]').click({ force: true });
}
});
});

When('user searches {string}', (value: string) => {
cy.get('[role="combobox"]').click();
cy.get('[aria-label="Type to filter"]').should('be.visible').type(value);
cy.get('[class="co-resource-item"]').then(($el) => {
if ($el.text().includes('operator.openshift.io')) {
cy.wrap($el).contains('operator.openshift.io').click();
cy.get('button[aria-label="Clear input value"]').should('be.visible').click();
// close the select so it doesn't block the items on the page
cy.get('body').click();
}
});
});

When('user clicks on cluster', () => {
cy.byTestID('cluster').should('be.visible').click({ force: true });
});

When('user clicks the {string} button in the page heading', (item: string) => {
cy.get(`button[data-test-action="${item}"]`).should('be.visible').click();
cy.get('[data-test="page-heading"] h1').should('have.text', 'Cluster configuration');
});

When(
'user selects {string} in the Developer under perspective section of general customisation',
(key: string) => {
cy.get('[data-test="perspectives form-group"]')
.eq(1)
.find('button')
.contains('Disabled')
.click();
cy.log('Perspective enabling menu to be opened');
cy.get('[role="listbox"]').should('be.visible');
cy.get('button[role="option"]').contains(key).click();
cy.get('[data-test="perspectives form-group"]')
.eq(1)
.find('button[class*="menu-toggle"]')
.should('contain.text', key);
},
);

When('user will see Saved alert', () => {
cy.byTestID('success-alert').should('be.visible');
});

Then('user refreshes the page to see developer option', () => {
cy.exec('oc rollout status -w deploy/console -n openshift-console', {
failOnNonZeroExit: true,
}).then((result) => {
cy.log(result.stderr);
});
cy.reload(true);
app.waitForDocumentLoad();
});

Then('user will see developer perspective in the perspective switcher', () => {
cy.byLegacyTestID('perspective-switcher-toggle')
.click({ force: true })
.byLegacyTestID('perspective-switcher-menu-option')
.contains('Developer');
});