Skip to content

Commit b37f7a5

Browse files
committed
Fix unsupported condition detection in timeline subcomponents
1 parent fdac76d commit b37f7a5

2 files changed

Lines changed: 97 additions & 1 deletion

File tree

RevenueCatUI/Templates/V2/ViewModelHelpers/PresentedPartials.swift

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,12 @@ extension PaywallComponent.TimelineComponent {
393393

394394
func containsUnsupportedConditions() -> Bool {
395395
(overrides?.hasUnsupportedCondition() == true) ||
396-
items.contains(where: { $0.overrides?.hasUnsupportedCondition() == true })
396+
items.contains(where: {
397+
($0.overrides?.hasUnsupportedCondition() == true) ||
398+
($0.title.overrides?.hasUnsupportedCondition() == true) ||
399+
($0.description?.overrides?.hasUnsupportedCondition() == true) ||
400+
($0.icon.overrides?.hasUnsupportedCondition() == true)
401+
})
397402
}
398403

399404
}

Tests/RevenueCatUITests/PaywallsV2/ToPresentedOverridesTests.swift

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,36 @@ class ToPresentedOverridesTests: TestCase {
237237
expect(tabs.containsUnsupportedConditions()).to(beFalse())
238238
}
239239

240+
func testTimelineWithUnsupportedConditionInTitle_ReturnsTrue() throws {
241+
let timeline = self.makeTimeline(
242+
titleOverrides: [
243+
.init(extendedConditions: [.unsupported], properties: .init())
244+
]
245+
)
246+
247+
expect(timeline.containsUnsupportedConditions()).to(beTrue())
248+
}
249+
250+
func testTimelineWithUnsupportedConditionInDescription_ReturnsTrue() throws {
251+
let timeline = self.makeTimeline(
252+
descriptionOverrides: [
253+
.init(extendedConditions: [.unsupported], properties: .init())
254+
]
255+
)
256+
257+
expect(timeline.containsUnsupportedConditions()).to(beTrue())
258+
}
259+
260+
func testTimelineWithUnsupportedConditionInIcon_ReturnsTrue() throws {
261+
let timeline = self.makeTimeline(
262+
iconOverrides: [
263+
.init(extendedConditions: [.unsupported], properties: .init())
264+
]
265+
)
266+
267+
expect(timeline.containsUnsupportedConditions()).to(beTrue())
268+
}
269+
240270
func testButtonWithUnsupportedConditionInStack_ReturnsTrue() throws {
241271
let button = PaywallComponent.ButtonComponent(
242272
action: .restorePurchases,
@@ -508,6 +538,67 @@ class ToPresentedOverridesTests: TestCase {
508538
expect(result.count).to(equal(3))
509539
}
510540

541+
private func makeTimeline(
542+
titleOverrides: PaywallComponent.ComponentOverrides<PaywallComponent.PartialTextComponent>? = nil,
543+
descriptionOverrides: PaywallComponent.ComponentOverrides<PaywallComponent.PartialTextComponent>? = nil,
544+
iconOverrides: PaywallComponent.ComponentOverrides<PaywallComponent.PartialIconComponent>? = nil
545+
) -> PaywallComponent.TimelineComponent {
546+
let title = PaywallComponent.TextComponent(
547+
text: "text_1",
548+
color: .init(light: .hex("#000000")),
549+
overrides: titleOverrides
550+
)
551+
552+
let description: PaywallComponent.TextComponent? = descriptionOverrides.map { overrides in
553+
.init(
554+
text: "text_1",
555+
color: .init(light: .hex("#000000")),
556+
overrides: overrides
557+
)
558+
}
559+
560+
let icon = PaywallComponent.IconComponent(
561+
baseUrl: "https://revenuecat.com",
562+
iconName: "icon",
563+
formats: .init(
564+
svg: "icon.svg",
565+
png: "icon.png",
566+
heic: "icon.heic",
567+
webp: "icon.webp"
568+
),
569+
size: .init(width: .fit, height: .fit),
570+
padding: .zero,
571+
margin: .zero,
572+
color: .init(light: .hex("#000000")),
573+
iconBackground: nil,
574+
overrides: iconOverrides
575+
)
576+
577+
let item = PaywallComponent.TimelineComponent.Item(
578+
title: title,
579+
description: description,
580+
icon: icon,
581+
connector: .init(
582+
width: 1,
583+
color: .init(light: .hex("#000000")),
584+
margin: .zero
585+
),
586+
overrides: nil
587+
)
588+
589+
return .init(
590+
iconAlignment: nil,
591+
itemSpacing: nil,
592+
textSpacing: nil,
593+
columnGutter: nil,
594+
size: .init(width: .fill, height: .fit),
595+
padding: .zero,
596+
margin: .zero,
597+
items: [item],
598+
overrides: nil
599+
)
600+
}
601+
511602
}
512603

513604
#endif

0 commit comments

Comments
 (0)