|
|
@ -200,6 +200,7 @@ class ThreadDisappearingMessagesSettingsViewModelSpec: QuickSpec {
|
|
|
|
id: ThreadDisappearingMessagesSettingsViewModel.Item(
|
|
|
|
id: ThreadDisappearingMessagesSettingsViewModel.Item(
|
|
|
|
title: "DISAPPERING_MESSAGES_TYPE_AFTER_SEND_TITLE".localized()
|
|
|
|
title: "DISAPPERING_MESSAGES_TYPE_AFTER_SEND_TITLE".localized()
|
|
|
|
),
|
|
|
|
),
|
|
|
|
|
|
|
|
position: .bottom,
|
|
|
|
title: "DISAPPERING_MESSAGES_TYPE_AFTER_SEND_TITLE".localized(),
|
|
|
|
title: "DISAPPERING_MESSAGES_TYPE_AFTER_SEND_TITLE".localized(),
|
|
|
|
subtitle: "DISAPPERING_MESSAGES_TYPE_AFTER_SEND_DESCRIPTION".localized(),
|
|
|
|
subtitle: "DISAPPERING_MESSAGES_TYPE_AFTER_SEND_DESCRIPTION".localized(),
|
|
|
|
rightAccessory: .radio(
|
|
|
|
rightAccessory: .radio(
|
|
|
@ -216,7 +217,7 @@ class ThreadDisappearingMessagesSettingsViewModelSpec: QuickSpec {
|
|
|
|
let title: String = (DisappearingMessagesConfiguration.validDurationsSeconds(.disappearAfterSend).last?
|
|
|
|
let title: String = (DisappearingMessagesConfiguration.validDurationsSeconds(.disappearAfterSend).last?
|
|
|
|
.formatted(format: .long))
|
|
|
|
.formatted(format: .long))
|
|
|
|
.defaulting(to: "")
|
|
|
|
.defaulting(to: "")
|
|
|
|
expect(viewModel.tableData.first?.elements.last)
|
|
|
|
expect(viewModel.tableData.last?.elements.last)
|
|
|
|
.to(
|
|
|
|
.to(
|
|
|
|
equal(
|
|
|
|
equal(
|
|
|
|
SessionCell.Info(
|
|
|
|
SessionCell.Info(
|
|
|
@ -233,72 +234,99 @@ class ThreadDisappearingMessagesSettingsViewModelSpec: QuickSpec {
|
|
|
|
)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
it("has no footer button") {
|
|
|
|
|
|
|
|
var footerButtonInfo: SessionButton.Info?
|
|
|
|
|
|
|
|
|
|
|
|
context("change to another setting and change back") {
|
|
|
|
cancellables.append(
|
|
|
|
// Change to another setting
|
|
|
|
viewModel.footerButtonInfo
|
|
|
|
viewModel.tableData.first?.elements.first?.onTap?()
|
|
|
|
.receiveOnMain(immediately: true)
|
|
|
|
// Change back
|
|
|
|
.sink(
|
|
|
|
viewModel.tableData.first?.elements.last?.onTap?()
|
|
|
|
receiveCompletion: { _ in },
|
|
|
|
|
|
|
|
receiveValue: { info in footerButtonInfo = info }
|
|
|
|
it("shows the previous setting with no set button") {
|
|
|
|
)
|
|
|
|
expect(viewModel.tableData.first?.elements.last)
|
|
|
|
)
|
|
|
|
.to(
|
|
|
|
|
|
|
|
equal(
|
|
|
|
expect(footerButtonInfo).to(beNil())
|
|
|
|
SessionCell.Info(
|
|
|
|
}
|
|
|
|
id: ThreadDisappearingMessagesSettingsViewModel.Item(
|
|
|
|
|
|
|
|
title: "DISAPPERING_MESSAGES_TYPE_AFTER_SEND_TITLE".localized()
|
|
|
|
it("change to another setting and change back") {
|
|
|
|
),
|
|
|
|
// Test config: Disappear After Send - 2 weeks
|
|
|
|
title: "DISAPPERING_MESSAGES_TYPE_AFTER_SEND_TITLE".localized(),
|
|
|
|
let config: DisappearingMessagesConfiguration = DisappearingMessagesConfiguration
|
|
|
|
subtitle: "DISAPPERING_MESSAGES_TYPE_AFTER_SEND_DESCRIPTION".localized(),
|
|
|
|
.defaultWith("TestId")
|
|
|
|
rightAccessory: .radio(
|
|
|
|
.with(
|
|
|
|
isSelected: { true }
|
|
|
|
isEnabled: true,
|
|
|
|
),
|
|
|
|
durationSeconds: DisappearingMessagesConfiguration.validDurationsSeconds(.disappearAfterSend).last,
|
|
|
|
accessibility: Accessibility(
|
|
|
|
type: .disappearAfterSend
|
|
|
|
identifier: "Disappear after send option",
|
|
|
|
)
|
|
|
|
label: "Disappear after send option"
|
|
|
|
mockStorage.write { db in
|
|
|
|
)
|
|
|
|
_ = try config.saved(db)
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
viewModel = ThreadDisappearingMessagesSettingsViewModel(
|
|
|
|
|
|
|
|
dependencies: dependencies,
|
|
|
|
|
|
|
|
threadId: "TestId",
|
|
|
|
|
|
|
|
threadVariant: .contact,
|
|
|
|
|
|
|
|
currentUserIsClosedGroupMember: nil,
|
|
|
|
|
|
|
|
currentUserIsClosedGroupAdmin: nil,
|
|
|
|
|
|
|
|
config: config
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
cancellables.append(
|
|
|
|
|
|
|
|
viewModel.observableTableData
|
|
|
|
|
|
|
|
.receiveOnMain(immediately: true)
|
|
|
|
|
|
|
|
.sink(
|
|
|
|
|
|
|
|
receiveCompletion: { _ in },
|
|
|
|
|
|
|
|
receiveValue: { viewModel.updateTableData($0.0) }
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Change to another setting
|
|
|
|
|
|
|
|
viewModel.tableData.first?.elements.first?.onTap?()
|
|
|
|
|
|
|
|
// Change back
|
|
|
|
|
|
|
|
viewModel.tableData.first?.elements.last?.onTap?()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
expect(viewModel.tableData.first?.elements.last)
|
|
|
|
|
|
|
|
.to(
|
|
|
|
|
|
|
|
equal(
|
|
|
|
|
|
|
|
SessionCell.Info(
|
|
|
|
|
|
|
|
id: ThreadDisappearingMessagesSettingsViewModel.Item(
|
|
|
|
|
|
|
|
title: "DISAPPERING_MESSAGES_TYPE_AFTER_SEND_TITLE".localized()
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
position: .bottom,
|
|
|
|
|
|
|
|
title: "DISAPPERING_MESSAGES_TYPE_AFTER_SEND_TITLE".localized(),
|
|
|
|
|
|
|
|
subtitle: "DISAPPERING_MESSAGES_TYPE_AFTER_SEND_DESCRIPTION".localized(),
|
|
|
|
|
|
|
|
rightAccessory: .radio(
|
|
|
|
|
|
|
|
isSelected: { true }
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
accessibility: Accessibility(
|
|
|
|
|
|
|
|
identifier: "Disappear after send option",
|
|
|
|
|
|
|
|
label: "Disappear after send option"
|
|
|
|
)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
)
|
|
|
|
let title: String = (DisappearingMessagesConfiguration.validDurationsSeconds(.disappearAfterSend).last?
|
|
|
|
)
|
|
|
|
.formatted(format: .long))
|
|
|
|
|
|
|
|
.defaulting(to: "")
|
|
|
|
let title: String = (DisappearingMessagesConfiguration.validDurationsSeconds(.disappearAfterSend).last?
|
|
|
|
expect(viewModel.tableData.first?.elements.last)
|
|
|
|
.formatted(format: .long))
|
|
|
|
.to(
|
|
|
|
.defaulting(to: "")
|
|
|
|
equal(
|
|
|
|
expect(viewModel.tableData.last?.elements.last)
|
|
|
|
SessionCell.Info(
|
|
|
|
.to(
|
|
|
|
id: ThreadDisappearingMessagesSettingsViewModel.Item(title: title),
|
|
|
|
equal(
|
|
|
|
position: .bottom,
|
|
|
|
SessionCell.Info(
|
|
|
|
title: title,
|
|
|
|
id: ThreadDisappearingMessagesSettingsViewModel.Item(title: title),
|
|
|
|
rightAccessory: .radio(
|
|
|
|
position: .bottom,
|
|
|
|
isSelected: { true }
|
|
|
|
title: title,
|
|
|
|
),
|
|
|
|
rightAccessory: .radio(
|
|
|
|
accessibility: Accessibility(
|
|
|
|
isSelected: { true }
|
|
|
|
identifier: "Time option",
|
|
|
|
),
|
|
|
|
label: "Time option"
|
|
|
|
accessibility: Accessibility(
|
|
|
|
)
|
|
|
|
identifier: "Time option",
|
|
|
|
)
|
|
|
|
label: "Time option"
|
|
|
|
)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
var footerButtonInfo: SessionButton.Info?
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
cancellables.append(
|
|
|
|
|
|
|
|
viewModel.footerButtonInfo
|
|
|
|
|
|
|
|
.receiveOnMain(immediately: true)
|
|
|
|
|
|
|
|
.sink(
|
|
|
|
|
|
|
|
receiveCompletion: { _ in },
|
|
|
|
|
|
|
|
receiveValue: { info in footerButtonInfo = info }
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
)
|
|
|
|
expect(footerButtonInfo).to(beNil())
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
it("has no footer button") {
|
|
|
|
|
|
|
|
var footerButtonInfo: SessionButton.Info?
|
|
|
|
var footerButtonInfo: SessionButton.Info?
|
|
|
|
|
|
|
|
|
|
|
|
cancellables.append(
|
|
|
|
cancellables.append(
|
|
|
@ -337,7 +365,10 @@ class ThreadDisappearingMessagesSettingsViewModelSpec: QuickSpec {
|
|
|
|
style: .bordered,
|
|
|
|
style: .bordered,
|
|
|
|
title: "DISAPPERING_MESSAGES_SAVE_TITLE".localized(),
|
|
|
|
title: "DISAPPERING_MESSAGES_SAVE_TITLE".localized(),
|
|
|
|
isEnabled: true,
|
|
|
|
isEnabled: true,
|
|
|
|
accessibilityIdentifier: "Set button",
|
|
|
|
accessibility: Accessibility(
|
|
|
|
|
|
|
|
identifier: "Set button",
|
|
|
|
|
|
|
|
label: "Set button"
|
|
|
|
|
|
|
|
),
|
|
|
|
minWidth: 110,
|
|
|
|
minWidth: 110,
|
|
|
|
onTap: {}
|
|
|
|
onTap: {}
|
|
|
|
)
|
|
|
|
)
|
|
|
@ -381,7 +412,7 @@ class ThreadDisappearingMessagesSettingsViewModelSpec: QuickSpec {
|
|
|
|
)
|
|
|
|
)
|
|
|
|
expect(updatedConfig?.durationSeconds)
|
|
|
|
expect(updatedConfig?.durationSeconds)
|
|
|
|
.toEventually(
|
|
|
|
.toEventually(
|
|
|
|
equal(DisappearingMessagesConfiguration.validDurationsSeconds(.disappearAfterSend).last ?? -1),
|
|
|
|
equal(DisappearingMessagesConfiguration.DefaultDuration.disappearAfterSend.seconds),
|
|
|
|
timeout: .milliseconds(100)
|
|
|
|
timeout: .milliseconds(100)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
expect(updatedConfig?.type)
|
|
|
|
expect(updatedConfig?.type)
|
|
|
|