Skip to content

Commit b875cfc

Browse files
authored
Merge pull request #2500 from gouyang/settings_general_tab
CNV-57355: add test for cluster general settings
2 parents e5bf195 + 1e74340 commit b875cfc

File tree

15 files changed

+151
-74
lines changed

15 files changed

+151
-74
lines changed

cypress/cypress.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ module.exports = defineConfig({
2525
},
2626
retries: {
2727
openMode: 0,
28-
runMode: 3,
28+
runMode: 0,
2929
},
3030
screenshotOnRunFailure: true,
3131
screenshotsFolder: './gui-test-screenshots/screenshots/',

cypress/support/commands.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
export {};
2+
declare global {
3+
// eslint-disable-next-line @typescript-eslint/no-namespace
4+
namespace Cypress {
5+
interface Chainable {
6+
checkHCOSpec(spec: string, matchString: string, include: boolean): void;
7+
}
8+
}
9+
}
10+
11+
Cypress.Commands.add('checkHCOSpec', (spec: string, matchString: string, include: boolean) => {
12+
cy.exec(
13+
`oc get -n kubevirt-hyperconverged hyperconverged kubevirt-hyperconverged -o jsonpath='{${spec}}'`,
14+
).then((result) => {
15+
if (include) {
16+
expect(result.stdout).contain(matchString);
17+
} else {
18+
expect(result.stdout).not.contain(matchString);
19+
}
20+
});
21+
});

cypress/support/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import './nav.ts';
44
import './project.ts';
55
import './resource.ts';
66
import './selectors.ts';
7+
import './commands.ts';
78

89
declare global {
910
namespace Cypress {

cypress/tests/e2e/a-setup.cy.ts

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -41,18 +41,21 @@ describe('Prepare the cluster for test', () => {
4141
cy.contains('button[role="tab"]', 'User').click();
4242
cy.contains(manageKeysText).click();
4343
cy.contains(authSSHKey, { timeout: 20000 }).should('be.visible');
44-
cy.wait(2000);
45-
// configure new public ssh key
46-
cy.get('.settings-tab__content').then(() => {
47-
cy.contains('Select project').click();
48-
cy.byLegacyTestID(TEST_NS).click({ force: true });
49-
cy.get('button.project-ssh-row__secret-name').click();
50-
cy.get(useExisting).click();
51-
cy.contains('Select secret').click();
52-
cy.byButtonText(TEST_SECRET_NAME).click();
53-
cy.clickSaveBtn();
44+
cy.wait(10000);
45+
cy.get('.settings-tab__content').then(($body) => {
46+
if ($body.text().includes(TEST_SECRET_NAME)) {
47+
cy.task('log', 'secret is configured');
48+
} else {
49+
cy.contains('Select project').click();
50+
cy.byLegacyTestID(TEST_NS).click({ force: true });
51+
cy.get('button.project-ssh-row__secret-name').click();
52+
cy.get(useExisting).click();
53+
cy.contains('Select secret').click();
54+
cy.byButtonText(TEST_SECRET_NAME).click();
55+
cy.clickSaveBtn();
56+
}
57+
cy.contains('button.project-ssh-row__secret-name', TEST_SECRET_NAME).should('exist');
5458
});
55-
cy.contains('button.project-ssh-row__secret-name', TEST_SECRET_NAME).should('exist');
5659
});
5760

5861
it('create example VM', () => {

cypress/tests/e2e/b-overview.cy.ts

Lines changed: 1 addition & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,11 @@
1-
import { TEST_NS } from '../../utils/const/index';
2-
import { authSSHKey } from '../../utils/const/string';
3-
import { tabModal } from '../../views/actions';
4-
import { addNew, manageKeysText, secretName, uploadSecret } from '../../views/selector-catalog';
5-
import { userButtonTxt } from '../../views/selector-instance';
61
import { tab } from '../../views/tab';
72

8-
const testSecret = 'test-secret';
9-
103
describe('Test Virtualization Overview', () => {
114
before(() => {
12-
cy.visit('');
5+
cy.visitOverview();
136
});
147

158
it('overview page is loaded', () => {
16-
cy.visitOverview();
179
cy.contains('VirtualMachine statuses').should('exist');
1810
});
1911

@@ -31,31 +23,4 @@ describe('Test Virtualization Overview', () => {
3123
tab.navigateToSettings();
3224
cy.contains('General settings').should('be.visible');
3325
});
34-
35-
it('test saving SSH key', () => {
36-
cy.byButtonText(userButtonTxt).click();
37-
cy.byButtonText(manageKeysText).click();
38-
cy.byButtonText(manageKeysText)
39-
.parent()
40-
.parent()
41-
.within(() => {
42-
cy.contains(authSSHKey, { timeout: 20000 }).should('be.visible');
43-
});
44-
// configure public ssh key when it's not configured
45-
cy.get('.settings-tab__content').then(($body) => {
46-
if ($body.text().includes('Select project')) {
47-
cy.contains('Select project').click();
48-
cy.byLegacyTestID(TEST_NS).click({ force: true });
49-
}
50-
});
51-
cy.get('button.project-ssh-row__secret-name').click();
52-
cy.get(tabModal).within(() => {
53-
cy.get(addNew).click();
54-
cy.dropFile('./fixtures/rsa.pub', 'rsa.pub', uploadSecret);
55-
cy.wait(1000);
56-
cy.get(secretName).type(testSecret);
57-
cy.clickSaveBtn();
58-
});
59-
cy.byButtonText(testSecret).should('exist');
60-
});
6126
});

cypress/tests/e2e/catalog-filter.cy.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,10 @@ import { cardTitleV6 } from '../../views/selector-overview';
77

88
describe('Test filter in InstanceType', () => {
99
before(() => {
10-
cy.visit('');
11-
cy.switchToVirt();
10+
cy.visitCatalog();
1211
});
1312

1413
it('test hint in InstanceTypes boot volume', () => {
15-
cy.visitCatalog();
1614
cy.contains('Select volume to boot from').find('svg').click();
1715
cy.contains(
1816
'From the Volume table, select a bootable volume to boot your VirtualMachine',
@@ -55,7 +53,7 @@ describe('Test filter in InstanceType', () => {
5553
cy.contains(colName, 'centos').should('not.exist');
5654
});
5755

58-
it('check instanceType class in catalog', () => {
56+
xit('check instanceType class in catalog', () => {
5957
cy.byButtonText('User').click();
6058
cy.get('input[aria-label="Filter menu items"]').clear().type('.small');
6159
cy.contains('n1').should('not.exist');

cypress/tests/e2e/check-tab-yaml.cy.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,10 @@ import { navigateToConfigurationSubTab, subTabName, tab } from '../../views/tab'
77

88
describe('Check all virtualization pages can be loaded', () => {
99
before(() => {
10-
cy.visit('');
10+
cy.visitVMs();
1111
});
1212

1313
describe('Check VirtualMachines page', () => {
14-
it('visit VM list page', () => {
15-
cy.visitVMs();
16-
});
17-
1814
it('start example vm', () => {
1915
cy.byLegacyTestID(Example).click();
2016
cy.get(sel.iconStartBtn, { timeout: MINUTE }).click();

cypress/tests/e2e/create-vm.cy.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ import { vm, waitForStatus } from '../../views/vm-flow';
1111

1212
describe('Create VMs from InstanceType', () => {
1313
before(() => {
14-
cy.visit('');
15-
cy.switchToVirt();
14+
cy.visitOverview();
15+
cy.visitCatalog();
1616
cy.switchProject(TEST_NS);
1717
});
1818

@@ -49,7 +49,6 @@ describe('Create VMs from Template', () => {
4949
tab.navigateToConfiguration();
5050
cy.contains(VM_TMPL_CUST.description).should('be.visible');
5151
cy.contains(VM_TMPL_CUST.hostname).should('be.visible');
52-
cy.byButtonText('Boot management').click();
5352
cy.contains(VM_TMPL_CUST.bootMode).should('be.visible');
5453
tab.navigateToConsole();
5554
cy.contains('.pf-v6-c-clipboard-copy', VM_TMPL_CUST.cloudInitUname).should('be.visible');

cypress/tests/e2e/d-networking.cy.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ import { NAD_BRIDGE, NAD_LOCALNET, NAD_OVN } from '../../utils/const/nad';
22
import { createNAD, deleteNAD } from '../../views/nad';
33

44
describe('Test network attachments', () => {
5-
before(() => {
6-
cy.visit('');
5+
beforeEach(() => {
6+
cy.visitNAD();
77
});
88

99
it('create NAD with MAC Spoof checked', () => {

cypress/tests/e2e/template-list.cy.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,6 @@ import { catalogNav } from '../../views/selector';
44
import * as tView from '../../views/selector-template';
55

66
describe('Test template list page', () => {
7-
before(() => {
8-
cy.visit('');
9-
cy.switchToVirt();
10-
});
11-
127
beforeEach(() => {
138
cy.clickVirtLink(catalogNav);
149
cy.visitTemplates();

0 commit comments

Comments
 (0)