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

(PC-33638) feat(chronicle): add anchor on chronicle when see more button used #7602

Merged
merged 6 commits into from
Feb 3, 2025

Conversation

clesausse-pass
Copy link
Contributor

@clesausse-pass clesausse-pass commented Jan 29, 2025

Link to JIRA ticket: https://passculture.atlassian.net/browse/PC-33638

Flakiness

If I had to re-run tests in the CI due to flakiness, I add the incident on Notion

Checklist

I have:

  • Made sure my feature is working on web.
  • Made sure my feature is working on mobile (depending on relevance : real or virtual devices)
  • Written unit tests native (and web when implementation is different) for my feature.
  • Added a screenshot for UI tickets or deleted the screenshot section if no UI change
  • If my PR is a bugfix, I add the link of the "résolution de problème sur le bug" on Notion
  • I am aware of all the best practices and respected them.

Screenshots

iOS:

Enregistrement.de.l.ecran.2025-01-30.a.13.57.04.mov

Android :

Enregistrement.de.l.ecran.2025-01-30.a.14.00.42.mov

Web mobile :

Enregistrement.de.l.ecran.2025-01-30.a.13.55.30.mov

Web desktop :

Enregistrement.de.l.ecran.2025-01-30.a.13.56.16.mov

Best Practices

Click to expand These rules apply to files that you make changes to. If you can't respect one of these rules, be sure to explain why with a comment. If you consider correcting the issue is too time consuming/complex: create a ticket. Link the ticket in the code.
  • In the production code: remove type assertions with as (type assertions are removed at compile-time, there is no runtime checking associated with a type assertion. There won’t be an exception or null generated if the type assertion is wrong). In certain cases as const is acceptable (for example when defining readonly arrays/objects). Using as in tests is tolerable.
  • Remove bypass type checking with any (when you want to accept anything because you will be blindly passing it through without interacting with it, you can use unknown). Using any in tests is tolerable.
  • Remove non-null assertion operators (just like other type assertions, this doesn’t change the runtime behavior of your code, so it’s important to only use ! when you know that the value can’t be null or undefined).
  • Remove all @ts-expect-error and @eslint-disable.
  • Remove all warnings, and errors that we are used to ignore (yarn test:lint, yarn test:types, yarn start:web...).
  • Use gap (ViewGap) instead of <Spacer.Column />, <Spacer.Row /> or <Spacer.Flex />.
  • Don't add new "alias hooks" (hooks created to group other hooks together). When adding new logic, this hook will progressively become more complex and harder to maintain.
  • Remove logic from components that should be dumb.

Test specific:

  • Avoid mocking internal parts of our code. Ideally, mock only external calls.
  • When you see a local variable that is over-written in every test, mock it.
  • Prefer user to fireEvent.
  • When mocking feature flags, use setFeatureFlags. If not possible, mention which one(s) you want to mock in a comment (example: jest.spyOn(useFeatureFlagAPI, 'useFeatureFlag').mockReturnValue(true) // WIP_NEW_OFFER_TILE in renderPassPlaylist.tsx )
  • In component tests, replace await act(async () => {}) and await waitFor(/* ... */) by await screen.findBySomething().
  • In hooks tests, use act by default and waitFor as a last resort.
  • Make a snapshot test for pages and modals ONLY.
  • Make a web specific snapshot when your web page/modal is specific to the web.
  • Make an a11y test for web pages.

Advice:

  • Use TDD
  • Use Storybook
  • Use pair programming/mobs

@clesausse-pass clesausse-pass force-pushed the PC-33638 branch 2 times, most recently from bb77c56 to 8929c99 Compare January 29, 2025 16:56
description={item.description}
date={item.date}
cardWidth={cardWidth}>
{shouldShowSeeMoreButton && offerId ? (
Copy link
Contributor Author

Choose a reason for hiding this comment

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

L'un ne va pas sans l'autre mais shouldShowSeeMoreButton est plus clair que si on avait juste offerId, qu'en pensez-vous ?

Copy link
Contributor

@mmeissonnier-pass mmeissonnier-pass Feb 3, 2025

Choose a reason for hiding this comment

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

Effectivement, si l'affichage de ton bouton dépend uniquement du fait d'avoir une offre, il n'y a aucune utilité à utiliser une autre propre pour faire la même chose. Mais est-ce que tu as vraiment besoin de ce test finalement ? Est-ce qu'on va avoir le cas où certaines chroniques auront des liens et pas d'autres ?

@clesausse-pass clesausse-pass force-pushed the PC-33638 branch 2 times, most recently from a9aa4f2 to 5f8054f Compare February 3, 2025 11:01
@@ -12,7 +12,7 @@ const CHRONICLE_THUMBNAIL_SIZE = getSpacing(14)

type Props = ChronicleCardData & {
cardWidth?: number
}
} & PropsWithChildren
Copy link
Contributor

Choose a reason for hiding this comment

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

Tu peux aussi écrire PropsWithChildren<ChronicleCardData & {...}>

description={item.description}
date={item.date}
cardWidth={cardWidth}>
{shouldShowSeeMoreButton && offerId ? (
Copy link
Contributor

@mmeissonnier-pass mmeissonnier-pass Feb 3, 2025

Choose a reason for hiding this comment

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

Effectivement, si l'affichage de ton bouton dépend uniquement du fait d'avoir une offre, il n'y a aucune utilité à utiliser une autre propre pour faire la même chose. Mais est-ce que tu as vraiment besoin de ce test finalement ? Est-ce qu'on va avoir le cas où certaines chroniques auront des liens et pas d'autres ?

Copy link
Contributor

@mmeissonnier-pass mmeissonnier-pass left a comment

Choose a reason for hiding this comment

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

Comme vu ensemble, dans le composant ChronicleCardListBase plutôt exposer une prop onShowMore optionnelle. si la prop est définie on sait qu'on doit afficher le bouton voir plus.

Copy link

sonarqubecloud bot commented Feb 3, 2025

Copy link
Contributor

@mmeissonnier-pass mmeissonnier-pass left a comment

Choose a reason for hiding this comment

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

@clesausse-pass clesausse-pass merged commit 78d4233 into master Feb 3, 2025
53 checks passed
@clesausse-pass clesausse-pass deleted the PC-33638 branch February 3, 2025 15:40
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.

3 participants