Skip to content

Commit

Permalink
Bump cyress
Browse files Browse the repository at this point in the history
  • Loading branch information
JBWatenbergScality committed Jan 4, 2025
1 parent e18b4de commit ef32193
Show file tree
Hide file tree
Showing 22 changed files with 1,668 additions and 7,537 deletions.
33 changes: 33 additions & 0 deletions ui/cypress.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import { defineConfig } from 'cypress'

export default defineConfig({
env: {
email: '[email protected]',
username: 'admin',
password: 'password',
device_path: '/dev/disk1',
volume_capacity: 1,
storage_class: 'metalk8s',
volume_label_name: 'kubernetest.io/name',
volume_label_value: 'test',
},
reporter: 'junit',
reporterOptions: {
mochaFile: 'junit/cypress-junit.xml',
toConsole: true,
},
chromeWebSecurity: false,
viewportWidth: 1440,
viewportHeight: 900,
defaultCommandTimeout: 30000,
experimentalNetworkStubbing: true,
experimentalFetchPolyfill: true,
e2e: {
// We've imported your old cypress plugins here.
// You may want to clean this up later by importing these.
setupNodeEvents(on, config) {
return require('./cypress/plugins/index.js')(on, config)
},
baseUrl: 'http://localhost:8084',
},
})
24 changes: 0 additions & 24 deletions ui/cypress.json

This file was deleted.

34 changes: 34 additions & 0 deletions ui/cypress/downloads/runtime-app-configuration
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"kind": "MicroAppRuntimeConfiguration",
"apiVersion": "ui.scality.com/v1alpha1",
"metadata": {
"kind": "metalk8s-ui",
"name": "metalk8s.eu-west-1"
},
"spec": {
"title": "MetalK8s Platform",
"selfConfiguration": {
"url": "/api/kubernetes",
"url_salt": "/api/salt",
"url_prometheus": "/api/prometheus",
"url_grafana": "/grafana",
"url_doc": "/docs",
"url_alertmanager": "/api/alertmanager",
"url_loki": "/api/loki",
"flags": [
"dashboard"
],
"ui_base_path": "/platform",
"url_support": "https://github.com/scality/metalk8s/discussions/new"
},
"auth": {
"kind": "OIDC",
"providerUrl": "https://13.48.197.10:8443/auth/realms/artesca",
"redirectUrl": "http://localhost:8084/platform",
"clientId": "control-plane-ui",
"responseType": "code",
"scopes": "openid email profile",
"providerLogout": true
}
}
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
21 changes: 13 additions & 8 deletions ui/cypress/plugins/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,19 @@

// This function is called when a project is opened or re-opened (e.g. due to
// the project's config changing)
const cucumber = require('cypress-cucumber-preprocessor').default;
const cucumberP = import('cypress-cucumber-preprocessor');

module.exports = (on, config) => {
on('file:preprocessor', cucumber());
cucumberP
.then((cucumber) => {
on('file:preprocessor', cucumber());

on('before:browser:launch', (browser, launchOptions) => {
if (browser.name === 'chrome') {
launchOptions.args.push('--js-flags=--expose-gc');
}
return launchOptions;
});
on('before:browser:launch', (browser, launchOptions) => {
if (browser.name === 'chrome') {
launchOptions.args.push('--js-flags=--expose-gc');
}
return launchOptions;
});
})
.catch(console.log);
};
13 changes: 7 additions & 6 deletions ui/cypress/requirements.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,11 @@ RPM_PACKAGES=(
)
NODE_PACKAGES=(
[email protected]
[email protected]
[email protected]
[email protected]
@testing-library/[email protected]
[email protected]
[email protected]
[email protected]
@testing-library/[email protected]
[email protected]
)

curl -sL https://rpm.nodesource.com/setup_10.x | sudo bash -
Expand All @@ -43,5 +44,5 @@ npm install "${NPM_OPTS[@]}" "${NODE_PACKAGES[@]}"

sudo ln -s "$PWD/node_modules/cypress/bin/cypress" /usr/local/bin/cypress

sudo chown root:root "$HOME/.cache/Cypress/5.6.0/Cypress/chrome-sandbox"
sudo chmod 4755 "$HOME/.cache/Cypress/5.6.0/Cypress/chrome-sandbox"
sudo chown root:root "$HOME/.cache/Cypress/13.17.0/Cypress/chrome-sandbox"
sudo chmod 4755 "$HOME/.cache/Cypress/13.17.0/Cypress/chrome-sandbox"
27 changes: 14 additions & 13 deletions ui/cypress/support/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import {
genValues,
} from './mockUtils';


