-
-
Notifications
You must be signed in to change notification settings - Fork 335
feat(mobile): add family diary browsing and selective copying #2235
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
Merged
CodeWithCJ
merged 10 commits into
CodeWithCJ:main
from
Bl4nk24:feat/mobile-family-diary
Aug 26, 2026
Merged
Changes from 9 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
954b4bb
feat(server): support secure family diary copies
Bl4nk24 94ee156
feat(mobile): add family diary data and copy flows
Bl4nk24 4f23e77
feat(mobile): add family diary browsing and review
Bl4nk24 415cb2c
fix: keep reviewed family diary copies consistent
Bl4nk24 3f8ec59
fix(server): preserve unlinked family diary rows
Bl4nk24 6321f5e
fix: address family diary review findings
Bl4nk24 0e761c9
fix: align family diary access and navigation
Bl4nk24 bf804d7
chore(mobile): remove unused family date labels
Bl4nk24 b243da9
fix(server): discard clients after rollback failures
Bl4nk24 88de457
fix(mobile): restore dateUtils test to the translator signature
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
156 changes: 156 additions & 0 deletions
156
SparkyFitnessMobile/__tests__/components/DateNavigator.test.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,156 @@ | ||
| import React from 'react'; | ||
| import { fireEvent, render } from '@testing-library/react-native'; | ||
| import { SafeAreaProvider } from 'react-native-safe-area-context'; | ||
| import DateNavigator from '../../src/components/DateNavigator'; | ||
| import i18n, { initializeI18n } from '../../src/localization/i18n'; | ||
|
|
||
| describe('DateNavigator action', () => { | ||
| beforeAll(async () => { | ||
| await initializeI18n('en'); | ||
| }); | ||
|
|
||
| afterAll(async () => { | ||
| await i18n.changeLanguage('en'); | ||
| }); | ||
|
|
||
| test('renders an accessible 44 by 44 header action', () => { | ||
| const onPress = jest.fn(); | ||
| const { getByRole } = render( | ||
| <SafeAreaProvider | ||
| initialMetrics={{ | ||
| frame: { x: 0, y: 0, width: 390, height: 844 }, | ||
| insets: { top: 0, bottom: 0, left: 0, right: 0 }, | ||
| }} | ||
| > | ||
| <DateNavigator | ||
| title="Diary" | ||
| selectedDate="2025-01-15" | ||
| onPreviousDay={jest.fn()} | ||
| onNextDay={jest.fn()} | ||
| onToday={jest.fn()} | ||
| action={{ | ||
| icon: 'people', | ||
| accessibilityLabel: 'Open family diaries', | ||
| onPress, | ||
| }} | ||
| /> | ||
| </SafeAreaProvider>, | ||
| ); | ||
|
|
||
| const action = getByRole('button', { name: 'Open family diaries' }); | ||
| expect(action.props.style).toEqual( | ||
| expect.objectContaining({ width: 44, height: 44 }), | ||
| ); | ||
| fireEvent.press(action); | ||
| expect(onPress).toHaveBeenCalledTimes(1); | ||
| }); | ||
|
|
||
| test('exposes every date control as a named 44 point button', () => { | ||
| const onPreviousDay = jest.fn(); | ||
| const onNextDay = jest.fn(); | ||
| const onDatePress = jest.fn(); | ||
| const { getByRole } = render( | ||
| <SafeAreaProvider | ||
| initialMetrics={{ | ||
| frame: { x: 0, y: 0, width: 390, height: 844 }, | ||
| insets: { top: 0, bottom: 0, left: 0, right: 0 }, | ||
| }} | ||
| > | ||
| <DateNavigator | ||
| title="Family diary" | ||
| selectedDate="2025-01-15" | ||
| onPreviousDay={onPreviousDay} | ||
| onNextDay={onNextDay} | ||
| onToday={jest.fn()} | ||
| onDatePress={onDatePress} | ||
| /> | ||
| </SafeAreaProvider>, | ||
| ); | ||
|
|
||
| const previous = getByRole('button', { name: 'Previous day' }); | ||
| const picker = getByRole('button', { name: 'Choose date' }); | ||
| const next = getByRole('button', { name: 'Next day' }); | ||
|
|
||
| for (const control of [previous, picker, next]) { | ||
| expect(control.props.style).toEqual( | ||
| expect.objectContaining({ minHeight: 44, minWidth: 44 }), | ||
| ); | ||
| } | ||
| expect(previous.props.accessibilityHint).toBe('Shows the previous day'); | ||
| expect(picker.props.accessibilityHint).toBe('Opens the date picker'); | ||
| expect(next.props.accessibilityHint).toBe('Shows the next day'); | ||
|
|
||
| fireEvent.press(previous); | ||
| fireEvent.press(picker); | ||
| fireEvent.press(next); | ||
| expect(onPreviousDay).toHaveBeenCalledTimes(1); | ||
| expect(onDatePress).toHaveBeenCalledTimes(1); | ||
| expect(onNextDay).toHaveBeenCalledTimes(1); | ||
| }); | ||
|
|
||
| test('renders the global relative date and translated accessible controls', () => { | ||
| jest.useFakeTimers(); | ||
| jest.setSystemTime(new Date(2025, 0, 15, 12)); | ||
| const screen = render( | ||
| <SafeAreaProvider | ||
| initialMetrics={{ | ||
| frame: { x: 0, y: 0, width: 390, height: 844 }, | ||
| insets: { top: 0, bottom: 0, left: 0, right: 0 }, | ||
| }} | ||
| > | ||
| <DateNavigator | ||
| title="Dziennik rodzinny" | ||
| selectedDate="2025-01-15" | ||
| onPreviousDay={jest.fn()} | ||
| onNextDay={jest.fn()} | ||
| onToday={jest.fn()} | ||
| dateControls={{ | ||
| previousDayLabel: 'Poprzedni dzień', | ||
| previousDayHint: 'Pokazuje poprzedni dzień', | ||
| nextDayLabel: 'Następny dzień', | ||
| nextDayHint: 'Pokazuje następny dzień', | ||
| chooseDateLabel: 'Wybierz datę', | ||
| chooseDateHint: 'Otwiera wybór daty', | ||
| goToTodayLabel: 'Przejdź do dzisiaj', | ||
| goToTodayHint: 'Wraca do dzisiaj', | ||
| }} | ||
| /> | ||
| </SafeAreaProvider>, | ||
| ); | ||
|
|
||
| expect(screen.getByText('Today')).toBeTruthy(); | ||
| expect( | ||
| screen.getByRole('button', { name: 'Poprzedni dzień' }), | ||
| ).toBeTruthy(); | ||
| expect(screen.getByRole('button', { name: 'Następny dzień' })).toBeTruthy(); | ||
| jest.useRealTimers(); | ||
| }); | ||
|
|
||
| test('localizes default accessible controls for existing callers', async () => { | ||
| await i18n.changeLanguage('pl'); | ||
|
|
||
| const screen = render( | ||
| <SafeAreaProvider | ||
| initialMetrics={{ | ||
| frame: { x: 0, y: 0, width: 390, height: 844 }, | ||
| insets: { top: 0, bottom: 0, left: 0, right: 0 }, | ||
| }} | ||
| > | ||
| <DateNavigator | ||
| title="Dziennik" | ||
| selectedDate="2025-01-15" | ||
| onPreviousDay={jest.fn()} | ||
| onNextDay={jest.fn()} | ||
| onToday={jest.fn()} | ||
| onDatePress={jest.fn()} | ||
| /> | ||
| </SafeAreaProvider>, | ||
| ); | ||
|
|
||
| expect( | ||
| screen.getByRole('button', { name: 'Poprzedni dzień' }), | ||
| ).toBeTruthy(); | ||
| expect(screen.getByRole('button', { name: 'Wybierz datę' })).toBeTruthy(); | ||
| expect(screen.getByRole('button', { name: 'Następny dzień' })).toBeTruthy(); | ||
| }); | ||
| }); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.