File tree Expand file tree Collapse file tree 3 files changed +20
-1
lines changed
src/browser/contexts/pr-review Expand file tree Collapse file tree 3 files changed +20
-1
lines changed Original file line number Diff line number Diff line change @@ -15,6 +15,9 @@ Use `bun` for everything - package management, tests.
1515
1616Tests should be minimal, not conflict with each other, and not be race-prone.
1717
18+ If you make changes to a file that has tests, you should ensure the tests pass and add a test-case if one does not already exist covering it.
19+ We do not want duplicative tiny tests, but we want cases to be covered.
20+
1821Good:
1922
2023- ` import { test } from "bun:test" `
Original file line number Diff line number Diff line change @@ -224,6 +224,16 @@ test("toggleViewed unmarks viewed file", () => {
224224 expect ( store . getSnapshot ( ) . viewedFiles . has ( "src/index.ts" ) ) . toBe ( false ) ;
225225} ) ;
226226
227+ test ( "toggleViewed navigates to next file when marking current file as viewed" , ( ) => {
228+ const store = createStore ( ) ;
229+ store . selectFile ( "src/index.ts" ) ;
230+
231+ store . toggleViewed ( "src/index.ts" ) ;
232+
233+ expect ( store . getSnapshot ( ) . viewedFiles . has ( "src/index.ts" ) ) . toBe ( true ) ;
234+ expect ( store . getSnapshot ( ) . selectedFile ) . toBe ( "src/utils.ts" ) ;
235+ } ) ;
236+
227237test ( "toggleViewedMultiple marks multiple files" , ( ) => {
228238 const store = createStore ( ) ;
229239
Original file line number Diff line number Diff line change @@ -524,13 +524,19 @@ export class PRReviewStore {
524524
525525 toggleViewed = ( filename : string ) => {
526526 const next = new Set ( this . state . viewedFiles ) ;
527- if ( next . has ( filename ) ) {
527+ const wasViewed = next . has ( filename ) ;
528+ if ( wasViewed ) {
528529 next . delete ( filename ) ;
529530 } else {
530531 next . add ( filename ) ;
531532 }
532533 this . persistViewedFiles ( next ) ;
533534 this . set ( { viewedFiles : next } ) ;
535+
536+ // When marking a file as viewed, navigate to the next file
537+ if ( ! wasViewed && filename === this . state . selectedFile ) {
538+ this . navigateToFile ( "next" ) ;
539+ }
534540 } ;
535541
536542 toggleViewedMultiple = ( filenames : string [ ] ) => {
You can’t perform that action at this time.
0 commit comments