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
30 changes: 20 additions & 10 deletions cypress/e2e/NewPolicy.spec.cy.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import { SKIP_WELCOME_BANNER_TEST_ID } from '../support/selectors';

const deletePolicyFromDetailsPage = (policyName: string) => {
cy.contains('button', 'Actions', { matchCase: false }).click();
cy.contains('button', 'Delete').click();
Expand All @@ -13,27 +11,39 @@ const deletePolicyFromDetailsPage = (policyName: string) => {
cy.contains('h1', 'NodeNetworkConfigurationPolicy');
};

describe.skip('Create new policy with form', () => {
describe('Create new policy with form', () => {
beforeEach(() => {
cy.login();
cy.skipOCPGuidedTour();
});

it('with bridge interface', () => {
it('with default node network', () => {
const testPolicyName = 'test-bridge-policy-name';
const testDescription = 'Test description';

cy.visit('/k8s/cluster/nmstate.io~v1~NodeNetworkConfigurationPolicy');
cy.byTestID(SKIP_WELCOME_BANNER_TEST_ID).click();
cy.byTestID('item-create').click();

cy.contains('button', 'From Form').click();

cy.get('input[name="policy-name"]').clear().type(`${testPolicyName}`);
// Network identity step
cy.get('input[name="physical-network-name"]').clear().type(`${testPolicyName}`);
cy.contains('button', 'Next').click();

cy.get('input[name="policy-description"]').clear().type('test-policy-description');
// Nodes configuration step
cy.get('input[name="policy-name"]').clear().type(`${testPolicyName}`);
cy.get('input[name="policy-description"]').clear().type(`${testDescription}`);
cy.contains('button', 'Next').click();

cy.contains('button', 'Bridging').click();
cy.get(`button#add-bridging-interface-button`).click();
// Uplink connection step - 'Default node network' selected by default
cy.contains('button', 'Next').click();
cy.contains('button', 'Create policy').click();

// Settings step is skipped because 'Default node network' is selected

// Review and Create step
cy.byLegacyTestID('review-physical-network-name').should('have.text', testPolicyName);
cy.byLegacyTestID('review-network-description').should('have.text', testDescription);
cy.contains('button', 'Create network').click();

cy.contains('h1', testPolicyName);

Expand Down
20 changes: 11 additions & 9 deletions cypress/e2e/StatusList.spec.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@ import {
EXPAND_INTERFACES_LIST_TEST_ID,
INTERFACE_DRAWER_TEST_ID,
LLDP_DRAWER_DETAILS_SECTION_TEST_ID,
LLDP_SYSTEM_NAME_FILTER_OPTION_ID,
LLDP_VLAN_NAME_FILTER_OPTION_ID,
SEARCH_FILTER_DROPDOWN_TEST_ID,
TEXT_FILTER_BUTTON_SELECTOR,
} from '../support/selectors';

describe('NodeNetworkState list', () => {
beforeEach(() => {
cy.login();
cy.skipOCPGuidedTour();
});

it('Empty state', () => {
Expand All @@ -24,7 +26,7 @@ describe('NodeNetworkState list', () => {
cy.get('h5').should('contain', 'No NodeNetworkStates found');
});

it('with one VID instace ', () => {
it('with one VID instance ', () => {
cy.intercept('GET', '/api/kubernetes/apis/nmstate.io/v1beta1/nodenetworkstates*', {
fixture: 'NodeNetworkStatusWithVID.json',
}).as('getStatuses');
Expand Down Expand Up @@ -52,7 +54,7 @@ describe('NodeNetworkState list', () => {
});
});

it('with LLDP informations ', () => {
it('with LLDP information', () => {
cy.intercept('GET', '/api/kubernetes/apis/nmstate.io/v1beta1/nodenetworkstates*', {
fixture: 'NodeNetworkStatusWithLLDP.json',
}).as('getStatuses');
Expand Down Expand Up @@ -86,7 +88,7 @@ describe('NodeNetworkState list', () => {
});
});

it('filter by lldp', () => {
it('filter by LLDP', () => {
cy.intercept('GET', '/api/kubernetes/apis/nmstate.io/v1beta1/nodenetworkstates*', {
fixture: 'NodeNetworkStatusWithLLDP.json',
}).as('getStatuses');
Expand All @@ -107,7 +109,7 @@ describe('NodeNetworkState list', () => {
// open filter toolbar
cy.get('button').contains('Filter').click({ force: true });

// filter by lldp enabled
// filter by LLDP enabled
cy.contains('label', 'Enabled').find('input[type="checkbox"]').check();

// close filter toolbar by clicking outside
Expand All @@ -125,7 +127,7 @@ describe('NodeNetworkState list', () => {
});
});

it('search by lldp vlan ID', () => {
it('search by LLDP VLAN ID', () => {
cy.intercept('GET', '/api/kubernetes/apis/nmstate.io/v1beta1/nodenetworkstates*', {
fixture: 'NodeNetworkStatusWithLLDP.json',
}).as('getStatuses');
Expand All @@ -147,7 +149,7 @@ describe('NodeNetworkState list', () => {

cy.byTestID(SEARCH_FILTER_DROPDOWN_TEST_ID).click();

cy.get(TEXT_FILTER_BUTTON_SELECTOR).contains('LLDP VLAN name').click();
cy.get(LLDP_VLAN_NAME_FILTER_OPTION_ID).click();

cy.get('input[data-test-id="item-filter"]').type(VLAN_NAME);

Expand All @@ -163,7 +165,7 @@ describe('NodeNetworkState list', () => {
});
});

it('search by lldp system name', () => {
it('search by LLDP system name', () => {
cy.intercept('GET', '/api/kubernetes/apis/nmstate.io/v1beta1/nodenetworkstates*', {
fixture: 'NodeNetworkStatusWithLLDP.json',
}).as('getStatuses');
Expand All @@ -185,7 +187,7 @@ describe('NodeNetworkState list', () => {

cy.byTestID(SEARCH_FILTER_DROPDOWN_TEST_ID).click();

cy.get(TEXT_FILTER_BUTTON_SELECTOR).contains('LLDP system name').click();
cy.get(LLDP_SYSTEM_NAME_FILTER_OPTION_ID).click();

cy.get('input[data-test-id="item-filter"]').type(SYSTEM_NAME);

Expand Down
64 changes: 28 additions & 36 deletions cypress/support/commands.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
/* eslint-disable @typescript-eslint/no-namespace */
/// <reference types="cypress" />
import { KUBEADMIN_IDP, KUBEADMIN_USERNAME } from './constants';
import { KUBEADMIN_IDP, KUBEADMIN_USERNAME, MINUTE, SKIP_TOUR } from './constants';
import { OCP_GUIDED_TOUR_MODAL, SUBMIT_BUTTON_SELECTOR } from './selectors';
import { ConsoleWindowType } from './types';

import Loggable = Cypress.Loggable;
import Timeoutable = Cypress.Timeoutable;
import Withinable = Cypress.Withinable;
import Shadow = Cypress.Shadow;

declare global {
namespace Cypress {
interface Chainable {
Expand All @@ -19,44 +15,32 @@ declare global {
): Chainable;
byLegacyTestID(selector: string): Chainable;
clickOutside(): Chainable;
skipOCPGuidedTour(): Chainable;
}
}
}

const submitButton = 'button[type=submit]';

Cypress.Commands.add('login', (provider, username, password) => {
// Check if auth is disabled (for a local development environment).

cy.visit(''); // visits baseUrl which is set in plugins.js
cy.window().then((win: ConsoleWindowType) => {
if (win.SERVER_FLAGS?.authDisabled) {
cy.log('skipping login, console is running with auth disabled');

cy.contains('li[data-test="nav"]', 'Networking').click();
cy.contains(
'*[data-test-id="nodenetworkconfigurationpolicy-nav-item"]',
'NodeNetworkConfigurationPolicy',
).should('be.visible');
return;
cy.task('log', ` Logging in as ${username || KUBEADMIN_USERNAME}`);
cy.get('.pf-v6-c-login__main', { timeout: 3 * MINUTE }).should('exist');
const idp = provider || KUBEADMIN_IDP;
cy.get('body').then(($body) => {
if ($body.text().includes(idp)) {
cy.contains(idp).should('be.visible').click();
}

cy.clearCookie('openshift-session-token');

const idp = provider || KUBEADMIN_IDP;

cy.get('main form').should('be.visible');

cy.get('body').then(($body) => {
if ($body.text().includes(idp)) {
cy.contains(idp).should('be.visible').click();
}
});

cy.get('#inputUsername').type(username || KUBEADMIN_USERNAME);
cy.get('#inputPassword').type(password || Cypress.env('KUBEADMIN_PASSWORD'));
cy.get(submitButton).click();
});
cy.get('#inputUsername').type(username || KUBEADMIN_USERNAME);
cy.get('#inputPassword').type(password || Cypress.env('BRIDGE_KUBEADMIN_PASSWORD'));
cy.get(SUBMIT_BUTTON_SELECTOR).click();
cy.byTestID(Cypress.env('BRIDGE_KUBEADMIN_PASSWORD') ? 'user-dropdown-toggle' : 'username', {
timeout: MINUTE,
}).should('be.visible');
// wait for virtualization page appears, only for kubeadmin user
if (idp === KUBEADMIN_IDP) {
cy.contains('You are logged in as a temporary administrative user.').should('be.visible');
}
cy.task('log', ' Login is successful');
});

Cypress.Commands.add('logout', () => {
Expand All @@ -83,3 +67,11 @@ Cypress.Commands.add('byLegacyTestID', (selector) => cy.get(`[data-test-id="${se
Cypress.Commands.add('clickOutside', () => {
return cy.get('body').click(0, 0); //0,0 here are the x and y coordinates
});

Cypress.Commands.add('skipOCPGuidedTour', () =>
cy.get('body').then(($body) => {
if ($body.find(OCP_GUIDED_TOUR_MODAL).length) {
cy.contains('button', SKIP_TOUR).click();
}
}),
);
4 changes: 4 additions & 0 deletions cypress/support/constants.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
export const KUBEADMIN_USERNAME = 'kubeadmin';
export const KUBEADMIN_IDP = 'kube:admin';

export const SKIP_TOUR = 'Skip tour';

export const MINUTE = 60000;
9 changes: 6 additions & 3 deletions cypress/support/selectors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@ export const INTERFACE_DRAWER_TEST_ID = 'interface-drawer';
export const LLDP_DRAWER_DETAILS_SECTION_TEST_ID = 'lldp-section';

export const SEARCH_FILTER_DROPDOWN_TEST_ID = 'console-select-menu-toggle';
export const TEXT_FILTER_BUTTON_SELECTOR =
'.pf-v6-c-menu li.pf-v6-c-menu__list-item button.pf-v6-c-menu__item';

export const SKIP_WELCOME_BANNER_TEST_ID = 'tour-step-footer-secondary';
export const LLDP_VLAN_NAME_FILTER_OPTION_ID = '#lldp-name-link';
export const LLDP_SYSTEM_NAME_FILTER_OPTION_ID = '#lldp-system-name-link';

export const OCP_GUIDED_TOUR_MODAL = '[data-test="guided-tour-modal"]';

export const SUBMIT_BUTTON_SELECTOR = 'button[type=submit]';
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ const ReviewStep: FC<ReviewStepProps> = ({ policy, creationError, setPolicy }) =
<DetailItem
header={t('Physical network name')}
description={getOVNLocalnet(policy) || NO_DATA_DASH}
testId="review-physical-network-name"
/>
<DetailItem
header={t('Node network configuration name')}
Expand All @@ -111,6 +112,7 @@ const ReviewStep: FC<ReviewStepProps> = ({ policy, creationError, setPolicy }) =
<DetailItem
header={t('Network description')}
description={getDescription(policy) || NO_DATA_DASH}
testId="review-network-description"
/>
<DetailItem
header={t('Uplink connection')}
Expand Down