Giter Site home page Giter Site logo

Comments (4)

khiga8 avatar khiga8 commented on May 6, 2024 1

I would love to pick this up as a way to get my feet wet! 👀

from react.

joshblack avatar joshblack commented on May 6, 2024

@khiga8 sounds great! Wanted to ask you, for the stretch goal is there anything that you all have found helpful for this in other projects like PVC or in github/github?

from react.

khiga8 avatar khiga8 commented on May 6, 2024

That's a great question @joshblack! I am not sure the same setup would translate to Primer React, but happy to share what I've observed about setups in other projects.

I've noticed that e2e tests in Primer React are reserved for auto-generated visual regression tests and axe scans tests. It sounds like this is because (as you've noted before), it is possible to write very robust React unit tests that test component behaviors. Since you can test most interactions (e.g. keyboard behavior) with unit tests, it isn't really worth testing these in e2e tests.

If I recall correctly, it's not possible to test JS behaviors with Rails unit tests. In PVC, in order to test (any kind of JS) interactions, e2e browser tests need to be written. Browser tests in PVC are written (manually, not auto-generated) with the intent of testing interactions because unit tests are limited. The e2e tests have been set up in a way where whenever interactions are made (e.g. a click call), an axe scan is automatically called. This expands coverage of axe to different states of the component automatically. It doesn't seem like this same setup would make sense in Primer React though and would require a significant change.

If we want to work with the existing setup, I wonder if a starting point could be to modify the script/generate-e2e-tests.js script, and have this cross-check the component markup (somehow?), and if it is role="dialog", role="combobox", role="menu" (or any markup that "pops over" or has a hidden initial state), the auto-generated tests would include the following:

Pseudo:

      test('axe @aat' on open state, async ({page}) => {
        await visit(page, {
          id: '${story.id}',
          globals: {
            colorScheme: theme
          }
        })
        // Remove this after addressing TODO
        expect(false).toBeTruthy();
        // TODO: We want the axe scan to run on the open state of the component. Please replace this with a call to open the component!
        await expect(page).toHaveNoViolations()
      })

Basically, try to call attention to the fact that there should be test coverage on the open state by noting it in the test and having it auto-fail.

Curious what you think of this approach to start with, or if you have any other ideas!

from react.

khiga8 avatar khiga8 commented on May 6, 2024

The following components have an open state and sufficient snapshot/axe coverage on it ✅

The following components have an open state and no snapshot/axe coverage on the open state ❌ , but are facing deprecation anyways. So I will take no action for now:

Opening a PR, just for ActionMenu!

from react.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.