Skip to content

Commit

Permalink
Upgrade Cypress to v12 (#8995)
Browse files Browse the repository at this point in the history
* Update Cypress to v12 (#8926)

* Update cypress to v12

Signed-off-by: Daniel Rowe <[email protected]>

* Add required e2e.js

Signed-off-by: Daniel Rowe <[email protected]>

* Changeset file for PR #8926 created/updated

* Update license header

Signed-off-by: Daniel Rowe <[email protected]>

* Update license in e2e.js

Signed-off-by: Daniel Rowe <[email protected]>

---------

Signed-off-by: Daniel Rowe <[email protected]>
Signed-off-by: Daniel Rowe <[email protected]>
Co-authored-by: Daniel Rowe <[email protected]>
Co-authored-by: opensearch-changeset-bot[bot] <154024398+opensearch-changeset-bot[bot]@users.noreply.github.com>

* fix: support imports without extensions in cypress webpack build (#8993)

* fix: support imports without extensions in cypress webpack build

Signed-off-by: Daniel Rowe <[email protected]>

* Changeset file for PR #8993 created/updated

* use typescript config

Signed-off-by: Daniel Rowe <[email protected]>

* fix lint

Signed-off-by: Daniel Rowe <[email protected]>

* disable new test isolation feature

This isolation was causing regressions

Signed-off-by: Daniel Rowe <[email protected]>

---------

Signed-off-by: Daniel Rowe <[email protected]>
Signed-off-by: Daniel Rowe <[email protected]>
Co-authored-by: opensearch-changeset-bot[bot] <154024398+opensearch-changeset-bot[bot]@users.noreply.github.com>

---------

Signed-off-by: Daniel Rowe <[email protected]>
Signed-off-by: Daniel Rowe <[email protected]>
Co-authored-by: opensearch-changeset-bot[bot] <154024398+opensearch-changeset-bot[bot]@users.noreply.github.com>
  • Loading branch information
d-rowe and opensearch-changeset-bot[bot] authored Dec 3, 2024
1 parent d5e0087 commit e07680b
Show file tree
Hide file tree
Showing 7 changed files with 293 additions and 48 deletions.
2 changes: 2 additions & 0 deletions changelogs/fragments/8926.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
chore:
- Update cypress to v12 ([#8926](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/8926))
2 changes: 2 additions & 0 deletions changelogs/fragments/8993.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
fix:
- Support imports without extensions in cypress webpack build ([#8993](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/8993))
65 changes: 65 additions & 0 deletions cypress.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*/

import { defineConfig } from 'cypress';
import webpackPreprocessor from '@cypress/webpack-preprocessor';

module.exports = defineConfig({
defaultCommandTimeout: 60000,
requestTimeout: 60000,
responseTimeout: 60000,
viewportWidth: 2000,
viewportHeight: 1320,
env: {
openSearchUrl: 'http://localhost:9200',
SECURITY_ENABLED: false,
AGGREGATION_VIEW: false,
username: 'admin',
password: 'myStrongPassword123!',
ENDPOINT_WITH_PROXY: false,
MANAGED_SERVICE_ENDPOINT: false,
VISBUILDER_ENABLED: true,
DATASOURCE_MANAGEMENT_ENABLED: false,
ML_COMMONS_DASHBOARDS_ENABLED: true,
WAIT_FOR_LOADER_BUFFER_MS: 0,
},
e2e: {
baseUrl: 'http://localhost:5601',
specPattern: 'cypress/integration/**/*_spec.{js,jsx,ts,tsx}',
testIsolation: false,
setupNodeEvents,
},
});

function setupNodeEvents(
on: Cypress.PluginEvents,
config: Cypress.PluginConfigOptions
): Cypress.PluginConfigOptions {
const { webpackOptions } = webpackPreprocessor.defaultOptions;

/**
* By default, cypress' internal webpack preprocessor doesn't allow imports without file extensions.
* This makes our life a bit hard since if any file in our testing dependency graph has an import without
* the .js extension our cypress build will fail.
*
* This extra rule relaxes this a bit by allowing imports without file extension
* ex. import module from './module'
*/
webpackOptions!.module!.rules.unshift({
test: /\.m?js/,
resolve: {
enforceExtension: false,
},
});

on(
'file:preprocessor',
webpackPreprocessor({
webpackOptions,
})
);

return config;
}
21 changes: 0 additions & 21 deletions cypress.json

This file was deleted.

6 changes: 6 additions & 0 deletions cypress/support/e2e.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*/

import '../utils/commands';
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,7 @@
"@babel/plugin-transform-class-static-block": "^7.24.4",
"@babel/register": "^7.22.9",
"@babel/types": "^7.22.9",
"@cypress/webpack-preprocessor": "^5.17.1",
"@elastic/apm-rum": "^5.6.1",
"@elastic/charts": "31.1.0",
"@elastic/ems-client": "7.10.0",
Expand Down Expand Up @@ -383,7 +384,7 @@
"chromedriver": "^121.0.1",
"classnames": "^2.3.1",
"compare-versions": "3.5.1",
"cypress": "9.5.4",
"cypress": "12.17.4",
"d3": "3.5.17",
"d3-cloud": "1.2.5",
"dedent": "^0.7.0",
Expand Down
Loading

0 comments on commit e07680b

Please sign in to comment.