-
Notifications
You must be signed in to change notification settings - Fork 24
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
(BSR) perf(firebase): gestion des performances par firebase #7271
base: master
Are you sure you want to change the base?
Conversation
be0e598
to
8d18136
Compare
8d18136
to
a09b71a
Compare
Quality Gate passedIssues Measures |
Quality Gate failedFailed conditions |
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.
Hello, je passe juste par là, stylé que tu ais les mains encore dans le code, je te fait des retours sur les bonnes pratiques au sein de l'équipe plus que sur la partie métier.
- essaie de remplacer tous les fichiers
.tsx
qui n'utilisent pas dejsx
par des fichiersts
- remplace les
test('...')
parit('should ...')
|
||
jest.mock('shared/performance/useFirebasePerformanceProfiler', () => ({ | ||
useFirebasePerformanceProfiler: jest.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.
Il faudrait mettre ce mock dans les fichiers de tests concernés, dans le cas contraire ce mock sera chargé même dans les fichiers qui ne l'utilisent pas #6531
const { isConnected } = useNetInfoContext() | ||
const { isLoggedIn } = useAuthContext() | ||
|
||
useFirebasePerformanceProfiler('Favorites', { route } as UsePerformanceProfilerOptions) |
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.
le as
peut-être supprimé
@@ -158,6 +152,8 @@ export const ThematicHome: FunctionComponent = () => { | |||
// eslint-disable-next-line react-hooks/exhaustive-deps | |||
}, [hasGeolocPosition, isFromDeeplink]) | |||
|
|||
useFirebasePerformanceProfiler('ThematicHome', { route } as UsePerformanceProfilerOptions) |
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.
on peut supprimer le as
class MyDate extends Date { | ||
constructor(date: string) { | ||
super(date) | ||
} | ||
now = () => 1732384186972 | ||
} |
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.
Bien vu pour l'injection de dépendance, mais on ne l'utilise pas dans le code pour le moment on utilise mockdate.set(date)
On va préférer avoir un objet avec des fonctions comme la majorité de l'équipe n'a pas de connaissance sur l'OOP
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.
on peut peut-être utiliser un autre nom de classe que le MyDate
|
||
describe('AppStartTimeStore', () => { | ||
test('When start time the start time is correct', () => { | ||
const t = MyDate.now() |
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.
on peut peut-être utiliser un autre nom de classe que le t
// Supprimer les espaces en début et fin | ||
let sanitized = name.trim() | ||
// Supprimer les underscores au début et à la fin | ||
sanitized = sanitized.replace(/(^_+)|(_+$)/g, '') | ||
// Tronquer à 32 caractères maximum |
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.
les commentaires peuvent peut-être supprimés pour un naming plus parlant ou un stringBuilder pour encapsuler les implémentation de méthodes et exposer des noms parlant (overkill)
@@ -0,0 +1,324 @@ | |||
/* eslint-disable no-restricted-imports */ |
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.
import { act, renderHook } from 'tests/utils'
et renommer en .ts
import { PerformanceService, InteractionService } from './types' | ||
import { usePerformanceProfiler } from './usePerformanceProfiler' | ||
|
||
test('Ne fait rien si on ne veut pas profiler', async () => { |
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.
Peut-être mettre des noms de tests en anglais et wrapper le tout avec un describe
type useFirebasePerformanceProfilerProps = { | ||
route?: Route | ||
shouldProfile?: boolean | ||
} | ||
|
||
export const useFirebasePerformanceProfiler = ( | ||
traceName: string, | ||
props?: useFirebasePerformanceProfilerProps | ||
) => { |
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.
type useFirebasePerformanceProfilerProps<T extends ScreenNames> = {
route?: UseRouteType<T>
shouldProfile?: boolean
}
export const useFirebasePerformanceProfiler = <T extends ScreenNames>(
traceName: T,
props?: useFirebasePerformanceProfilerProps<T>
) => {
ce type te permettra d'avoir l'autocomplétion avec toutes les routes et de supprimer le problème avec les as
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.
Et bien remplacer le nom du fichier en ts
car le tsx
à tendance à confondre <T extends ScreenNames>
avec des composants
Link to JIRA ticket: https://passculture.atlassian.net/browse/PC-XXXXX
Flakiness
If I had to re-run tests in the CI due to flakiness, I add the incident on Notion
Checklist
I have:
Screenshots
delete if no UI change
Best Practices
Click to expand
!
when you know that the value can’t benull
orundefined
).Test specific:
user
tofireEvent
.