Skip to content

fix: Determine global mode based on whether there is a current project#22838

Merged
chrisbreiding merged 6 commits intodevelopfrom
global-mode-issue
Jul 19, 2022
Merged

fix: Determine global mode based on whether there is a current project#22838
chrisbreiding merged 6 commits intodevelopfrom
global-mode-issue

Conversation

@chrisbreiding
Copy link
Copy Markdown
Contributor

@chrisbreiding chrisbreiding commented Jul 18, 2022

User facing changelog

N/A - fixing an issue pre-release

Additional details

#22073 changes the logic for determining if the Launchpad is running in global mode, making it solely based on whether the --global flag is passed via the command line. In production, running cypress open results in a falsey value for the --global flag and so the Launchpad displays the welcome page instead of the global mode projects list.

Global mode should be determined by whether a project is specified or not. The --global flag can be used to force global mode, but if there is not a project, we can assume the Launchpad is being run in global mode.

Steps to test

  1. If you've installed a version of 10.3.1 before and have cypress installed globally, run cypress cache clear
  2. Install globally via the latest pre-release posted in this PR (npm install -g https://cdn.cypress.io/.../cypress.tgz)
  3. If you've installed a version of 10.3.1 before and didn't have cypress installed globally, run cypress cache clear && cypress install to ensure the latest binary from this PR is installed.
  4. Run cypress open
  5. The 'Add Project' or projects view should be shown

How has the user experience changed?

PR Tasks

  • Have tests been added/updated?
  • N/A Has the original issue (or this PR, if no issue exists) been tagged with a release in ZenHub? (user-facing changes only)
  • N/A Has a PR for user-facing changes been opened in cypress-documentation?
  • N/A Have API changes been updated in the type definitions?

@chrisbreiding chrisbreiding requested review from a team as code owners July 18, 2022 20:34
@cypress-bot
Copy link
Copy Markdown
Contributor

cypress-bot Bot commented Jul 18, 2022

Thanks for taking the time to open a PR!

@chrisbreiding chrisbreiding requested review from rachelruderman and removed request for a team July 18, 2022 20:34
@cypress
Copy link
Copy Markdown

cypress Bot commented Jul 18, 2022



Test summary

37729 0 456 0Flakiness 9


Run details

Project cypress
Status Passed
Commit d7e8636
Started Jul 19, 2022 1:45 PM
Ended Jul 19, 2022 2:02 PM
Duration 16:45 💡
OS Linux Debian - 10.11
Browser Multiple

View run in Cypress Dashboard ➡️


Flakiness

commands/xhr.cy.js Flakiness
1 ... > logs request + response headers
2 ... > logs Method, Status, URL, and XHR
3 ... > logs response
cypress/proxy-logging.cy.ts Flakiness
1 Proxy Logging > request logging > xhr log has response body/status code when xhr response is logged first
2 ... > intercept log has consoleProps with intercept info
This comment includes only the first 5 flaky tests. See all 9 flaky tests in the Cypress Dashboard.

This comment has been generated by cypress-bot as a result of this project's GitHub integration settings. You can manage this integration in this project's settings in the Cypress Dashboard

Copy link
Copy Markdown
Contributor

@marktnoonan marktnoonan left a comment

Choose a reason for hiding this comment

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

Testing the binary from this, this doesn't seem to get there.

  • cypress open -> thinks current directory is a project always?
  • downloading zip -> works great
  • opening with --global flag -> fine too

@@ -79,7 +79,7 @@ export const Query = objectType({

t.nonNull.boolean('isGlobalMode', {
description: 'Whether the app is in global mode or not',
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Global mode should be determined by whether a project is specified or not. The --global flag can be used to force global mode, but if there is not a project, we can assume the Launchpad is being run in global mode.

@chrisbreiding Gah I was missing this context for global mode when I did #22073. Would you mind adding your explanation to the description here so it doesn't get lost in the future? 🙏

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

No worries. It's not well-documented, so adding a better description is a good idea. I split it up between here and where the logic is in the CLI, so it's less likely to end up out-of-date if the implementation changes.

@chrisbreiding
Copy link
Copy Markdown
Contributor Author

Testing the binary from this, this doesn't seem to get there.

cypress open -> thinks current directory is a project always?
downloading zip -> works great
opening with --global flag -> fine too

@marktnoonan That's odd. After installing the pre-release binary from this PR, cypress open works properly for me. Did you clear your cypress cache before installing the pre-release? If not, it will use the cached version if you have one installed.

@marktnoonan
Copy link
Copy Markdown
Contributor

@chrisbreiding it wasn't cache but it turns out I had a wrong assumption about how this was expected to work - the new comments are helpful and after retesting, yeah this is the correct behavior now and doesn't enter the in-between state that develop opens to.

@marktnoonan
Copy link
Copy Markdown
Contributor

marktnoonan commented Jul 19, 2022

Hmm, the problem this work was intended to deal with seems to have resurfaced: the "Projects" link should still be in the top left here, since we did open in global mode and users can go back there. So "global mode", as far as the UI is concerned, can't only be determined by whether there is a project at the moment - that just tells the launchpad to be on the global page and as soon as a project is selected, we forget that we are running in global mode, which has effects that last longer.

Screen Shot 2022-07-19 at 9 09 18 AM

I suspect this is why that projectRootFromCI value that was removed in #22073 was introduced in the first place.

otherwise, it changes to false once a project is selected because then ctx.currentProject is set
@chrisbreiding
Copy link
Copy Markdown
Contributor Author

I've fixed that issue in 0507401 (#22838). Using ctx.modeOptions.project instead of ctx.currentProject keeps isGlobalMode from changing once a project is selected.

Comment thread cli/lib/exec/open.js Outdated
cy.get('h1').should('contain', defaultMessages.globalPage.empty.title)
})

it('shows global page when opened by global install', () => {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks for these!

Co-authored-by: Mark Noonan <mark@cypress.io>
@chrisbreiding chrisbreiding requested a review from astone123 July 19, 2022 13:44
@emilyrohrbough
Copy link
Copy Markdown
Member

Changes look good. Waiting for the last binary build to confirm you can get back to the project list once clicking a project in global mode.

@chrisbreiding chrisbreiding merged commit 1da95a7 into develop Jul 19, 2022
@chrisbreiding chrisbreiding deleted the global-mode-issue branch July 19, 2022 14:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants