package com.peachpasswords.autofill import org.junit.Assert.assertEquals import org.junit.Assert.assertNull import org.junit.Test /** * Which inline spec hosts the "Search Peach…" chip. * * v2.14.6 collision fix (holds): with a single inline spec and an OTP chip * eligible, both chips would target specs[0] and the picker dataset -- added * last -- would clobber the 2FA chip. The picker drops to the system menu so * the OTP chip keeps the lone slot. * * v2.14.8 refinement: without an OTP chip the stale two-slot reservation * left the last spec empty (and with 2 specs the entry budget at zero). The * picker now anchors the last slot itself when no 2FA chip is eligible. */ class AutofillPickerSpecSelectionTest { private val a = "spec-A" private val b = "spec-B" private val c = "spec-C" private val d = "spec-D" // --- no 2FA chip: picker anchors the last slot (v2.14.8) --- @Test fun empty_specs_yield_null_picker() { assertNull(pickerSpecFor(emptyList(), otpEligible = false)) assertNull(pickerSpecFor(emptyList(), otpEligible = true)) } @Test fun single_spec_goes_to_the_picker_when_no_otp_chip() { assertEquals(a, pickerSpecFor(listOf(a), otpEligible = false)) } @Test fun without_otp_the_picker_takes_the_last_slot() { assertEquals(b, pickerSpecFor(listOf(a, b), otpEligible = false)) assertEquals(c, pickerSpecFor(listOf(a, b, c), otpEligible = false)) assertEquals(d, pickerSpecFor(listOf(a, b, c, d), otpEligible = false)) } // --- with a 2FA chip: picker sits just before the OTP slot (v2.14.6) --- @Test fun single_spec_yields_null_picker_so_otp_keeps_the_slot() { assertNull(pickerSpecFor(listOf(a), otpEligible = true)) } @Test fun with_otp_the_picker_sits_before_the_2fa_slot() { assertEquals(a, pickerSpecFor(listOf(a, b), otpEligible = true)) assertEquals(b, pickerSpecFor(listOf(a, b, c), otpEligible = true)) assertEquals(c, pickerSpecFor(listOf(a, b, c, d), otpEligible = true)) } }