Hello everyone, following up with my <recent annou...
# feed
a
Hello everyone, following up with my recent announcement of lazy-pagination-compose, I'm happy to share that I've also added support for a
PaginatedLazyRow
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/
๐Ÿฅท 1
๐ŸŽ‰ 3
a
Do you have plans to add the web target?
a
Yes I do, hopefully soon
๐Ÿ”ฅ 1
K 1
Big thanks to TomislavMladenov for the PR that added the wasm js target in this PR I'll soon be publishing the wasm js artifacts
a
There is only JS target. It would nice also to add wasmJs (not much harder that this PR)
a
Oh my bad, got it, I'll be checking the wasm target too.
I'll also need to see how I can run the UI tests targeting JS and wasmJs, do you have any clue what are the gradle commands for them?
a
@Ilya Goncharov [JB] I believe Karma should handle it right?
i
By default lines
Copy code
js {
    browser()
}
should add test run.
a
Thank you, I believe same goes for wasmJs. If I'm encountering errors running my UI tests on the js and wasmJs targets, where do I seek help?
i
You can ask here. As for wasm-js we have bugs for versions earlier than 2.0.20 (https://kotlinlang.slack.com/archives/CDFP59223/p1722925272045489) They can be workarounded, but actually you can check if it works for you with 2.0.20-RC version
๐Ÿ™Œ 1
a
Hi @Artem Kobzar, I've published the js and wasm js targets ๐ŸŽ‰ As for the testing part I encountered some errors and I may ask for help soon.
๐ŸŽ‰ 1
a
Sure, feel free to ask any question.
โœ… 1
a
wasm tests are now working for me after upgrading to 2.0.20-RC using
wasmJsBrowserTest
, thank you for the heads up @Ilya Goncharov [JB] Running the tests using
jsBrowserTest
is failing, saying:
Copy code
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:
a
@Ilya Goncharov [JB] do we use some separate version of index.html for tests?
i
Yes, JS setup is a bit harder, so it is recommended to use wasm for compose web. You need to add a bit configuration to test framework. Initially add configuration to
build.gradle.kts
Copy code
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
Copy code
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
Copy code
@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()
}
๐Ÿ™๐Ÿป 1
K 1
a
Thank you for your detailed response ๐Ÿ™๐Ÿป