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

chore(data-context): update runSpec mutation to support absolute spec path #26973

Merged
merged 8 commits into from
Jun 13, 2023

Conversation

jordanpowell88
Copy link
Contributor

Additional details

While working through the implementation on this issue I ran into a limitation with the current runSpec mutation that was implemented in this ticket. We need the mutation to work by passing in an absolute specPath. This PR adds support for this

Steps to test

Launch the app using yarn dev and open GraphQL. Run the following mutation using an absolute specPath:

runSpec (specPath: "/Users/blah/Desktop/application/cypress/e2e/1-getting-started/todo.cy.js") {
    __typename
    ... on RunSpecResponse {
      testingType
      browser {
        id
        name
      }
      spec {
        id
        name
      }
    }
    ... on RunSpecError {
      code
      detailMessage
    }
  }

How has the user experience changed?

n/a

PR Tasks

@jordanpowell88 jordanpowell88 marked this pull request as ready for review June 8, 2023 19:05
@jordanpowell88 jordanpowell88 changed the title fix(data-context): update runSpec mutation to support absolute spec path chore(data-context): update runSpec mutation to support absolute spec path Jun 8, 2023
@cypress
Copy link

cypress bot commented Jun 8, 2023

5 flaky tests on run #47529 ↗︎

0 5193 77 0 Flakiness 5

Details:

Merge branch 'develop' into jordanpowell88/update-runSpec-mutation
Project: cypress Commit: d297c64a7f
Status: Passed Duration: 13:44 💡
Started: Jun 13, 2023 6:19 AM Ended: Jun 13, 2023 6:33 AM
Flakiness  commands/net_stubbing.cy.ts • 2 flaky tests • 5x-driver-electron

View Output Video

Test Artifacts
network stubbing > intercepting request > can delay and throttle a StaticResponse Output Video
... > stops waiting when an fetch request is canceled Output Video
Flakiness  cypress/cypress.cy.js • 3 flaky tests • 5x-driver-electron

View Output Video

Test Artifacts
... > correctly returns currentRetry Output Video
... > correctly returns currentRetry Output Video
... > correctly returns currentRetry Output Video

This comment has been generated by cypress-bot as a result of this project's GitHub integration settings.

@jordanpowell88 jordanpowell88 requested a review from a team June 8, 2023 20:02
Copy link
Contributor

@lmiller1990 lmiller1990 left a comment

Choose a reason for hiding this comment

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

Looks good - testing it now, one question about how we get the path.

@@ -512,26 +512,27 @@ export class ProjectActions {

let targetTestingType: TestingType

// Get relative path from the specPath to determine which testing type from the specPattern
const relativeSpecPath = this.ctx.path.normalize(specPath.substring(this.ctx.currentProject.length + 1, specPath.length))
Copy link
Contributor

@lmiller1990 lmiller1990 Jun 12, 2023

Choose a reason for hiding this comment

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

I think we can just use path.relative here.

// eg...
path.relative("/a/b", "/a/b/c/d.js") //=> 'c/d.js'

So in this case it'd be:

path.relative(this.ctx.currentProject,specPath)

This way, you won't need to do the calculations to get the correct characters etc.

Quick test:

> curr
'/Users/lachlanmiller/code/work/cypress2/packages/launchpad'
> spec
'/Users/lachlanmiller/code/work/cypress2/packages/launchpad/src/setup/LaunchpadHeader.vue'
>
> path.relative(curr, spec)
'src/setup/LaunchpadHeader.vue'

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ahhh, yes this was what I was trying to do. Still learning some of these node best practices. Thanks!

Copy link
Contributor

@astone123 astone123 left a comment

Choose a reason for hiding this comment

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

Can we update the description of the GraphQL argument for the mutation to say that we're expecting an absolute path?

specPath: nonNull(stringArg({
description: 'Relative path of spec to run from Cypress project root - must match e2e or component specPattern',
})),

@jordanpowell88 jordanpowell88 requested a review from astone123 June 12, 2023 21:01
Copy link
Contributor

@astone123 astone123 left a comment

Choose a reason for hiding this comment

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

Looks good 👍🏻

@lmiller1990
Copy link
Contributor

Tested it out, works as expected 💯

@lmiller1990 lmiller1990 merged commit 3fc17c2 into develop Jun 13, 2023
@lmiller1990 lmiller1990 deleted the jordanpowell88/update-runSpec-mutation branch June 13, 2023 06:38
@cypress-bot
Copy link
Contributor

cypress-bot bot commented Jun 20, 2023

Released in 12.15.0.

This comment thread has been locked. If you are still experiencing this issue after upgrading to
Cypress v12.15.0, please open a new issue.

@cypress-bot cypress-bot bot locked as resolved and limited conversation to collaborators Jun 20, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants