ahmadhamwi999
08/08/2024, 9:35 PMPaginatedLazyRow
along with the original PaginatedLazyColumn
Some abstraction behind the scenes is happening which is what enabling the support to the lazy lists, while still keeping the same simple APIs.
Also the same tests have been abstracted away and reapplied on the new composable.
Huge respect to the authors of the Lazy lists in Compose, their code design enables such robust abstraction on top of the concrete lazy lists.
Also big thanks to the people who are starring and supporting the repository ๐๐ป
https://github.com/Ahmad-Hamwi/lazy-pagination-compose/Artem Kobzar
08/09/2024, 4:25 AMahmadhamwi999
08/09/2024, 5:58 AMahmadhamwi999
08/09/2024, 12:37 PMArtem Kobzar
08/09/2024, 12:39 PMahmadhamwi999
08/09/2024, 12:41 PMahmadhamwi999
08/09/2024, 12:43 PMArtem Kobzar
08/09/2024, 12:44 PMIlya Goncharov [JB]
08/09/2024, 1:43 PMjs {
browser()
}
should add test run.ahmadhamwi999
08/09/2024, 1:52 PMIlya Goncharov [JB]
08/09/2024, 1:54 PMahmadhamwi999
08/11/2024, 4:34 AMArtem Kobzar
08/11/2024, 7:18 AMahmadhamwi999
08/11/2024, 11:48 AMwasmJsBrowserTest
, thank you for the heads up @Ilya Goncharov [JB]
Running the tests using jsBrowserTest
is failing, saying:
ReferenceError: org_jetbrains_skia_Surface__1nMakeRasterN32Premul is not defined
A minimal reproducing code is under js-testing branch in my repo
And here's the full logs after cleaning the project:Artem Kobzar
08/11/2024, 2:06 PMIlya Goncharov [JB]
08/13/2024, 3:10 PMbuild.gradle.kts
js(IR) {
browser {
testTask {
useKarma {
useChromeHeadless()
useConfigDirectory(project.projectDir.resolve("karma.config.d").resolve("js"))
}
}
}
}
Then add js
file (with any name, for example index.js
) to karma.config.d/js
const path = require("path");
const basePath = config.basePath;
const wasmPath = path.resolve(basePath, "kotlin")
config.files = [
path.resolve(wasmPath, "skiko.js"),
{pattern: path.resolve(wasmPath, "skiko.wasm"), included: false, served: true, watched: false},
].concat(config.files);
And you need special callback for JS tests to work
@OptIn(ExperimentalTestApi::class)
@Test
fun firstPageProgressIndicatorShownInitially() {
onWasmReady {
runComposeUiTest {
setContent {
PaginatedLazyColumn(
paginationState = rememberPaginationState<Int, String>(
initialPageKey = 1,
onRequestPage = {}
),
firstPageProgressIndicator = {
Box(
modifier = Modifier.testTag("indicator")
)
},
) {}
}
onNodeWithTag("indicator").assertExists()
}
}
}
expect fun onWasmReady(arg: () -> Unit)
// actual js
actual external fun onWasmReady(arg: () -> Unit)
// actual others
actual fun onWasmReady(arg: () -> Unit) {
arg()
}
ahmadhamwi999
08/15/2024, 12:05 PM