Skip to content

Commit

Permalink
fix: Fix tests after changing gardener flow (#3058)
Browse files Browse the repository at this point in the history
* fix tests

* change tests order in login

* remove token test

* remove unused

* cleanup

* fix
  • Loading branch information
OliwiaGowor authored Jul 16, 2024
1 parent f795d87 commit 7ecb492
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 106 deletions.
1 change: 1 addition & 0 deletions tests/integration/cypress.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ module.exports = defineConfig({
},
specPattern: [
'tests/cluster/test-download-a-kubeconfig.spec.js',
'tests/cluster/test-edit-cluster.spec.js',
'tests/cluster/test-cluster-overview.spec.js',
'tests/cluster/test-cluster-role-bindings.spec.js',
'tests/cluster/test-cluster-validation.spec.js',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,22 +45,13 @@ context('Test Cluster configuration', () => {
cy.loginAndSelectCluster();
cy.url().should('match', /overview$/);

// TODO: Bring back the overwritten message
// cluster storage message should be visible
// cy.contains(/The chosen storage type has been overwritten/).should(
// 'be.visible',
// );

// custom category should be added
cy.contains('Category from target cluster').should('be.visible');

// custom storage type should be set
cy.getLeftNav()
.contains('Cluster Details')
.click();

// Uncomment after resolving https://github.com/kyma-project/busola/issues/2511
// cy.contains(/session storage/i).should('be.visible');
});

it('Test pagination', () => {
Expand Down
28 changes: 17 additions & 11 deletions tests/integration/tests/cluster/test-edit-cluster.spec.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
/// <reference types="cypress" />
import config from '../../config';

const DESC = 'beautiful, pretty cluster for all our test needs';
const TEMP_NAME = 'clustered';

Expand All @@ -12,44 +14,48 @@ context('Test edit cluster', () => {
});

it('Changes cluster name and adds description', () => {
cy.get('.ui5-shellbar-menu-button').click();
cy.contains('Clusters Overview').click();
cy.visit(`${config.clusterAddress}/clusters`);

cy.get('ui5-table-cell')
.eq(0)
.then(el => (originalName = el.text()));

cy.get('button[data-testid="edit"]').click();
cy.get('ui5-button[data-testid="edit"]').click();

cy.get('input[data-testid="cluster-description"]')
cy.get('ui5-input[data-testid="cluster-description"]')
.find('input')
.click()
.type(DESC);

cy.get('input[date-testid="cluster-name"]')
cy.get('ui5-input[date-testid="cluster-name"]')
.first()
.find('input')
.type(`{selectall}{backspace}`)
.type(TEMP_NAME);

cy.contains('button', 'Update').click();
cy.contains('ui5-button', 'Update').click();

cy.contains(TEMP_NAME)
cy.get('.header')
.find('button')
.contains(TEMP_NAME)
.should('be.visible')
.click();

cy.contains('Clusters Overview').click();
cy.visit(`${config.clusterAddress}/clusters`);

cy.contains(DESC).should('be.visible');
});

it('Restores previous settings', () => {
cy.get('button[data-testid="edit"]').click();
cy.get('ui5-button[data-testid="edit"]').click();

cy.get('input[date-testid="cluster-name"]')
cy.get('ui5-input[date-testid="cluster-name"]')
.first()
.find('input')
.type(`{selectall}{backspace}`)
.type(originalName);

cy.contains('button', 'Update').click();
cy.contains('ui5-button', 'Update').click();

cy.contains(originalName)
.should('be.visible')
Expand Down
88 changes: 45 additions & 43 deletions tests/integration/tests/cluster/test-login-kubeconfigID.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,51 @@ context('Test login - kubeconfigID', () => {
});
});

it('Handles default kubeconfig', () => {
// mock defaultKubeconfig on
cy.intercept(
{
method: 'GET',
url: '/config/config.yaml*',
},
jsyaml.dump({
config: {
features: {
KUBECONFIG_ID: {
isEnabled: true,
config: {
kubeconfigUrl: '/kubeconfig',
defaultKubeconfig: 'mock-kubeconfig.yaml',
},
},
},
},
}),
);

cy.wrap(loadFile('kubeconfig.yaml')).then(kubeconfig => {
cy.intercept(
{
method: 'GET',
url: `${kubeconfigIdAddress}/*`,
},
kubeconfig,
);
cy.visit(`${config.clusterAddress}/clusters`);

cy.get('ui5-button[data-testid="delete"]').click();
cy.contains('ui5-button', 'Delete').click();

cy.contains('Load default cluster')
.should('be.visible')
.click();

cy.url().should('match', /overview$/);

cy.contains('Session Storage').should('be.visible');
});
});

it('Gracefully fails on invalid input', () => {
cy.intercept(
{
Expand All @@ -86,47 +131,4 @@ context('Test login - kubeconfigID', () => {
expect(alertContent).to.include('Error loading kubeconfig ID'),
);
});

// Uncomment after resolving https://github.com/kyma-project/busola/issues/2511
// it('Handles default kubeconfig', () => {
// // mock defaultKubeconfig on
// cy.intercept(
// {
// method: 'GET',
// url: '/config/config.yaml*',
// },
// jsyaml.dump({
// config: {
// features: {
// KUBECONFIG_ID: {
// isEnabled: true,
// config: {
// kubeconfigUrl: '/kubeconfig',
// defaultKubeconfig: 'mock-kubeconfig.yaml',
// },
// },
// },
// },
// }),
// );

// cy.wrap(loadFile('kubeconfig.yaml')).then(kubeconfig => {
// cy.intercept(
// {
// method: 'GET',
// url: `${kubeconfigIdAddress}/*`,
// },
// kubeconfig,
// );
// cy.visit(`${config.clusterAddress}/clusters`);

// cy.contains('Load default cluster')
// .should('be.visible')
// .click();

// cy.url().should('match', /overview$/);

// cy.contains('Session Storage').should('be.visible');
// });
// });
});
43 changes: 0 additions & 43 deletions tests/integration/tests/cluster/test-other-login-options.spec.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
/// <reference types="cypress" />
import 'cypress-file-upload';
import config from '../../config';
import { loadFile } from '../../support/loadFile';
import jsyaml from 'js-yaml';

context('Test other login options', () => {
Cypress.skipAfterFail();
Expand All @@ -11,47 +9,6 @@ context('Test other login options', () => {
cy.handleExceptions();
});

// Uncomment after resolving https://github.com/kyma-project/busola/issues/2511
// it('Kubeconfig and token separately', () => {
// cy.wrap(loadFile('kubeconfig.yaml')).then(kubeconfig => {
// const token = kubeconfig.users[0].user.token;
// kubeconfig.users[0].user.token = null;

// cy.visit(`${config.clusterAddress}/clusters`);

// cy.contains('Connect cluster').click();

// cy.contains('Drag your file here or click to upload').attachFile(
// {
// fileContent: jsyaml.dump(kubeconfig),
// filePath: 'kubeconfig.yaml',
// },
// {
// subjectType: 'drag-n-drop',
// },
// );

// cy.contains('Next').click();

// cy.contains(
// '[role=alert]',
// "We couldn't find enough authentication information",
// ).should('be.visible');

// cy.contains('Token')
// .parent()
// .next()
// .type(token);

// cy.contains('Next').click();

// cy.contains('[role="dialog"] button', 'Connect cluster').click();

// cy.url().should('match', /overview$/);
// cy.contains('Cluster Details').should('be.visible');
// });
// });

it('Reset endpoint', () => {
cy.loginAndSelectCluster();
cy.url().should('match', /overview$/);
Expand Down

0 comments on commit 7ecb492

Please sign in to comment.