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

fix: allow choose another dashboard template after pressing back #21248

Merged
merged 6 commits into from
Apr 24, 2024

Conversation

nikitaevg
Copy link
Contributor

Problem

Fix #20784.

This was caused by the following:

  1. isLoading is set to true on selecting a template.
  2. It's not set to false on pressing "back", so onClick returns early, I confirmed it via debugger.

Changes

Listener for the "Back" button is described here, so I set isLoading to false on clearActiveDashboardTemplate.

Does this work well for both Cloud and self-hosted?

N/A

How did you test this code?

Here's before, after.

Could you please guide me if I could add tests for this anywhere? I don't think it makes sense to test it in newDashboardLogic.test.tsx, as this functionality is spread across newDashboardLogic.ts and DashboardTemplateChooser.tsx, and I couldn't find tests that cover both of them. I also haven't found tests corresponding to this module in the commit history.

@nikitaevg
Copy link
Contributor Author

Hi @pauldambra !

I want to start contributing to PostHog, so I'm picking simple tasks to get acquainted with the project. Could you please review this PR as the latest contributor to this file, or assign somebody else? Thank you!

@pauldambra
Copy link
Member

Could you please guide me if I could add tests for this anywhere?

You could add tests in newDashboardLogic.test.tsx, but it isn't currently testing the kea logic in there so adding a test only for isLoading being false after calling clearActiveDashboardTemplate feels unnecessary

You could add a Cypress test to validate this works. That's the best place for tests that validate the interaction between components and logics

We only have a very basic test on top of templates here

it('Create dashboard from a template', () => {

So - since you want to learn how to contribute to posthog - you'd need to add a Cypress intercept so that the template modal had a template with a variable, then test that clicking that new template moves to the variable form in the modal, and finally that click back and selecting a template again works

I've manually tested this PR so I'd be happy to accept it without a test, but if you want to learn how to contribute on more complex fixes I'm also happy spending time reviewing changes to Cypress tests :)

@nikitaevg
Copy link
Contributor Author

Thanks for the guidance @pauldambra

PTAL again, I added a test. What's the best way to request a review once again? Just mentioning a reviewer? I couldn't find it in the tutorials.

@nikitaevg
Copy link
Contributor Author

FYI, I see there's a failure in a not related e2e test, which seems to be a flake, because it happens with other PRs. I'll fix it in #21259.

@Twixes Twixes self-requested a review April 2, 2024 10:45
@nikitaevg
Copy link
Contributor Author

Hi @Twixes! Kind reminder here, could you please review this?

@posthog-bot
Copy link
Contributor

This PR hasn't seen activity in a week! Should it be merged, closed, or further worked on? If you want to keep it open, post a comment or remove the stale label – otherwise this will be closed in another week.

@posthog-bot posthog-bot removed the stale label Apr 18, 2024
Copy link
Member

@Twixes Twixes left a comment

Choose a reason for hiding this comment

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

This works, thank you for the contribution! Apologies for the delay on this, I 100% dropped the ball on reviewing in a timely manner. Will do better next time!

@Twixes Twixes enabled auto-merge (squash) April 22, 2024 22:20
@nikitaevg
Copy link
Contributor Author

Thanks for the review @Twixes and no problem!

The merge looks stuck though, is there something I should do? The failing tests are probably flakes, as I don't touch the backend part here.

@mariusandra mariusandra disabled auto-merge April 24, 2024 12:07
@mariusandra mariusandra merged commit 0955a0b into PostHog:master Apr 24, 2024
96 of 100 checks passed
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.

Cannot choose another dashboard template after clicking back
5 participants