Skip to content

[ALFMOB-341] Add BFF integration test suite (productList, productDetails, searchProducts)#24

Merged
hoangnhatdrk merged 4 commits into
mainfrom
feature/ALFMOB-341-integration-tests
Jun 25, 2026
Merged

[ALFMOB-341] Add BFF integration test suite (productList, productDetails, searchProducts)#24
hoangnhatdrk merged 4 commits into
mainfrom
feature/ALFMOB-341-integration-tests

Conversation

@hoangnhatdrk

Copy link
Copy Markdown
Contributor

ALFMOB-341 — Integration test suite against local BFF

Adds a new :integration-test Android library module with instrumented tests that drive a real ApolloClient against a locally-running BFF, exercising the operations introduced in the BFF-migration epic.

Coverage

  • productList — happy path, cursor pagination (page 2 distinct from page 1), PRICE_ASC ordering, brand filter.
  • productDetails — happy path for a real handle, plus variants reconstructed-from-options[] consistency.
  • searchProducts — happy path, cursor pagination.

Tests are data-driven (handles/terms are read from productList for the frontpage collection) so they tolerate changing BFF data, and assert on shape rather than exact values.

How it runs

  • Instrumented only — runs via ./gradlew :integration-test:connectedDebugAndroidTest (an emulator + a BFF on :3000). Not part of testDebugUnitTest, so PR unit lanes are unaffected.
  • A readiness gate (assumeTrue) skips — not fails — when no BFF is reachable, so the suite stays green on devices/CI without a backend.
  • Standalone test APK needs its own INTERNET permission + a cleartext allowance for 10.0.2.2 (added via the androidTest manifest); these are otherwise only present in :app.

Verification

Ran on a Pixel_10_Pro emulator against the live local BFF: 7 tests, 0 failures, 0 skipped. detekt clean.

Docs / follow-ups

  • README gains an "Integration tests (local BFF)" section (start BFF → emulator → run target).
  • CI orchestration (boot/teardown script + GitHub Actions job) is tracked separately in ALFMOB-409.

Copilot AI review requested due to automatic review settings June 21, 2026 14:52

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a new :integration-test Android library module containing instrumented integration tests that exercise the new BFF GraphQL operations (productList, productDetails, searchProducts) against a locally-running backend (emulator host alias 10.0.2.2). This fits the ongoing BFF migration by validating server responses and pagination behavior with a real ApolloClient, while keeping unit-test lanes unaffected.

Changes:

  • Introduces the :integration-test module with a JUnit5 instrumented test suite (reachability-gated via assumeTrue).
  • Adds test-only manifest + network security config to allow INTERNET + cleartext to 10.0.2.2.
  • Updates docs and aligns PLP placeholder collection handle to frontpage.

Reviewed changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
settings.gradle.kts Includes the new :integration-test module in the Gradle build.
README.md Documents how to run the local-BFF integration tests and where reports are generated.
integration-test/build.gradle.kts Declares the new module and its androidTest-only dependencies.
integration-test/src/main/AndroidManifest.xml Provides a minimal manifest for the new library module.
integration-test/src/androidTest/AndroidManifest.xml Adds INTERNET permission and points to a test-only network security config.
integration-test/src/androidTest/res/xml/network_security_config.xml Allows cleartext traffic to 10.0.2.2 for emulator → host BFF access.
integration-test/src/androidTest/java/com/mindera/alfie/integrationtest/BffIntegrationTest.kt Adds a shared base with BFF reachability gating + Apollo execution helpers.
integration-test/src/androidTest/java/com/mindera/alfie/integrationtest/ProductListIntegrationTest.kt Validates productList happy path, pagination, sorting, and brand filtering.
integration-test/src/androidTest/java/com/mindera/alfie/integrationtest/ProductDetailsIntegrationTest.kt Validates productDetails shape and variant/options consistency.
integration-test/src/androidTest/java/com/mindera/alfie/integrationtest/SearchProductsIntegrationTest.kt Validates searchProducts happy path and cursor pagination.
feature/plp/src/main/java/com/mindera/alfie/feature/plp/ProductListViewModel.kt Switches the BFF placeholder collection handle to frontpage.

Comment thread README.md Outdated
Comment thread integration-test/build.gradle.kts

val prices = response.products.map {
it.productListEntryFragment.priceRange.minVariantPrice.moneyFragment.amount
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

amount is a String from the GraphQL schema — .sorted() on a List<String> sorts lexicographically, not numerically. Prices like "9.99" and "10.00" will be misordered ('9' > '1'), so the test gives a false green whenever prices span a power-of-ten boundary.

val prices = response.products.map {
    it.productListEntryFragment.priceRange.minVariantPrice.moneyFragment.amount.toBigDecimal()
}
assertEquals(prices.sorted(), prices, "PRICE_ASC should return non-decreasing min prices")

@hoangnhatdrk hoangnhatdrk added this pull request to the merge queue Jun 25, 2026
Merged via the queue into main with commit 97da420 Jun 25, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants