Skip to content

Commit

Permalink
Move testing-library cypress commands import to inner commands so it …
Browse files Browse the repository at this point in the history
…can be imported (#5906)

Co-authored-by: Steve Piercy <[email protected]>
  • Loading branch information
sneridagh and stevepiercy authored Mar 23, 2024
1 parent f89c523 commit 45fa3a2
Show file tree
Hide file tree
Showing 17 changed files with 32 additions and 15 deletions.
16 changes: 16 additions & 0 deletions docs/source/upgrade-guide/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,22 @@ In your add-ons and projects, we advise you to always use the public components

This change improves UX of the Babel view (translation form) since a disabled field cannot be selected to be copied over.

### `volto-slate` Cypress helpers moved to its own module

There were some Cypress helpers for `volto-slate` along with the other definitions of Cypress commands.
The Cypress command definitions are intended to be loaded only once, whereas the helpers can be imported any number of times.
Therefore, we moved the helpers to its own module:

```js
import { slateBeforeEach } from '@plone/volto/cypress/support/commands';
```

becomes:

```js
import { slateBeforeEach } from '@plone/volto/cypress/support/helpers';
```

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

## Upgrading to Volto 17.x.x
Expand Down
3 changes: 1 addition & 2 deletions packages/volto/cypress/support/commands.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/* eslint-disable no-console */
import '@testing-library/cypress/add-commands';
import { getIfExists } from '../helpers';
import { ploneAuth } from './constants';

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

export * from './volto-slate';

// --- isInViewport ----------------------------------------------------------
Cypress.Commands.add('isInViewport', (element) => {
cy.get(element).then(($el) => {
Expand Down
1 change: 1 addition & 0 deletions packages/volto/cypress/support/helpers.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './volto-slate';
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { slateBeforeEach } from '../../../support/commands';
import { slateBeforeEach } from '../../../support/helpers';

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/commands';
import { slateBeforeEach } from '../../../support/helpers';

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

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/commands';
import { slateBeforeEach } from '../../../support/helpers';

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/commands';
import { slateBeforeEach } from '../../../support/helpers';

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

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

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

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

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/commands';
import { slateBeforeEach } from '../../../support/helpers';

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/commands';
import { slateBeforeEach } from '../../../support/helpers';

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/commands';
import { slateBeforeEach } from '../../../support/helpers';

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/commands';
import { slateBeforeEach } from '../../../support/helpers';

describe('Block Tests: pasting content in table block', () => {
beforeEach(slateBeforeEach);
Expand Down
1 change: 1 addition & 0 deletions packages/volto/news/5906.internal
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Move `testing-library` Cypress commands import to inner commands, so it can be imported from the outside. @sneridagh

0 comments on commit 45fa3a2

Please sign in to comment.