Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Fix tests after changing gardener flow #3058

Merged
merged 6 commits into from
Jul 16, 2024
Merged
Show file tree
Hide file tree
Changes from 5 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
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 @@ -59,7 +59,7 @@ context('Test Cluster configuration', () => {
.contains('Cluster Details')
.click();

// Uncomment after resolving https://github.com/kyma-project/busola/issues/2511
// Uncomment after bringing back overriting storage
Copy link
Contributor

Choose a reason for hiding this comment

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

overriting storage is working

// cy.contains(/session storage/i).should('be.visible');
});

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');
// });
// });
});
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
Loading