Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
20 changes: 20 additions & 0 deletions ui/apps/platform/cypress.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/*
* The helper function intended to provide automatic code completion for configuration in many popular code editors
* had subtle side-effect to cause some typescript-eslint/no-unsafe-return errors in unit test files.
*
* const { defineConfig } = require('cypress'); // eslint-disable-line import/no-extraneous-dependencies
* module.exports = defineConfig({ … });
*/

module.exports = {
blockHosts: ['*.*'], // Browser options
chromeWebSecurity: false, // Browser options
numTestsKeptInMemory: 0, // Global options
viewportHeight: 850, // Viewport options
viewportWidth: 1440, // Viewport options

e2e: {
baseUrl: 'https://localhost:3000',
specPattern: 'cypress/integration/**/*.test.js',
},
};
14 changes: 0 additions & 14 deletions ui/apps/platform/cypress.json

This file was deleted.

10 changes: 0 additions & 10 deletions ui/apps/platform/cypress/integration/mainmenu.test.js

This file was deleted.

12 changes: 4 additions & 8 deletions ui/apps/platform/cypress/integration/network.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,10 @@ import {

function uploadYAMLFile(fileName, selector) {
cy.intercept('POST', api.network.simulate).as('postNetworkPolicySimulate');
cy.fixture(fileName).then((fileContent) => {
cy.get(selector).attachFile({
fileContent,
fileName,
mimeType: 'text/yaml',
encoding: 'utf8',
});
});

// Needs force option because input element has display: none style.
cy.get(selector).selectFile(`${Cypress.config('fixturesFolder')}/${fileName}`, { force: true });

cy.wait('@postNetworkPolicySimulate');
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,21 +22,22 @@ describe('Import policy', () => {
visitPolicies();

const fileName = 'policies/good_policy_to_import.json';
cy.fixture(fileName).then((fileContent) => {
const importedPolicyName = fileContent.policies[0].name;
cy.fixture(fileName).then((contents) => {
const importedPolicyName = contents.policies[0].name;

cy.get(`${selectors.table.policyLink}:contains("${importedPolicyName}")`).should(
'not.exist'
);

cy.get(selectors.table.importButton).click();

cy.get(selectors.importUploadModal.fileInput).attachFile({
fileContent,
fileName,
mimeType: 'application/json',
encoding: 'utf8',
});
cy.get(selectors.importUploadModal.fileInput).selectFile(
{
contents,
fileName,
},
{ force: true } // because input element has display: none style
);
cy.get(
`${selectors.importUploadModal.policyNames}:nth-child(1):contains("${importedPolicyName}")`
);
Expand Down Expand Up @@ -66,19 +67,20 @@ describe('Import policy', () => {

cy.get(selectors.table.importButton).click();

const fileContent = {
const contents = {
policies: [
{
name: 'Dupe Name Policy',
},
],
};
cy.get(selectors.importUploadModal.fileInput).attachFile({
fileContent,
fileName: 'dummy.json',
mimeType: 'application/json',
encoding: 'utf8',
});
cy.get(selectors.importUploadModal.fileInput).selectFile(
{
contents,
fileName: 'dummy.json',
},
{ force: true } // because input element has display: none style
);

const body = {
responses: [
Expand Down Expand Up @@ -127,19 +129,20 @@ describe('Import policy', () => {

cy.get(selectors.table.importButton).click();

const fileContent = {
const contents = {
policies: [
{
name: 'Dupe ID Policy',
},
],
};
cy.get(selectors.importUploadModal.fileInput).attachFile({
fileContent,
fileName: 'dummy.json',
mimeType: 'application/json',
encoding: 'utf8',
});
cy.get(selectors.importUploadModal.fileInput).selectFile(
{
contents,
fileName: 'dummy.json',
},
{ force: true } // because input element has display: none style
);

const body = {
responses: [
Expand Down Expand Up @@ -185,19 +188,20 @@ describe('Import policy', () => {

cy.get(selectors.table.importButton).click();

const fileContent = {
const contents = {
policies: [
{
name: 'Dupe Name and Dupe ID Policy',
},
],
};
cy.get(selectors.importUploadModal.fileInput).attachFile({
fileContent,
fileName: 'dummy.json',
mimeType: 'application/json',
encoding: 'utf8',
});
cy.get(selectors.importUploadModal.fileInput).selectFile(
{
contents,
fileName: 'dummy.json',
},
{ force: true } // because input element has display: none style
);

const body = {
responses: [
Expand Down
3 changes: 0 additions & 3 deletions ui/apps/platform/cypress/support/commands.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
// adds "upload" command, see https://github.com/abramenal/cypress-file-upload
import 'cypress-file-upload';

Cypress.Commands.add('getCytoscape', (containerId) => {
cy.wait(100);
cy.get(containerId).then(() => {
Expand Down
3 changes: 1 addition & 2 deletions ui/apps/platform/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,7 @@
"@types/react-redux": "^7.1.20",
"autoprefixer": "^10.2.5",
"babel-eslint": "^10.1.0",
"cypress": "^9.7.0",
"cypress-file-upload": "^5.0.8",
"cypress": "^10.6.0",
"eslint": "^7.32.0",
"eslint-config-airbnb": "^18.2.1",
"eslint-config-airbnb-typescript": "12.3.1",
Expand Down
13 changes: 4 additions & 9 deletions ui/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7040,15 +7040,10 @@ cyclist@^1.0.1:
resolved "https://registry.yarnpkg.com/cyclist/-/cyclist-1.0.1.tgz#596e9698fd0c80e12038c2b82d6eb1b35b6224d9"
integrity sha1-WW6WmP0MgOEgOMK4LW6xs1tiJNk=

cypress-file-upload@^5.0.8:
version "5.0.8"
resolved "https://registry.yarnpkg.com/cypress-file-upload/-/cypress-file-upload-5.0.8.tgz#d8824cbeaab798e44be8009769f9a6c9daa1b4a1"
integrity sha512-+8VzNabRk3zG6x8f8BWArF/xA/W0VK4IZNx3MV0jFWrJS/qKn8eHfa5nU73P9fOQAgwHFJx7zjg4lwOnljMO8g==

cypress@^9.7.0:
version "9.7.0"
resolved "https://registry.yarnpkg.com/cypress/-/cypress-9.7.0.tgz#bf55b2afd481f7a113ef5604aa8b693564b5e744"
integrity sha512-+1EE1nuuuwIt/N1KXRR2iWHU+OiIt7H28jJDyyI4tiUftId/DrXYEwoDa5+kH2pki1zxnA0r6HrUGHV5eLbF5Q==
cypress@^10.6.0:
version "10.6.0"
resolved "https://registry.yarnpkg.com/cypress/-/cypress-10.6.0.tgz#13f46867febf2c3715874ed5dce9c2e946b175fe"
integrity sha512-6sOpHjostp8gcLO34p6r/Ci342lBs8S5z9/eb3ZCQ22w2cIhMWGUoGKkosabPBfKcvRS9BE4UxybBtlIs8gTQA==
dependencies:
"@cypress/request" "^2.88.10"
"@cypress/xvfb" "^1.2.4"
Expand Down