Skip to content

Commit

Permalink
[BWA-113] [BWA-114] [BWA-71 ] Issues With Alphabetical Ordering of TO…
Browse files Browse the repository at this point in the history
…TP Items (#207)
  • Loading branch information
brant-livefront authored Dec 5, 2024
1 parent f8be504 commit 307d2bd
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ final class ItemListProcessor: StateProcessor<ItemListState, ItemListAction, Ite
showToast = true
}
let itemList = try await services.authenticatorItemRepository.refreshTotpCodes(on: section.items)
let sortedList = itemList.sorted { $0.name < $1.name }
let sortedList = itemList.sorted { $0.name.localizedStandardCompare($1.name) == .orderedAscending }
return ItemListSection(id: section.id, items: sortedList, name: section.name)
}
groupTotpExpirationManager?.configureTOTPRefreshScheduling(for: sectionList.flatMap(\.items))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -501,9 +501,17 @@ class ItemListProcessorTests: AuthenticatorTestCase { // swiftlint:disable:this
ItemListItem.fixture(name: "Beta"),
ItemListItem.fixture(name: "Delta"),
ItemListItem.fixture(name: "Alpha"),
ItemListItem.fixture(name: "beta"),
]
let resultsSorted = [
results[3], // Alpha
results[4], // beta
results[1], // Beta
results[2], // Delta
results[0], // Gamma
]
let resultSection = ItemListSection(id: "", items: results, name: "")
let resultSorted = ItemListSection(id: "", items: results.sorted(by: { $0.name < $1.name }), name: "")
let sortedSection = ItemListSection(id: "", items: resultsSorted, name: "")

authItemRepository.itemListSubject.send([resultSection])
authItemRepository.refreshTotpCodesResult = .success(results)
Expand All @@ -516,7 +524,7 @@ class ItemListProcessorTests: AuthenticatorTestCase { // swiftlint:disable:this
waitFor(subject.state.loadingState != .loading(nil))

XCTAssertEqual(authItemRepository.refreshedTotpCodes, results)
XCTAssertEqual(subject.state.loadingState, .data([resultSorted]))
XCTAssertEqual(subject.state.loadingState, .data([sortedSection]))
}

/// `perform(_:)` with `.streamItemList` starts streaming vault items. When there are shared items
Expand Down

0 comments on commit 307d2bd

Please sign in to comment.