-
Notifications
You must be signed in to change notification settings - Fork 2
feat: add Software Updates Dashboard #60
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
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
6281b32
feat: add software update types from SOVD spec
bburda e2d96db
feat: add updates API fetch helpers with tests
bburda f531203
fix: use explicit field instead of parameter property for erasableSyn…
bburda 83698c2
feat: add useUpdatesPolling hook with visibility pause
bburda 219851f
fix: add type annotations to test find callbacks
bburda 4751bff
feat: add UpdateCard component for software update status display
bburda 808c42a
feat: add UpdatesDashboard view with polling and action support
bburda 96794be
feat: wire Updates Dashboard into navigation
bburda 2d9e1e2
fix: adaptive polling interval, delete confirmation, action handler t…
bburda b006ce7
fix: address review findings - execute action, View Details dialog, d…
bburda 5612435
fix: address PR review - state reset, URL encoding, detail abort, con…
bburda 970e809
fix: address review round 2 - unmount abort, aria-label, status unava…
bburda c23b649
fix: add not-connected state to UpdatesDashboard
bburda 024d75b
fix: address review round 3 - poll guard, progress clamping, busy sta…
bburda 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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,141 @@ | ||
| // Copyright 2026 bburda | ||
| // | ||
| // Licensed under the Apache License, Version 2.0 (the "License"); | ||
| // you may not use this file except in compliance with the License. | ||
| // You may obtain a copy of the License at | ||
| // | ||
| // http://www.apache.org/licenses/LICENSE-2.0 | ||
| // | ||
| // Unless required by applicable law or agreed to in writing, software | ||
| // distributed under the License is distributed on an "AS IS" BASIS, | ||
| // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| // See the License for the specific language governing permissions and | ||
| // limitations under the License. | ||
|
|
||
| import { describe, it, expect, vi } from 'vitest'; | ||
| import { render, screen } from '@testing-library/react'; | ||
| import userEvent from '@testing-library/user-event'; | ||
| import { UpdateCard } from './UpdateCard'; | ||
| import type { UpdateEntry } from '@/lib/types'; | ||
|
|
||
| describe('UpdateCard', () => { | ||
| it('renders update ID', () => { | ||
| const entry: UpdateEntry = { | ||
| id: 'update-abc-123', | ||
| status: { status: 'pending' }, | ||
| }; | ||
|
|
||
| render(<UpdateCard entry={entry} />); | ||
|
|
||
| expect(screen.getByText(/update-abc-123/)).toBeInTheDocument(); | ||
| }); | ||
|
|
||
| it('shows status unavailable when status is null', () => { | ||
| const entry: UpdateEntry = { | ||
| id: 'update-failed-status', | ||
| status: null, | ||
| }; | ||
|
|
||
| render(<UpdateCard entry={entry} />); | ||
|
|
||
| expect(screen.getByText('Status unavailable')).toBeInTheDocument(); | ||
| }); | ||
|
|
||
| it('shows pending badge', () => { | ||
| const entry: UpdateEntry = { | ||
| id: 'update-pending', | ||
| status: { status: 'pending' }, | ||
| }; | ||
|
|
||
| render(<UpdateCard entry={entry} />); | ||
|
|
||
| expect(screen.getByText('pending')).toBeInTheDocument(); | ||
| }); | ||
|
|
||
| it('shows inProgress badge with progress bar', () => { | ||
| const entry: UpdateEntry = { | ||
| id: 'update-inprogress', | ||
| status: { status: 'inProgress', progress: 42 }, | ||
| }; | ||
|
|
||
| render(<UpdateCard entry={entry} />); | ||
|
|
||
| expect(screen.getByText('inProgress')).toBeInTheDocument(); | ||
| const progressBar = screen.getByRole('progressbar'); | ||
| expect(progressBar).toBeInTheDocument(); | ||
| expect(progressBar).toHaveAttribute('aria-valuenow', '42'); | ||
| expect(progressBar).toHaveAttribute('aria-valuemin', '0'); | ||
| expect(progressBar).toHaveAttribute('aria-valuemax', '100'); | ||
| }); | ||
|
|
||
| it('shows completed badge', () => { | ||
| const entry: UpdateEntry = { | ||
| id: 'update-done', | ||
| status: { status: 'completed' }, | ||
| }; | ||
|
|
||
| render(<UpdateCard entry={entry} />); | ||
|
|
||
| expect(screen.getByText('completed')).toBeInTheDocument(); | ||
| }); | ||
|
|
||
| it('shows failed badge with error message text', () => { | ||
| const entry: UpdateEntry = { | ||
| id: 'update-failed', | ||
| status: { status: 'failed', error: 'Checksum verification failed' }, | ||
| }; | ||
|
|
||
| render(<UpdateCard entry={entry} />); | ||
|
|
||
| expect(screen.getByText('failed')).toBeInTheDocument(); | ||
| expect(screen.getByText('Checksum verification failed')).toBeInTheDocument(); | ||
| }); | ||
|
|
||
| it('shows sub-progress list when present', () => { | ||
| const entry: UpdateEntry = { | ||
| id: 'update-sub', | ||
| status: { | ||
| status: 'inProgress', | ||
| progress: 60, | ||
| sub_progress: [ | ||
| { name: 'Download', progress: 100 }, | ||
| { name: 'Verify', progress: 20 }, | ||
| ], | ||
| }, | ||
| }; | ||
|
|
||
| render(<UpdateCard entry={entry} />); | ||
|
|
||
| expect(screen.getByText('Download')).toBeInTheDocument(); | ||
| expect(screen.getByText('100%')).toBeInTheDocument(); | ||
| expect(screen.getByText('Verify')).toBeInTheDocument(); | ||
| expect(screen.getByText('20%')).toBeInTheDocument(); | ||
| }); | ||
|
|
||
| it('does not show progress bar when progress is undefined', () => { | ||
| const entry: UpdateEntry = { | ||
| id: 'update-no-progress', | ||
| status: { status: 'pending' }, | ||
| }; | ||
|
|
||
| render(<UpdateCard entry={entry} />); | ||
|
|
||
| expect(screen.queryByRole('progressbar')).not.toBeInTheDocument(); | ||
| }); | ||
|
|
||
| it('calls onAction with correct id and action when action button clicked', async () => { | ||
| const user = userEvent.setup(); | ||
| const onAction = vi.fn(); | ||
| const entry: UpdateEntry = { | ||
| id: 'update-act', | ||
| status: { status: 'pending' }, | ||
| }; | ||
|
|
||
| render(<UpdateCard entry={entry} onAction={onAction} />); | ||
|
|
||
| const prepareButton = screen.getByRole('button', { name: /prepare/i }); | ||
| await user.click(prepareButton); | ||
|
|
||
| expect(onAction).toHaveBeenCalledWith('update-act', 'prepare'); | ||
| }); | ||
| }); |
Oops, something went wrong.
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.