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

Upgrade to Cypress 12.17.1 (latest) #4981

Merged
merged 10 commits into from
Jul 23, 2023
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
3 changes: 2 additions & 1 deletion cypress/support/commands.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import '@testing-library/cypress/add-commands';
import { getIfExists } from '../helpers';
import { ploneAuth } from './constants';

Expand All @@ -21,6 +20,8 @@ const ploneAuthObj = {
pass: ploneAuth[1],
};

export * from './volto-slate';

// --- isInViewport ----------------------------------------------------------
Cypress.Commands.add('isInViewport', (element) => {
cy.get(element).then(($el) => {
Expand Down
3 changes: 1 addition & 2 deletions cypress/support/e2e.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import '@testing-library/cypress/add-commands';
import 'cypress-axe';
import 'cypress-file-upload';
import './commands';
Expand Down Expand Up @@ -28,5 +29,3 @@ afterEach(function () {
teardown();
}
});

export * from './volto-slate';
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { slateBeforeEach } from '../../../support/e2e';
import { slateBeforeEach } from '../../../support/commands';

describe('Block Tests', () => {
beforeEach(slateBeforeEach);
Expand Down
2 changes: 1 addition & 1 deletion cypress/tests/core/volto-slate/02-block-slate.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { slateBeforeEach } from '../../../support/e2e';
import { slateBeforeEach } from '../../../support/commands';

describe('Block Tests', () => {
beforeEach(slateBeforeEach);
Expand Down
2 changes: 1 addition & 1 deletion cypress/tests/core/volto-slate/03-block-slate.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { slateBeforeEach, getSlateBlockValue } from '../../../support/e2e';
import { slateBeforeEach, getSlateBlockValue } from '../../../support/commands';

describe('Block Tests', () => {
beforeEach(slateBeforeEach);
Expand Down
2 changes: 1 addition & 1 deletion cypress/tests/core/volto-slate/04-block-focus.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { slateBeforeEach } from '../../../support/e2e';
import { slateBeforeEach } from '../../../support/commands';

describe('Block Tests', () => {
beforeEach(slateBeforeEach);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { slateBeforeEach } from '../../../support/e2e';
import { slateBeforeEach } from '../../../support/commands';

describe('Block Tests: Basic text format', () => {
beforeEach(slateBeforeEach);
Expand Down
12 changes: 6 additions & 6 deletions cypress/tests/core/volto-slate/06-block-slate-format-link.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { slateBeforeEach } from '../../../support/e2e';
import { slateBeforeEach } from '../../../support/commands';

describe('Block Tests: Links', () => {
beforeEach(slateBeforeEach);
Expand Down Expand Up @@ -66,31 +66,31 @@ describe('Block Tests: Links', () => {
'Colorless green ideas{shift}{enter} {shift}{enter}sleep furiously.',
);

cy.log("Adding link")
cy.log('Adding link');
cy.setSlateSelection('green', 'furiously');
cy.clickSlateButton('Add link');

cy.get('.slate-toolbar .link-form-container input').type(
'https://google.com{enter}',
);

cy.log("Removing link");
cy.log('Removing link');
cy.setSlateSelection('ideas');
cy.clickSlateButton('Edit link');
cy.get('.slate-inline-toolbar .cancel').click();

cy.log("Re-add link")
cy.log('Re-add link');
cy.setSlateSelection('Colorless', 'furiously');
cy.clickSlateButton('Add link');

cy.get('.slate-toolbar .link-form-container input').type(
'https://google.com{enter}',
);

cy.log("Save");
cy.log('Save');
cy.toolbarSave();

cy.log("then the page view should contain a link");
cy.log('then the page view should contain a link');
cy.get('[id="page-document"] p a')
.should('have.attr', 'href')
.and('include', 'https://google.com');
Expand Down
4 changes: 2 additions & 2 deletions cypress/tests/core/volto-slate/07-block-slate-format-ulist.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { slateBeforeEach } from '../../../support/e2e';
import { slateBeforeEach } from '../../../support/commands';

describe('Block Tests: Bulleted lists', () => {
beforeEach(slateBeforeEach);
Expand Down Expand Up @@ -47,7 +47,7 @@ describe('Block Tests: Bulleted lists', () => {

cy.log('then the page view should contain a link');
cy.get('#view #page-document p').its('length').should('eq', 1);
cy.get('#view #page-document p').should('have.text', "");
cy.get('#view #page-document p').should('have.text', '');
});

it('As editor I can remove bulleted lists', function () {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { slateBeforeEach } from '../../../support/e2e';
import { slateBeforeEach } from '../../../support/commands';

describe('Block Tests: Numbered lists', () => {
beforeEach(slateBeforeEach);
Expand Down
2 changes: 1 addition & 1 deletion cypress/tests/core/volto-slate/09-block-slate-slashmenu.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { slateBeforeEach } from '../../../support/e2e';
import { slateBeforeEach } from '../../../support/commands';

describe('SlashMenu Test: Shortcuts', () => {
beforeEach(slateBeforeEach);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { slateBeforeEach } from '../../../support/e2e';
import { slateBeforeEach } from '../../../support/commands';

describe('Block Tests: Bold Bulleted lists', () => {
beforeEach(slateBeforeEach);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { slateBeforeEach } from '../../../support/e2e';
import { slateBeforeEach } from '../../../support/commands';

describe('Block Tests: paste external images', () => {
beforeEach(slateBeforeEach);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { slateBeforeEach } from '../../../support/e2e';
import { slateBeforeEach } from '../../../support/commands';

describe('Block Tests: external text containing html contents/tags ', () => {
beforeEach(slateBeforeEach);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { slateBeforeEach } from '../../../support/volto-slate';
import { slateBeforeEach } from '../../../support/commands';

describe('Block Tests: pasting content in table block', () => {
beforeEach(slateBeforeEach);
Expand Down
21 changes: 21 additions & 0 deletions docs/source/upgrade-guide/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,26 @@ If you want to retain the old behavior (and no use `apiExpanders` at all), you n
config.settings.apiExpanders = [];
```

### Cypress upgraded to 12.17.1

As usual in a Volto major version release, Cypress has been upgraded to the latest version to date.
There are no major changes to the way the tests are implemented and run.

However, it could be that your Cypress boilerplate must be updated in your projects and add-ons if you use `@testing-library/cypress` in your tests.
This is due to a change in how the default commands are now built internally and in `@testing-library/cypress`.

You need to move the import:

```js
import '@testing-library/cypress/add-commands';
```

from {file}`cypress/support/commands.js` to {file}`cypress/support/e2e.js`, in case you have it in there.

This is because the overrides that `@testing-library/cypress` introduce can be run only once.
Since there are some commands that can call exports in {file}`cypress/support/commands.js`, this import may be run more than once, and then it errors.
So you have to make sure that import is run only once while the tests are run.

### New Image component

```{versionadded} 17.0.0-alpha.21
Expand All @@ -101,6 +121,7 @@ It requires the latest version of `plone.restapi` (>=8.42.0) installed in the ba
The `utils.js` file of the Teaser block was removed because it is no longer used.
You can consider removing it if you were shadowing it in your project.


(volto-upgrade-guide-16.x.x)=

## Upgrading to Volto 16.x.x
Expand Down
1 change: 1 addition & 0 deletions news/4981.internal
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Upgrade to Cypress 12.17.1 (latest) @sneridagh
Copy link
Sponsor Member

Choose a reason for hiding this comment

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

@sneridagh I think we also need an entry in the news folder for the volto-testing package

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@
"@loadable/server": "5.14.0",
"@loadable/webpack-plugin": "5.15.2",
"@plone/scripts": "2.1.2",
"@testing-library/cypress": "8.0.7",
"@testing-library/cypress": "9.0.0",
"@testing-library/jest-dom": "5.16.4",
"@testing-library/react": "12.1.5",
"@testing-library/react-hooks": "8.0.1",
Expand All @@ -257,8 +257,8 @@
"connected-react-router": "6.8.0",
"crypto-random-string": "3.2.0",
"css-loader": "5.2.7",
"cypress": "11.1.0",
"cypress-axe": "1.0.0",
"cypress": "12.17.1",
"cypress-axe": "1.4.0",
"cypress-file-upload": "5.0.8",
"debug": "4.3.2",
"decorate-component-with-props": "1.2.1",
Expand Down
1 change: 1 addition & 0 deletions packages/volto-testing/news/4981.breaking
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Update to Cypress 12.17.1 @sneridagh
6 changes: 3 additions & 3 deletions packages/volto-testing/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,12 @@
"access": "public"
},
"dependencies": {
"@testing-library/cypress": "8.0.7",
"@testing-library/cypress": "9.0.0",
"@testing-library/jest-dom": "5.16.4",
"@testing-library/react": "12.1.5",
"axe-core": "4.6.3",
"cypress": "11.1.0",
"cypress-axe": "1.0.0",
"cypress": "12.17.1",
"cypress-axe": "1.4.0",
"cypress-file-upload": "5.0.8"
},
"devDependencies": {
Expand Down
Loading