-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
fix: implement new graphql fields for spec counts #25757
Conversation
Sounds like this is a bug fix? |
…om/cypress-io/cypress into marktnoonan/25647-new-cloud-fields
const wasWatchingCurrentProject = this.#cached.statuses.current === 'RUNNING' | ||
|
||
if (projectSlug && wasWatchingCurrentProject) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the change that avoids a flash of the full page loading skeleton when a next
run transitions from "running" to "completed".
Ideally we would have an end-to-end test for this, I'm working on one that can form part of a separate PR if this merges first. It's also the kind of test that will be much easier to write if we have improvements coming in the test infra soon.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think the wasWatchingCurrentProject
check will work at its current location. The #cached
variable is getting set on line 201, and the statusesChanged
variable is calculated before that. When the code gets to the wasWatchingCurrentProject
calculation, the #cached.statues.current
will no longer be RUNNING.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point. It's how the code was in the video I put in the PR description where it's having the intended effect, let me take a look at why exactly that's the case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated to move this earlier in the flow, everything seems good anyway.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still looking at this, but wanted to add the other comment to look at in the mean time.
const wasWatchingCurrentProject = this.#cached.statuses.current === 'RUNNING' | ||
|
||
if (projectSlug && wasWatchingCurrentProject) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think the wasWatchingCurrentProject
check will work at its current location. The #cached
variable is getting set on line 201, and the statusesChanged
variable is calculated before that. When the code gets to the wasWatchingCurrentProject
calculation, the #cached.statues.current
will no longer be RUNNING.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a name update for the test
packages/data-context/test/unit/sources/RelevantRunSpecsDataSource.spec.ts
Outdated
Show resolved
Hide resolved
current | ||
&& current.runNumber | ||
&& current.status | ||
&& typeof current.totalInstanceCount === 'number' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could use Number.isFinite(...)
as well to save a few chars and exclude edge cases like *Ininity
and NaN
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool, sure 👍
if ( | ||
next | ||
&& next.runNumber | ||
&& next.status | ||
&& typeof next.totalInstanceCount === 'number' | ||
&& typeof next.completedInstanceCount === 'number' | ||
) { | ||
runSpecsToReturn.runSpecs.next = { | ||
...this.#calculateSpecMetadata(cloudProject.next.specs || []), | ||
runNumber: cloudProject.next.runNumber, | ||
totalSpecs: next.totalInstanceCount, | ||
completedSpecs: next.completedInstanceCount, | ||
runNumber: next.runNumber, | ||
} | ||
|
||
runSpecsToReturn.statuses.next = cloudProject.next.status | ||
runSpecsToReturn.statuses.next = next.status | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This block is pretty much a duplicate of the one above, worth extracting to a fn?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was marginal on whether to do this or not, and we are about to be right back in here in the next sprint or two doing further modifications. So seems slightly easier on all sides to leave this logic repeated, make the diff super simple, and the shortly we'll combine them in a way that meets the needs we are about to have.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I went ahead and made a helper: f138cc3
(#25757)
…urce.spec.ts Co-authored-by: Stokes Player <[email protected]>
Co-authored-by: Mike Plummer <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left a comment on the test style, we need to get our graphql testing practices in order - still figuring out what those are.
I would say this is a non-blocking change, though.
// we do not expect a 'RUNNING` current and next run at the same time, so | ||
// the data below represents an invalid state. | ||
|
||
result.currentProject.cloudProject.runByNumber = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of modifying this on the fly, should we use the fixtures you added such as FAKE_PROJECT_MULTIPLE_COMPLETED
?
I find the modified on the fly ones kind of hard to read - you need to have a mental modal of exactly what you are modifying in the first place. How about you?
if (runNumber && Number.isFinite(totalInstanceCount) && Number.isFinite(completedInstanceCount)) { | ||
return { | ||
totalSpecs: totalInstanceCount!, | ||
completedSpecs: completedInstanceCount!, | ||
runNumber, | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am still wrapping my head around the best way to do type checking in scenarios like this to confirm that variables are defined. It stinks that you had to use the !
to tell typescript that these variables have a value since the Number.isFinite
does not do that for you.
This is just a comment and not a blocking request.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yuck, hadn't considered the typecheck loss. Could use _.isNumber
which has an appropriate type guard, but that accepts NaN
and *Infinity
which isn't ideal. I think we'd have to build a custom type guard to handle our definition of a valid number to get the TS compiler to handle this automatically:
function isValidNumber(value: unknown): value is number {
return Number.isFinite(value)
}
...
if (runNumber && isValidNumber(totalInstanceCount) && isValidNumber(completedInstanceCount)) {
return {
totalSpecs: totalInstanceCount,
completedSpecs: completedInstanceCount,
runNumber,
}
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah that seems better than the !
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated
* fix: update newProject ref when switching between organizations in SelectCloudProjectModal (#25730) * chore: debug page tooltip distance and artifact border (#25727) * misc: debug page tooltip distance and artifact border * add changelog entry * fix CT test * fix: Improve error handling around calls to `this.next` in middleware (#25702) * chore: update changelog validation example (#25742) * misc: improve debug loading text wrap responsiveness (#25703) * misc: Increase max failures in IATR badge to 99 (#25737) * chore: exclude collaborator issues/PRs from triage project (#25769) * feat: add --auto-cancel-after-failures flag (#25237) Co-authored-by: Emily Rohrbough <[email protected]> Co-authored-by: Matt Schile <[email protected]> Co-authored-by: Ryan Pei <[email protected]> Co-authored-by: Emily Rohrbough <[email protected]> * chore: Update v8 snapshot cache (#25592) * chore: updating v8 snapshot cache * chore: updating v8 snapshot cache * chore: updating v8 snapshot cache * chore: updating v8 snapshot cache * chore: updating v8 snapshot cache * chore: updating v8 snapshot cache * chore: updating v8 snapshot cache * chore: updating v8 snapshot cache * chore: updating v8 snapshot cache * chore: updating v8 snapshot cache * chore: updating v8 snapshot cache * chore: updating v8 snapshot cache * chore: updating v8 snapshot cache * chore: updating v8 snapshot cache * chore: updating v8 snapshot cache * chore: updating v8 snapshot cache * chore: updating v8 snapshot cache * chore: updating v8 snapshot cache * chore: updating v8 snapshot cache * chore: updating v8 snapshot cache * chore: updating v8 snapshot cache * chore: updating v8 snapshot cache * chore: updating v8 snapshot cache * chore: updating v8 snapshot cache * chore: updating v8 snapshot cache * chore: updating v8 snapshot cache * chore: updating v8 snapshot cache * chore: updating v8 snapshot cache * chore: updating v8 snapshot cache * Update update_v8_snapshot_cache.yml * chore: updating v8 snapshot cache * chore: updating v8 snapshot cache * chore: updating v8 snapshot cache * chore: updating v8 snapshot cache * chore: updating v8 snapshot cache * chore: updating v8 snapshot cache * chore: updating v8 snapshot cache * chore: updating v8 snapshot cache * chore: updating v8 snapshot cache * chore: updating v8 snapshot cache * chore: updating v8 snapshot cache * chore: updating v8 snapshot cache * chore: updating v8 snapshot cache * chore: updating v8 snapshot cache * chore: updating v8 snapshot cache * chore: updating v8 snapshot cache --------- Co-authored-by: cypress-bot[bot] <2f0651858c6e38e0+cypress-bot[bot]@users.noreply.github.com> Co-authored-by: Ryan Manuel <[email protected]> Co-authored-by: cypress-bot[bot] <47117332+cypress-bot[bot]@users.noreply.github.com> * fix: implement new graphql fields for spec counts (#25757) Co-authored-by: Stokes Player <[email protected]> Co-authored-by: Mike Plummer <[email protected]> * feat: Bundle cy.origin() dependencies at runtime (#25626) Co-authored-by: cypress-bot[bot] <2f0651858c6e38e0+cypress-bot[bot]@users.noreply.github.com> Co-authored-by: Ryan Manuel <[email protected]> * chore: remove zenhub from release process (#25701) Co-authored-by: Matt Schile <[email protected]> * feat: add Cypress.Commands.overwriteQuery (#25674) * feat: add Cypress.Commands.overwriteQuery Co-authored-by: Emily Rohrbough <[email protected]> Co-authored-by: Zach Bloomquist <[email protected]> * fix: spawn child process with process.env in macOS arm64 (#25753) Co-authored-by: Matt Schile <[email protected]> Co-authored-by: Emily Rohrbough <[email protected]> Co-authored-by: Zach Bloomquist <[email protected]> * chore: lint system tests in CI (#25673) * fix: Suppress filesystem errors during glob search (#25774) * chore: issue with ts-loader missing in binary and problematic esbuild norewrite construct (#25797) * chore: update changelog linting (#25809) * docs(guides): add more detail to code-signing (#25794) Co-authored-by: Emily Rohrbough <[email protected]> * chore: update workflows.yml to include the v8 snapshot update branch (#25784) Co-authored-by: cypress-bot[bot] <+cypress-bot[bot]@users.noreply.github.com> * chore: internal request preflight (#25772) --------- Co-authored-by: Emily Rohrbough <[email protected]> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: cypress-bot[bot] <2f0651858c6e38e0+cypress-bot[bot]@users.noreply.github.com> Co-authored-by: Ryan Manuel <[email protected]> Co-authored-by: Matt Henkes <[email protected]> Co-authored-by: Zach Bloomquist <[email protected]> * chore: bump for 12.6.0 release (#25812) * chore: release @cypress/webpack-batteries-included-preprocessor-v2.4.0 [skip ci] * chore: release @cypress/webpack-preprocessor-v5.17.0 [skip ci] * test: skip flaky GitDataSource test (#25825) * chore: making our add-to-triage-board workflow reusable within the Cypress-io org (#25820) * chore: Making our add to triage workflow callable from other projects inside the Cypress-io org in Github * chore: updated cypress-example-kitchensink version (#25828) * fix: duplicate and expired cookies (#25761) * chore: add regression tests for duplicate cookies and bad expiry times * avoid prepending domain with dot for cookies that are set with the server side jar. This is to avoid the cookie being duplicated if it is set or overridden in a different context (request that can actually set the cookie or via document.domain) * feat: use cookie.toString() in the cookie patch to more accurately set cookies on the document, which should include other properties besides key=value * fix: add logic to handle expired cookies in the document.cookie patch, as well as in CDP * chore: build binary for cookie fixes for users to test * chore: change name of fixture to something more accurate * chore: comment why we are using the toughCookie toString method in the patch * [run ci] * chore: add changelog entry * [run ci] * fix: revert back to key=value when getting document.cookie as those are the only values are displayed (oversight on my end) * [run ci] * chore: make compatible with cypress.require * fix: add tests for hostOnly/non hostOnly cookies to make sure property gets sent up to automation client correctly. No longer need custom cookie prop to determine destination * [run ci] * fix: stale unit test * chore: adjust comments * [run ci] * fix: bad domain logic * [run ci] * chore: remove irrelevant comment * [run ci] * fix: adjust cookie login text to spec hostOnly cookie within the cookie patch. This should yield the same behavior as we are bound to same origin within the spec bridge * [run ci] * [run ci] * fix: allow for cookies on request of same key to take precedence over cookies in the jar, regardless of how many hierachy cookies exist in the jar * chore: fix cookie misc tests for cy.origin (dont run cy.origin) * [run ci] * chore: skip misc cookie tests in webkit as headless behavior doesn't clear cookies between tests correctly * Revert "fix: allow for cookies on request of same key to take precedence over cookies in the jar, regardless of how many hierachy cookies exist in the jar" This reverts commit 17de188. * [run ci] * chore: split changelog entry into two parts * chore: update logic to remove else statement and add comments * [run ci] * chore: readd windows snapshot branch in workflows * [run ci] * chore: fix workflows from bad merge * [run ci] * Revert "chore: split changelog entry into two parts" This reverts commit 4352ef5. * [run ci] * fix: Fix type definitions for cy.reload() (#25779) Co-authored-by: Emily Rohrbough <[email protected]> * misc: Debug header updates (#25823) * fix: allow running tests outside Vite project root folder (#25801) * fix: allow running tests outside Vite project root folder * update snapshots * add changelog entry --------- Co-authored-by: Lachlan Miller <[email protected]> * fix: mount component in [data-cy-root] (#25807) * fix(angular): mount component in [data-cy-root] * fix e2e test * add changelog entry * changelog [skip ci] * changelog --------- Co-authored-by: Lachlan Miller <[email protected]> * chore: updating add to triage baord github action to use org secret (#25868) * chore: updating add to triage board github action to use org secret * chore: release @cypress/angular-v2.0.2 [skip ci] * chore: release @cypress/vite-dev-server-v5.0.3 [skip ci] * chore: Update v8 snapshot cache (#25822) Co-authored-by: cypress-bot[bot] <+cypress-bot[bot]@users.noreply.github.com> Co-authored-by: Ryan Manuel <[email protected]> * feat: support host only cookies (#25853) * feat: allow setCookie API to take a hostOnly option * chore: add jsdoc/typescript description to render to users * chore: add changelog entry * [run ci] * chore: fix types * chore: fix cookie login tests * chore: update e2e cookie system tests * [run ci] * chore: fix cookie command tests. localhost cookies are calculated as hostOnly, which is consistent with how cypress works today * chore: fix system tests for cookies. * [run ci] * chore: fix system tests * chore: skip hostOnly assertions in webkit (for now) * [run ci] * chore: add property definitions to setCookieOptions * [run ci] * chore: add comments to hostOnly prop in firefox when setting a cookie * fix(webpack-dev-server): touch component-index during onSpecsChange to avoid writing to app file (#25861) * testing: try disabling uTimesSync and see what happens * build binaries [run ci] * fix: touch component index file instead of browser.js * build binaries [run ci] * update test * fix test * add test for custom HTML file in config * use existing component index in webpack-dev-server unit tests --------- Co-authored-by: Lachlan Miller <[email protected]> * chore: release @cypress/webpack-dev-server-v3.2.4 [skip ci] * chore: improve types for server automation cookie client (#25836) * chore: improve types for automation cookies * [run ci] * fix: the cookie_behavior tests by syncing cookies immediately if … (#25855) * fix: fix the cookie_behavior tests by syncing cookies immediately if the application is already stable * chore: add changelog entry * [run ci] * chore: address comments from code review * feat: Public API for CT Framework Definitions (#25780) * chore: rework component onboarding in launchpad (#25713) * chore: refactoring and types * rework source of frameworks * revert rename * fix tests * fix more tests * types * update code * use same public API internally * rename interfaces * rename * work on dev server api * fix types * fix test * attempt to support getDevServerConfig * tests * add function to define framework [skip ci] * rework a lot of types * fix test * update tests and types * refactor * revert changes * lint * fix test * revert * remove * add "community" label [skip ci] * refactor * types * lint * fix bug * update function name * address feedback * improve types with Pick * refactor using type guard * correct label --------- Co-authored-by: Zachary Williams <[email protected]> * chore: typing error * feat: scan for 3rd party ct plugins (#25749) * chore: refactoring and types * rework source of frameworks * revert rename * fix tests * fix more tests * types * update code * use same public API internally * rename interfaces * rename * work on dev server api * fix types * fix test * attempt to support getDevServerConfig * tests * add function to define framework [skip ci] * rework a lot of types * fix test * update tests and types * refactor * revert changes * lint * fix test * revert * remove * add "community" label [skip ci] * refactor * types * lint * fix bug * update function name * address feedback * feat: scan for 3rd party ct plugins * add e2e test * unit tests [run ci] * tweak resolution * rebase, address comments * fix windows paths * remove .gitignore * fix test --------- Co-authored-by: Lachlan Miller <[email protected]> * lint config * spacing * try fix race cond * fix import error * build binary * try update snapshot * try using require * support namespaced definitions (#25804) * remove category * add icon prop * support esm -> cjs compiled typescript * fix test * misc: add CTA footer to launchpad framework dropdown (#25831) * remove test project dependencies * rebase * windows * windows again * add changelog entry * changelog * revert workflow * remove worklfow --------- Co-authored-by: Zachary Williams <[email protected]> Co-authored-by: Adam Stone-Lord <[email protected]> * chore: release @cypress/webpack-dev-server-v3.3.0 [skip ci] * fix: Add missing error message when `req.continue` is used incorrectly (#25884) --------- Co-authored-by: Adam Stone-Lord <[email protected]> Co-authored-by: Zachary Williams <[email protected]> Co-authored-by: Mike Plummer <[email protected]> Co-authored-by: Matt Schile <[email protected]> Co-authored-by: Alejandro Estrada <[email protected]> Co-authored-by: Emily Rohrbough <[email protected]> Co-authored-by: Ryan Pei <[email protected]> Co-authored-by: Emily Rohrbough <[email protected]> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: cypress-bot[bot] <2f0651858c6e38e0+cypress-bot[bot]@users.noreply.github.com> Co-authored-by: Ryan Manuel <[email protected]> Co-authored-by: cypress-bot[bot] <47117332+cypress-bot[bot]@users.noreply.github.com> Co-authored-by: Mark Noonan <[email protected]> Co-authored-by: Stokes Player <[email protected]> Co-authored-by: Chris Breiding <[email protected]> Co-authored-by: Zach Bloomquist <[email protected]> Co-authored-by: willmsC <[email protected]> Co-authored-by: Zach Bloomquist <[email protected]> Co-authored-by: cypress-bot[bot] <+cypress-bot[bot]@users.noreply.github.com> Co-authored-by: Tim Griesser <[email protected]> Co-authored-by: Matt Henkes <[email protected]> Co-authored-by: semantic-release-bot <[email protected]> Co-authored-by: Ben M <[email protected]> Co-authored-by: Bill Glesias <[email protected]> Co-authored-by: Podles <[email protected]> Co-authored-by: Paolo Caleffi <[email protected]> Co-authored-by: Lachlan Miller <[email protected]>
Additional details
This PR
#calculateSpecMetadata
function since we are now getting that information from the cloudcurrent
runSteps to test
Use of the new fields
The main thing to verify is that the spec counts are consistent with the cloud now. I test this by recording tests locally from a small project and comparing with the cloud. They poll at different rates so won't be totally in sync, but the total should be the same and we should not reach a state where the app shows "24 of 24" while the cloud is not completed, which was possible in the past.
Similarly, if I delete the Project ID and set up a new one, I should see the same thing when I record the first ever run in that project:
Cache clearing fix
Here we want to see that the transition between the banner's "in progress" state and the final "view run" state does not involve a cycle through the loading screen.
The place to watch this is at the end of a run and the transition happens.
Here is the old transition:
bad.transition.mov
And here is the new one:
good.transition.no.loading.state.mov
Logic update in
DebugContainer
This is currently only possible in the component test for this. The update is small and mostly there for developer-facing clarity since the front end logic previously allowed two components to render at the same time that are mutually exclusive in real life. Even though the server side logic did not lead to them rendering at the same time, it's confusing for the front end to have configurations that are possible that aren't valid states of the application.
How has the user experience changed?
PR Tasks
cypress-documentation
?type definitions
?