Skip to content

Commit d7f1853

Browse files
authored
deps(Cypress): upgrade library and related packages to latest versions, migrate config, fix type error (#2327)
* deps: upgrade cypress and related libraries * chore: automate migrate cypress config, rename spec files * fix: custom commands types * chore: upgrade CHANGELOG.md * ci: upgrade cypress action to support new config file format * ci: remove container from firefox job, upgrade checkout action
1 parent 75379c6 commit d7f1853

32 files changed

Lines changed: 443 additions & 419 deletions

.github/workflows/cypress.yml

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,13 @@ on: [pull_request]
33
jobs:
44
firefox:
55
runs-on: ubuntu-latest
6-
container:
7-
image: cypress/browsers:node14.17.0-chrome88-ff89
8-
options: --user 1001
96
steps:
107
- uses: actions/setup-node@v3
118
with:
129
node-version: 16
13-
- uses: actions/checkout@v2
10+
- uses: actions/checkout@v3
1411
- run: yarn ci:pull_paragraph
15-
- uses: cypress-io/github-action@v2
12+
- uses: cypress-io/github-action@v5
1613
with:
1714
config: video=false
1815
browser: firefox
@@ -23,9 +20,9 @@ jobs:
2320
- uses: actions/setup-node@v3
2421
with:
2522
node-version: 16
26-
- uses: actions/checkout@v2
23+
- uses: actions/checkout@v3
2724
- run: yarn ci:pull_paragraph
28-
- uses: cypress-io/github-action@v2
25+
- uses: cypress-io/github-action@v5
2926
with:
3027
config: video=false
3128
browser: chrome
@@ -36,9 +33,9 @@ jobs:
3633
- uses: actions/setup-node@v3
3734
with:
3835
node-version: 16
39-
- uses: actions/checkout@v2
36+
- uses: actions/checkout@v3
4037
- run: yarn ci:pull_paragraph
41-
- uses: cypress-io/github-action@v2
38+
- uses: cypress-io/github-action@v5
4239
with:
4340
config: video=false
4441
browser: edge

cypress.config.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import { defineConfig } from 'cypress'
2+
3+
export default defineConfig({
4+
env: {
5+
NODE_ENV: 'test',
6+
},
7+
fixturesFolder: 'test/cypress/fixtures',
8+
screenshotsFolder: 'test/cypress/screenshots',
9+
videosFolder: 'test/cypress/videos',
10+
e2e: {
11+
// We've imported your old cypress plugins here.
12+
// You may want to clean this up later by importing these.
13+
setupNodeEvents(on, config) {
14+
return require('./test/cypress/plugins/index.ts')(on, config)
15+
},
16+
specPattern: 'test/cypress/tests/**/*.cy.{js,jsx,ts,tsx}',
17+
supportFile: 'test/cypress/support/index.ts',
18+
},
19+
})

cypress.json

Lines changed: 0 additions & 11 deletions
This file was deleted.

docs/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
- `Fix`- Several bugs caused by random browser extensions.
1212
- `Improvement`*Dependencies* — Upgrade TypeScript to v5.
1313
- `Fix`*ToolsAPI*`pasteConfig` getter with `false` value could be used to disable paste handling by Editor.js core. Could be useful if your tool has its own paste handler.
14+
- `Improvement`*Dependencies* — Upgrade Cypress to v12, upgrade related libraries to latest versions.
1415

1516
### 2.26.5
1617

package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@
4848
"@babel/register": "^7.9.0",
4949
"@babel/runtime": "^7.9.2",
5050
"@codexteam/shortcuts": "^1.1.1",
51-
"@cypress/code-coverage": "^3.9.2",
52-
"@cypress/webpack-preprocessor": "^5.6.0",
51+
"@cypress/code-coverage": "^3.10.1",
52+
"@cypress/webpack-preprocessor": "^5.17.0",
5353
"@editorjs/code": "^2.7.0",
5454
"@editorjs/delimiter": "^1.2.0",
5555
"@editorjs/header": "^2.7.0",
@@ -64,8 +64,8 @@
6464
"core-js": "3.6.5",
6565
"css-loader": "^3.5.3",
6666
"cssnano": "^4.1.10",
67-
"cypress": "^6.8.0",
68-
"cypress-intellij-reporter": "^0.0.6",
67+
"cypress": "^12.9.0",
68+
"cypress-intellij-reporter": "^0.0.7",
6969
"eslint": "^8.28.0",
7070
"eslint-config-codex": "^1.7.1",
7171
"eslint-loader": "^4.0.2",

test/cypress/support/commands.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ Cypress.Commands.add('paste', {
7070
* Usage:
7171
* cy.get('div').copy().then(data => {})
7272
*/
73-
Cypress.Commands.add('copy', { prevSubject: true }, async (subject) => {
73+
Cypress.Commands.add('copy', { prevSubject: true }, (subject) => {
7474
const clipboardData: {[type: string]: any} = {};
7575

7676
const copyEvent = Object.assign(new Event('copy', {
@@ -87,7 +87,7 @@ Cypress.Commands.add('copy', { prevSubject: true }, async (subject) => {
8787

8888
subject[0].dispatchEvent(copyEvent);
8989

90-
return clipboardData;
90+
return cy.wrap(clipboardData);
9191
});
9292

9393
/**
@@ -96,7 +96,7 @@ Cypress.Commands.add('copy', { prevSubject: true }, async (subject) => {
9696
* Usage:
9797
* cy.get('div').cut().then(data => {})
9898
*/
99-
Cypress.Commands.add('cut', { prevSubject: true }, async (subject) => {
99+
Cypress.Commands.add('cut', { prevSubject: true }, (subject) => {
100100
const clipboardData: {[type: string]: any} = {};
101101

102102
const copyEvent = Object.assign(new Event('cut', {
@@ -113,18 +113,18 @@ Cypress.Commands.add('cut', { prevSubject: true }, async (subject) => {
113113

114114
subject[0].dispatchEvent(copyEvent);
115115

116-
return clipboardData;
116+
return cy.wrap(clipboardData);
117117
});
118118

119119
/**
120120
* Calls EditorJS API render method
121121
*
122122
* @param data — data to render
123123
*/
124-
Cypress.Commands.add('render', { prevSubject: true }, async (subject: EditorJS, data: OutputData): Promise<EditorJS> => {
125-
await subject.render(data);
124+
Cypress.Commands.add('render', { prevSubject: true }, (subject: EditorJS, data: OutputData) => {
125+
subject.render(data);
126126

127-
return subject;
127+
return cy.wrap(subject);
128128
});
129129

130130

test/cypress/support/index.d.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,22 +31,22 @@ declare global {
3131
* @usage
3232
* cy.get('div').copy().then(data => {})
3333
*/
34-
copy(): Chainable<{ [type: string]: any }>;
34+
copy(): Chainable<Subject>;
3535

3636
/**
3737
* Cut command to dispatch cut event on subject
3838
*
3939
* @usage
4040
* cy.get('div').cut().then(data => {})
4141
*/
42-
cut(): Chainable<{ [type: string]: any }>;
42+
cut(): Chainable<Subject>;
4343

4444
/**
4545
* Calls EditorJS API render method
4646
*
4747
* @param data — data to render
4848
*/
49-
render(data: OutputData): Chainable<EditorJS>;
49+
render(data: OutputData): Chainable<Subject>;
5050

5151
/**
5252
* Select passed text in element

0 commit comments

Comments
 (0)