Skip to content

Commit

Permalink
Merge pull request #8554 from metalice/connect-to-vm-using-ssh-cypres…
Browse files Browse the repository at this point in the history
…s-tests

Test vm ssh connect - cypress
  • Loading branch information
openshift-merge-robot committed Apr 7, 2021
2 parents 0a781c8 + cdf319d commit c083f4e
Show file tree
Hide file tree
Showing 7 changed files with 184 additions and 1 deletion.
Expand Up @@ -11,3 +11,14 @@
See how to setup env variables in Cypress https://docs.cypress.io/guides/guides/environment-variables.html#Setting


## Tests subjects
- You should organize tests by pages and by components as you should test components individually if possible. *.includes files are ignored by cypress. You can nest describe functions of includes files inside a main spec file of the same component/page. The folder structure for tests might look like.

├ component
├── test-a.includes.ts
├── test-b.includes.ts
├── component.spec.ts
├ page
├── test-a.includes.ts
├── test-b.includes.ts
├── page.spec.ts
Expand Up @@ -7,6 +7,7 @@
"reporterOptions": {
"configFile": "reporter-config.json"
},
"ignoreTestFiles": "*.includes.ts",
"supportFile": "support/index.ts",
"pluginsFile": "plugins/index.js",
"fixturesFolder": "fixtures",
Expand Down
@@ -0,0 +1,3 @@
{
"key": "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIPnp0CoHQoTOMg44Z8smEmi/Vrvt7FuBK6bDy5XpY/1g random@random"
}
@@ -0,0 +1,54 @@
export default ({ vmName }) =>
describe('ID (CNV-5971) Test if ssh service is present in advanced wizard', () => {
it('should navigate to advanced wizard', () => {
cy.get('[data-test=nav]')
.filter('[href$=virtualization]')
.then((link) => cy.visit(link.attr('href')));
cy.byLegacyTestID('item-create').click();
cy.byLegacyTestID('vm-wizard').click();
cy.get('.kv-select-template__tile')
.eq(1)
.click();
cy.byLegacyTestID('wizard-next')
.as('nextButton')
.click();
cy.byTestID('SupportModal').within(() => {
cy.get('[id=confirm-action]').click();
});
cy.get('[id=image-source-type-dropdown]').click();
cy.contains('Import via Registry (creates PVC)').click();
cy.get('[id=provision-source-container').type('kubevirt/fedora-cloud-container-disk-demo');
cy.get('@nextButton').click();
cy.get('[id=vm-name]')
.clear()
.type(`${vmName}-advanced-wizard`);
cy.byLegacyTestID('wizard-customize').click();
cy.get('.pf-c-wizard__nav-link')
.filter(':contains("Advanced")')
.click();
});

it('should open ssh accordion', () => {
cy.get('[id=ssh]').click();
});

it('checking expose service is checked', () => {
cy.get('[id=ssh-service-checkbox]').should('be.checked');
});

it('should continue to create vm', () => {
cy.get('[id=create-vm-wizard-reviewandcreate-btn]').click();
cy.get('[id=create-vm-wizard-submit-btn]').click();
cy.byLegacyTestID('kubevirt-wizard-success-result').should('be.visible');
});

it('should navigate to services', () => {
cy.get('[data-test=nav]')
.filter('[href$=services]')
.then((link) => cy.visit(link.attr('href')));
});

it('checking vm ssh service is present', () => {
cy.byLegacyTestID(`${vmName}-advanced-wizard-ssh-service`).should('be.exist');
});
});
@@ -0,0 +1,85 @@
export default ({ vmName }) =>
describe('ID (CNV-5970) Test creating a vm using simple wizard and adding an ssh key', () => {
it('starting to create a vm', () => {
cy.get('[data-test=nav]')
.filter('[href$=virtualization]')
.then((link) => cy.visit(link.attr('href')));
cy.byLegacyTestID('item-create').click();
cy.byLegacyTestID('vm-wizard').click();
cy.get('.kv-select-template__tile')
.eq(1)
.click();
cy.byLegacyTestID('wizard-next')
.as('nextButton')
.click();
cy.byTestID('SupportModal').within(() => {
cy.get('[id=confirm-action]').click();
});
cy.get('[id=image-source-type-dropdown]').click();
cy.contains('Import via Registry (creates PVC)').click();
cy.get('[id=provision-source-container').type('kubevirt/fedora-cloud-container-disk-demo');
cy.get('@nextButton').click();
cy.get('[id=vm-name]')
.clear()
.type(vmName);
});

it('checking if ssh keys message is visible', () => {
cy.byTestID('SSHCreateService-info-message').should('be.visible');
});

it('should open authorized keys component', () => {
cy.get('.SSHWizard-authorized-key').click();
});

it('checking no restore button', () => {
cy.get('.SSHFormKey-restore-button').should('not.exist');
});

it('checking no identity label', () => {
cy.get('.SSHFormKey-helperText-success').should('not.exist');
cy.get('.SSHFormKey-helperText-error').should('not.exist');
});

it('should add an ssh key', () => {
cy.fixture('ssh').then((ssh) => {
cy.get('.SSHFormKey-input-field').type(ssh?.key);
});
});

it('checking identity of key is correct', () => {
cy.get('.SSHFormKey-helperText-success').should('be.visible');
});

it('checking remember ssh key is not checked', () => {
cy.get('[id=ssh-service-checkbox]')
.first()
.should('not.be.checked');
});

it('should check remember ssh key', () => {
cy.get('[id=ssh-service-checkbox]')
.first()
.check();
});

it('checking if ssh helper modal exist', () => {
cy.get('.SSHPopover-button').click();
cy.byTestID('SSHPopover').should('be.visible');
});

it('checking if expose ssh service is checked by default', () => {
cy.get('[id=ssh-service-checkbox]')
.eq(1)
.should('be.checked');
});

it('checking if ssh keys message is not visible', () => {
cy.byTestID('SSHCreateService-info-message').should('not.exist');
});

it('should create a vm', () => {
cy.byLegacyTestID('wizard-next').click();
cy.byLegacyTestID('kubevirt-wizard-success-result').should('be.visible');
});
});
@@ -0,0 +1,29 @@
import { testName } from '../../support';
import sshAdvancedWizardTesting from './ssh-advanced-wizard-testing.includes';
// import sshSecretTesting from './ssh-secret-testing.includes';
// import sshServiceTesting from './ssh-service-testing.includes';
import sshSimpleWizardTest from './ssh-simple-wizard-test.includes';

// import sshVMDetailsPageTesting from './ssh-vm-details-page-testing.includes';

describe('Connect to a VM using SSH testing', () => {
const sshTestingFunctions = [
sshAdvancedWizardTesting,
sshSimpleWizardTest,
// sshSecretTesting,
// sshServiceTesting,
// sshVMDetailsPageTesting,
];
before(() => {
cy.login();
cy.visit('');
cy.createProject(testName);
});

sshTestingFunctions.forEach((fn) => fn({ vmName: `${testName}-vm` }));

after(() => {
cy.deleteProject(testName);
cy.visit('');
});
});
Expand Up @@ -26,7 +26,7 @@ const SupportModal: React.FC<SupportModalProps> = ({ onConfirm, close, community
const { t } = useTranslation();
const [doNotShow, setDoNotShow] = React.useState(false);
return (
<div className="modal-content">
<div className="modal-content" data-test="SupportModal">
<ModalTitle>
<BlueInfoCircleIcon className="co-icon-space-r" />
{t('kubevirt-plugin~Template support')}
Expand Down

0 comments on commit c083f4e

Please sign in to comment.