Overview

Prettier and ESLint are currently not enforced on Cypress tests. This causes issues with MRs when some people's IDEs will automatically format their Cypress tests but some peoples don't.

A solution to this would be to move the Cypress tests out of the /tests directory and into the /ui folder where it is already being enforced AND it also would not conflict with Drupal core's formatting rules. When trying to expand eslint enforcement to the Cypress file, it runs into a conflict with the prettier used by core.

Proposed resolution

Move Cypress tests to the /ui folder

User interface changes

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

hooroomoo created an issue. See original summary.

hooroomoo’s picture

Issue summary: View changes
wim leers’s picture

Priority: Normal » Major
Issue tags: +DX (Developer Experience)
Parent issue: » #3450592: [META] Front-end Kanban issue tracker
wim leers’s picture

omkar-pd made their first commit to this issue’s fork.

omkar-pd’s picture

Version: » 0.x-dev
Status: Active » Needs review
wim leers’s picture

Assigned: Unassigned » balintbrews

Let's land this!

balintbrews’s picture

Assigned: balintbrews » Unassigned
Status: Needs review » Needs work

Let's rename the directory to tests, please: ui/cypressui/tests. That is more conventional, and it's how people would look for tests. I think the current structure under that folder is fine, I don't see the need to have a subdirectory named cypress.

Also, when I tested the changes locally, I got many ESLint errors and required formatting changes when running npm run lint:eslint and npm run format. Let's make sure those are all gone before we merge the MR, otherwise we will break all MRs that merge in upstream code.

hooroomoo’s picture

Assigned: Unassigned » hooroomoo
hooroomoo’s picture

Will continue this

hooroomoo’s picture

Title: Enforce ESLint and Prettier on Cypress tests » [PP-1] Enforce ESLint and Prettier on Cypress tests
Assigned: hooroomoo » Unassigned
Status: Needs work » Postponed

Postponing this to after #3475759: Implement a different approach to the iFrame preview interactions is in since that touches many many Cypress files and would make sense to fix the errors the eslint-cypress plugin surfaces after that's in to avoid extra work.

jessebaker’s picture

Assigned: Unassigned » hooroomoo
Status: Postponed » Active
hooroomoo’s picture

Title: [PP-1] Enforce ESLint and Prettier on Cypress tests » Enforce ESLint and Prettier on Cypress tests
hooroomoo’s picture

A lot of the cypress eslint errors were for this rule: cypress/unsafe-to-chain-command. https://github.com/cypress-io/eslint-plugin-cypress/blob/master/docs/rules/unsafe-to-chain-command.md

This was good reading since the incorrect way seems very intuitive to me but turns out it's not recommended! :
https://docs.cypress.io/app/core-concepts/retry-ability#Actions-should-be-at-the-end-of-chains-not-the-middle

hooroomoo’s picture

Assigned: hooroomoo » balintbrews
Status: Active » Needs review
jessebaker’s picture

Assigned: balintbrews » hooroomoo
Status: Needs review » Needs work
hooroomoo’s picture

Assigned: hooroomoo » jessebaker
Status: Needs work » Needs review
balintbrews’s picture

Assigned: jessebaker » Unassigned
Status: Needs review » Reviewed & tested by the community

I went through all changes and approved the MR. Thanks for the hard work on this, everyone!

We're blocked on a code owner approval for the changes in gitlab-ci.yml. I naïvely thought I could temporarily add myself as a code owner, and give the approval, but it didn't work. (Makes sense that it didn't.) I assume that would need to be done upstream. I opened #3483966: Update "DX: CI" section of CODEOWNERS.

effulgentsia made their first commit to this issue’s fork.

effulgentsia’s picture

Status: Reviewed & tested by the community » Fixed

Thanks for opening #3483966: Update "DX: CI" section of CODEOWNERS. That'll be good to resolve. In the meantime, I merged this by temporarily turning off codeowner protection on 0.x. I turned that back on though right after merging this.

wim leers’s picture

Yay, thanks for this thorough improvement, @hooroomoo! 🙏

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.