From cc309983ffd19b979d20837b83771deb6f237e4c Mon Sep 17 00:00:00 2001 From: Georges-Antoine Assi Date: Fri, 31 Oct 2025 11:50:51 -0400 Subject: [PATCH] fix scrolling and test --- backend/models/platform.py | 2 +- .../handler/filesystem/test_roms_handler.py | 16 +++++++++------- frontend/src/components/Home/Collections.vue | 2 +- .../views/Gallery/Collection/BaseCollection.vue | 3 ++- frontend/src/views/Gallery/Platform.vue | 3 ++- frontend/src/views/Gallery/Search.vue | 3 ++- .../src/views/Settings/LibraryManagement.vue | 3 ++- 7 files changed, 19 insertions(+), 13 deletions(-) diff --git a/backend/models/platform.py b/backend/models/platform.py index 0986e9219..4013547bf 100644 --- a/backend/models/platform.py +++ b/backend/models/platform.py @@ -87,4 +87,4 @@ class Platform(BaseModel): return not self.is_unidentified def __repr__(self) -> str: - return self.name + return f"{self.name} ({self.slug}) ({self.id})" diff --git a/backend/tests/handler/filesystem/test_roms_handler.py b/backend/tests/handler/filesystem/test_roms_handler.py index 27060d81f..2c0e957a8 100644 --- a/backend/tests/handler/filesystem/test_roms_handler.py +++ b/backend/tests/handler/filesystem/test_roms_handler.py @@ -220,10 +220,10 @@ class TestFSRomsHandler: result = handler.exclude_multi_roms(roms) assert result == roms - def test_build_rom_file_single_file(self, handler: FSRomsHandler): + def test_build_rom_file_single_file(self, rom_single: Rom, handler: FSRomsHandler): """Test _build_rom_file with actual single ROM file""" - rom_path = Path("n64/roms") - file_name = "Paper Mario (USA).z64" + rom_path = Path(rom_single.fs_path) + file_name = rom_single.fs_name file_hash = FileHash( { "crc_hash": "ABCD1234", @@ -232,7 +232,7 @@ class TestFSRomsHandler: } ) - rom_file = handler._build_rom_file(rom_path, file_name, file_hash) + rom_file = handler._build_rom_file(rom_single, rom_path, file_name, file_hash) assert isinstance(rom_file, RomFile) assert rom_file.file_name == file_name @@ -244,10 +244,10 @@ class TestFSRomsHandler: assert rom_file.last_modified is not None assert rom_file.category is None # No category matching for this path - def test_build_rom_file_with_category(self, handler: FSRomsHandler): + def test_build_rom_file_with_category(self, rom_multi: Rom, handler: FSRomsHandler): """Test _build_rom_file with category detection""" # Test with DLC category - rom_path = Path("n64/roms/dlc") + rom_path = Path(rom_multi.fs_path, "dlc") file_name = "test_dlc.n64" file_hash = FileHash( { @@ -263,7 +263,9 @@ class TestFSRomsHandler: test_file.write_text("Test DLC content") try: - rom_file = handler._build_rom_file(rom_path, file_name, file_hash) + rom_file = handler._build_rom_file( + rom_multi, rom_path, file_name, file_hash + ) assert rom_file.category == RomFileCategory.DLC assert rom_file.file_name == file_name diff --git a/frontend/src/components/Home/Collections.vue b/frontend/src/components/Home/Collections.vue index 9c9c952c0..a15dc7a76 100644 --- a/frontend/src/components/Home/Collections.vue +++ b/frontend/src/components/Home/Collections.vue @@ -35,7 +35,7 @@ const { y: documentY } = useScroll(document.body, { throttle: 100 }); // Watch for scroll changes and trigger the throttled function watch(documentY, () => { if ( - documentY.value >= document.body.offsetHeight - 120 && + documentY.value + window.innerHeight >= document.body.scrollHeight - 300 && visibleCollections.value < props.collections.length ) { visibleCollections.value += 72; diff --git a/frontend/src/views/Gallery/Collection/BaseCollection.vue b/frontend/src/views/Gallery/Collection/BaseCollection.vue index 21e196186..6f817acd0 100644 --- a/frontend/src/views/Gallery/Collection/BaseCollection.vue +++ b/frontend/src/views/Gallery/Collection/BaseCollection.vue @@ -144,7 +144,8 @@ watch(documentY, () => { window.setTimeout(async () => { scrolledToTop.value = documentY.value === 0; if ( - documentY.value >= document.body.offsetHeight - 120 && + documentY.value + window.innerHeight >= + document.body.scrollHeight - 300 && fetchTotalRoms.value > filteredRoms.value.length ) { await fetchRoms(); diff --git a/frontend/src/views/Gallery/Platform.vue b/frontend/src/views/Gallery/Platform.vue index 94916f8da..d27bca20f 100644 --- a/frontend/src/views/Gallery/Platform.vue +++ b/frontend/src/views/Gallery/Platform.vue @@ -124,7 +124,8 @@ watch(documentY, () => { window.setTimeout(async () => { scrolledToTop.value = documentY.value === 0; if ( - documentY.value >= document.body.offsetHeight - 120 && + documentY.value + window.innerHeight >= + document.body.scrollHeight - 300 && fetchTotalRoms.value > filteredRoms.value.length ) { await fetchRoms(); diff --git a/frontend/src/views/Gallery/Search.vue b/frontend/src/views/Gallery/Search.vue index 1e8c5fc53..f3908915d 100644 --- a/frontend/src/views/Gallery/Search.vue +++ b/frontend/src/views/Gallery/Search.vue @@ -122,7 +122,8 @@ watch(documentY, () => { window.setTimeout(async () => { scrolledToTop.value = documentY.value === 0; if ( - documentY.value >= document.body.offsetHeight - 120 && + documentY.value + window.innerHeight >= + document.body.scrollHeight - 300 && fetchTotalRoms.value > filteredRoms.value.length ) { await fetchRoms(); diff --git a/frontend/src/views/Settings/LibraryManagement.vue b/frontend/src/views/Settings/LibraryManagement.vue index bd0083f3d..ee271a2ad 100644 --- a/frontend/src/views/Settings/LibraryManagement.vue +++ b/frontend/src/views/Settings/LibraryManagement.vue @@ -157,7 +157,8 @@ watch(documentY, () => { window.setTimeout(async () => { scrolledToTop.value = documentY.value === 0; if ( - documentY.value >= document.body.offsetHeight - 120 && + documentY.value + window.innerHeight >= + document.body.scrollHeight - 300 && fetchTotalRoms.value > filteredRoms.value.length ) { await fetchRoms();