fix(#26): ignore reflowed completed color rows
This commit is contained in:
+6
-1
@@ -531,7 +531,12 @@ class PddProductDetailCollector(
|
||||
screen.dimensions.filter { it.key == "unsupported" }.forEach { unsupported += it.name }
|
||||
val rows = colorRows(screen)
|
||||
if (rowIndex >= rows.size) {
|
||||
missing += "colorRow:${rowIndex + 1}"
|
||||
// Some PDD builds remove the selected option from the
|
||||
// clickable accessibility nodes and immediately reflow
|
||||
// the remaining options. A row disappearing after a
|
||||
// successful selection is therefore not evidence that
|
||||
// its values were missed. Real gaps are still reported
|
||||
// below as missing colors or prices.
|
||||
break
|
||||
}
|
||||
currentRow = rows[rowIndex].sortedBy { it.node.bounds.left }
|
||||
|
||||
@@ -343,6 +343,26 @@ class PddProductDetailCollectorTest {
|
||||
assertTrue(driver.swipes.any { it.first == SwipeDirection.UP && it.second != null })
|
||||
}
|
||||
|
||||
@Test
|
||||
fun selectedColorsDisappearingAndReflowingDoNotCreateFalseMissingRows() {
|
||||
val colors = listOf("A色", "B色", "C色")
|
||||
val driver = FakeCollectorDriver(
|
||||
colors = colors,
|
||||
prices = colors.associateWith { 1000L },
|
||||
rowSize = 2,
|
||||
hideSelectedColorOption = true,
|
||||
)
|
||||
var clock = 0L
|
||||
|
||||
val result = PddProductDetailCollector(driver, { clock }, { clock += it }).collect(GOODS_ID, rule())
|
||||
|
||||
assertTrue(result.successful)
|
||||
val payload = requireNotNull(result.payload)
|
||||
assertEquals("completed", payload.status)
|
||||
assertEquals(colors, payload.colorPrices.map { it.color })
|
||||
assertTrue(payload.missing.none { it.startsWith("colorRow:") })
|
||||
}
|
||||
|
||||
@Test
|
||||
fun sizesContinueAfterHeadingScrollsOutOfView() {
|
||||
val driver = FakeCollectorDriver(
|
||||
@@ -436,6 +456,7 @@ class PddProductDetailCollectorTest {
|
||||
private val specialText: String? = null,
|
||||
private val includeDangerousActions: Boolean = false,
|
||||
private val rowSize: Int = 4,
|
||||
private val hideSelectedColorOption: Boolean = false,
|
||||
private val hideDimensionHeadingsAfterFirstVerticalPage: Boolean = false,
|
||||
private val soldOutUntilPulls: Int = 0,
|
||||
) : PddCollectorDriver {
|
||||
@@ -468,7 +489,9 @@ class PddProductDetailCollectorTest {
|
||||
val continuationPage = hideDimensionHeadingsAfterFirstVerticalPage && verticalPage > 0
|
||||
if (!continuationPage) {
|
||||
nodes += node("scroll/color-heading", "颜色分类", 20, 400, 300, 450, parentPath = "scroll")
|
||||
colorPages[horizontalPage.coerceAtMost(colorPages.lastIndex)].forEachIndexed { index, color ->
|
||||
colorPages[horizontalPage.coerceAtMost(colorPages.lastIndex)]
|
||||
.filterNot { hideSelectedColorOption && it == selected }
|
||||
.forEachIndexed { index, color ->
|
||||
val row = index / rowSize
|
||||
val column = index % rowSize
|
||||
nodes += node(
|
||||
|
||||
Reference in New Issue
Block a user