Cypress.config({
retries: {
runMode: 2,
Expand Down Expand Up @@ -63,10 +64,10 @@ Cypress.Commands.add(
cy.intercept('GET', '/config.json', stubConfig);
}
if (stubUIDiscovery) {
cy.intercept('GET', '/shell/deployed-ui-apps.json', stubUIDiscovery);
cy.intercept('GET', '/shell/deployed-ui-apps.json', {...stubUIDiscovery });
}

cy.intercept('GET', '/.well-known/runtime-app-configuration', {
cy.intercept('GET', '**/.well-known/runtime-app-configuration*', {
fixture: 'runtime-app-configuration',
});

Expand All @@ -88,8 +89,8 @@ Cypress.Commands.add(
statusCode: 500,
});
});
cy.intercept('POST', '/api/salt/login', { fixture: 'salt-api/login.json' });
cy.intercept('GET', '/api/salt/events*', (req) =>
cy.intercept('POST', '**/api/salt/login', { fixture: 'salt-api/login.json' });
cy.intercept('GET', '**/api/salt/events*', (req) =>
req.reply(`data: ${JSON.stringify({})} \n\n`, {
'content-type': 'text/event-stream',
}),
Expand All @@ -99,13 +100,13 @@ Cypress.Commands.add(
cy.intercept(
{
method: 'GET',
pathname: '/api/kubernetes/api/v1/namespaces',
pathname: '**/api/kubernetes/api/v1/namespaces',
query: { fieldSelector: 'metadata.name=kube-system' },
},
{ fixture: 'kubernetes/namespace-kube-system.json' },
);
cy.fixture('kubernetes/nodes.json').then((nodes) => {
cy.intercept('GET', '/api/kubernetes/api/v1/nodes', { body: nodes });
cy.intercept('GET', '**/api/kubernetes/api/v1/nodes', { body: nodes });

cy.intercept(
'GET',
Expand All @@ -117,26 +118,26 @@ Cypress.Commands.add(
);
});

cy.intercept('GET', '/api/kubernetes/api/v1/pods', {
cy.intercept('GET', '**/api/kubernetes/api/v1/pods', {
fixture: 'kubernetes/pods.json',
});
cy.intercept('GET', '/api/kubernetes/api/v1/persistentvolumes', {
cy.intercept('GET', '**/api/kubernetes/api/v1/persistentvolumes', {
fixture: 'kubernetes/persistentvolumes.json',
});

cy.intercept(
'GET',
'/api/kubernetes/apis/storage.metalk8s.scality.com/v1alpha1/volumes',
'**/api/kubernetes/apis/storage.metalk8s.scality.com/v1alpha1/volumes',
{ fixture: 'kubernetes/volumes.json' },
);

cy.intercept('GET', '/api/kubernetes/api/v1/persistentvolumeclaims', {
cy.intercept('GET', '**/api/kubernetes/api/v1/persistentvolumeclaims', {
fixture: 'kubernetes/persistentvolumeclaims.json',
});

cy.intercept(
'GET',
'api/kubernetes/apis/storage.k8s.io/v1/storageclasses',
'**/api/kubernetes/apis/storage.k8s.io/v1/storageclasses',
{
fixture: 'kubernetes/storageclasses.json',
},
Expand Down Expand Up @@ -193,12 +194,12 @@ Cypress.Commands.add(
} else req.reply({ body: EMPTY_QUERY_RANGE_RESULT });
},
);
cy.intercept('GET', '/api/prometheus/api/v1/alerts', {
cy.intercept('GET', '**/api/prometheus/api/v1/alerts', {
fixture: 'prometheus/empty-alerts.json',
});

// Alertmanager
cy.intercept('GET', '/api/alertmanager/api/v2/alerts', {
cy.intercept('GET', '**/api/alertmanager/api/v2/alerts', {
fixture: 'alertmanager/alerts.json',
});
},
Expand Down
2 changes: 2 additions & 0 deletions ui/cypress/support/index.js → ui/cypress/support/e2e.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@

import './commands';

console.log('e2e.js loaded');

afterEach(() => {
// Redirect to empty page to cancel all requests in progress
cy.window().then((win) => {
Expand Down
Loading

0 comments on commit ef32193

Please sign in to comment.