mirror of
https://github.com/element-hq/element-x-ios.git
synced 2025-03-10 21:39:12 +00:00
Contact me added in Bug Report Screen (#1307)
* contact me added * fixing tests
This commit is contained in:
parent
98e7489aaf
commit
c573892954
@ -45,6 +45,7 @@ struct A11yIdentifiers {
|
||||
struct BugReportScreen {
|
||||
let report = "bug_report-report"
|
||||
let sendLogs = "bug_report-send_logs"
|
||||
let canContact = "bug_report-can_contact"
|
||||
let screenshot = "bug_report-screenshot"
|
||||
let removeScreenshot = "bug_report-remove_screenshot"
|
||||
let attachScreenshot = "bug-report-attach_screenshot"
|
||||
|
@ -33,6 +33,7 @@ struct BugReportScreenViewState: BindableState {
|
||||
struct BugReportScreenViewStateBindings {
|
||||
var reportText: String
|
||||
var sendingLogsEnabled: Bool
|
||||
var canContact: Bool
|
||||
}
|
||||
|
||||
enum BugReportScreenViewAction {
|
||||
|
@ -38,7 +38,7 @@ class BugReportScreenViewModel: BugReportScreenViewModelType, BugReportScreenVie
|
||||
self.userID = userID
|
||||
self.deviceID = deviceID
|
||||
|
||||
let bindings = BugReportScreenViewStateBindings(reportText: "", sendingLogsEnabled: true)
|
||||
let bindings = BugReportScreenViewStateBindings(reportText: "", sendingLogsEnabled: true, canContact: false)
|
||||
super.init(initialViewState: BugReportScreenViewState(screenshot: screenshot,
|
||||
bindings: bindings,
|
||||
isModallyPresented: isModallyPresented))
|
||||
@ -84,6 +84,7 @@ class BugReportScreenViewModel: BugReportScreenViewModelType, BugReportScreenVie
|
||||
text: context.reportText,
|
||||
includeLogs: context.sendingLogsEnabled,
|
||||
includeCrashLog: true,
|
||||
canContact: context.canContact,
|
||||
githubLabels: [],
|
||||
files: files)
|
||||
|
||||
|
@ -26,10 +26,9 @@ struct BugReportScreen: View {
|
||||
var body: some View {
|
||||
Form {
|
||||
textFieldSection
|
||||
|
||||
attachScreenshotSection
|
||||
|
||||
sendLogsSection
|
||||
canContactSection
|
||||
}
|
||||
.scrollDismissesKeyboard(.immediately)
|
||||
.compoundForm()
|
||||
@ -77,6 +76,18 @@ struct BugReportScreen: View {
|
||||
.compoundFormSection()
|
||||
}
|
||||
|
||||
private var canContactSection: some View {
|
||||
Section {
|
||||
Toggle(L10n.screenBugReportContactMeTitle, isOn: $context.canContact)
|
||||
.toggleStyle(.compoundForm)
|
||||
.accessibilityIdentifier(A11yIdentifiers.bugReportScreen.canContact)
|
||||
} footer: {
|
||||
Text(L10n.screenBugReportContactMe)
|
||||
.compoundFormSectionFooter()
|
||||
}
|
||||
.compoundFormSection()
|
||||
}
|
||||
|
||||
@ViewBuilder
|
||||
private var attachScreenshotSection: some View {
|
||||
Section {
|
||||
|
@ -103,7 +103,8 @@ class BugReportService: NSObject, BugReportServiceProtocol {
|
||||
progressListener: CurrentValueSubject<Double, Never>) async -> Result<SubmitBugReportResponse, BugReportServiceError> {
|
||||
var params = [
|
||||
MultipartFormData(key: "user_id", type: .text(value: bugReport.userID)),
|
||||
MultipartFormData(key: "text", type: .text(value: bugReport.text))
|
||||
MultipartFormData(key: "text", type: .text(value: bugReport.text)),
|
||||
MultipartFormData(key: "can_contact", type: .text(value: "\(bugReport.canContact)"))
|
||||
]
|
||||
|
||||
if let deviceID = bugReport.deviceID {
|
||||
|
@ -24,6 +24,7 @@ struct BugReport: Equatable {
|
||||
let text: String
|
||||
let includeLogs: Bool
|
||||
let includeCrashLog: Bool
|
||||
let canContact: Bool
|
||||
let githubLabels: [String]
|
||||
let files: [URL]
|
||||
}
|
||||
|
@ -32,11 +32,13 @@ class BugReportUITests: XCTestCase {
|
||||
// Type 4 characters and the send button should be disabled.
|
||||
app.textViews[A11yIdentifiers.bugReportScreen.report].clearAndTypeText("Text")
|
||||
XCTAssert(app.switches[A11yIdentifiers.bugReportScreen.sendLogs].isOn)
|
||||
XCTAssert(!app.switches[A11yIdentifiers.bugReportScreen.canContact].isOn)
|
||||
try await app.assertScreenshot(.bugReport, step: 2)
|
||||
|
||||
// Type more than 4 characters and send the button should become enabled.
|
||||
app.textViews[A11yIdentifiers.bugReportScreen.report].clearAndTypeText("Longer text")
|
||||
XCTAssert(app.switches[A11yIdentifiers.bugReportScreen.sendLogs].isOn)
|
||||
XCTAssert(!app.switches[A11yIdentifiers.bugReportScreen.canContact].isOn)
|
||||
try await app.assertScreenshot(.bugReport, step: 3)
|
||||
}
|
||||
|
||||
|
BIN
UITests/Sources/__Snapshots__/Application/en-GB-iPad-9th-generation.bugReport-0.png
(Stored with Git LFS)
BIN
UITests/Sources/__Snapshots__/Application/en-GB-iPad-9th-generation.bugReport-0.png
(Stored with Git LFS)
Binary file not shown.
BIN
UITests/Sources/__Snapshots__/Application/en-GB-iPad-9th-generation.bugReport-2.png
(Stored with Git LFS)
BIN
UITests/Sources/__Snapshots__/Application/en-GB-iPad-9th-generation.bugReport-2.png
(Stored with Git LFS)
Binary file not shown.
BIN
UITests/Sources/__Snapshots__/Application/en-GB-iPad-9th-generation.bugReport-3.png
(Stored with Git LFS)
BIN
UITests/Sources/__Snapshots__/Application/en-GB-iPad-9th-generation.bugReport-3.png
(Stored with Git LFS)
Binary file not shown.
BIN
UITests/Sources/__Snapshots__/Application/en-GB-iPad-9th-generation.bugReportWithScreenshot.png
(Stored with Git LFS)
BIN
UITests/Sources/__Snapshots__/Application/en-GB-iPad-9th-generation.bugReportWithScreenshot.png
(Stored with Git LFS)
Binary file not shown.
BIN
UITests/Sources/__Snapshots__/Application/en-GB-iPhone-14.bugReport-0.png
(Stored with Git LFS)
BIN
UITests/Sources/__Snapshots__/Application/en-GB-iPhone-14.bugReport-0.png
(Stored with Git LFS)
Binary file not shown.
BIN
UITests/Sources/__Snapshots__/Application/en-GB-iPhone-14.bugReport-2.png
(Stored with Git LFS)
BIN
UITests/Sources/__Snapshots__/Application/en-GB-iPhone-14.bugReport-2.png
(Stored with Git LFS)
Binary file not shown.
BIN
UITests/Sources/__Snapshots__/Application/en-GB-iPhone-14.bugReport-3.png
(Stored with Git LFS)
BIN
UITests/Sources/__Snapshots__/Application/en-GB-iPhone-14.bugReport-3.png
(Stored with Git LFS)
Binary file not shown.
BIN
UITests/Sources/__Snapshots__/Application/en-GB-iPhone-14.bugReportWithScreenshot.png
(Stored with Git LFS)
BIN
UITests/Sources/__Snapshots__/Application/en-GB-iPhone-14.bugReportWithScreenshot.png
(Stored with Git LFS)
Binary file not shown.
BIN
UITests/Sources/__Snapshots__/Application/pseudo-iPad-9th-generation.bugReport-0.png
(Stored with Git LFS)
BIN
UITests/Sources/__Snapshots__/Application/pseudo-iPad-9th-generation.bugReport-0.png
(Stored with Git LFS)
Binary file not shown.
BIN
UITests/Sources/__Snapshots__/Application/pseudo-iPad-9th-generation.bugReport-2.png
(Stored with Git LFS)
BIN
UITests/Sources/__Snapshots__/Application/pseudo-iPad-9th-generation.bugReport-2.png
(Stored with Git LFS)
Binary file not shown.
BIN
UITests/Sources/__Snapshots__/Application/pseudo-iPad-9th-generation.bugReport-3.png
(Stored with Git LFS)
BIN
UITests/Sources/__Snapshots__/Application/pseudo-iPad-9th-generation.bugReport-3.png
(Stored with Git LFS)
Binary file not shown.
BIN
UITests/Sources/__Snapshots__/Application/pseudo-iPad-9th-generation.bugReportWithScreenshot.png
(Stored with Git LFS)
BIN
UITests/Sources/__Snapshots__/Application/pseudo-iPad-9th-generation.bugReportWithScreenshot.png
(Stored with Git LFS)
Binary file not shown.
BIN
UITests/Sources/__Snapshots__/Application/pseudo-iPhone-14.bugReport-0.png
(Stored with Git LFS)
BIN
UITests/Sources/__Snapshots__/Application/pseudo-iPhone-14.bugReport-0.png
(Stored with Git LFS)
Binary file not shown.
BIN
UITests/Sources/__Snapshots__/Application/pseudo-iPhone-14.bugReport-2.png
(Stored with Git LFS)
BIN
UITests/Sources/__Snapshots__/Application/pseudo-iPhone-14.bugReport-2.png
(Stored with Git LFS)
Binary file not shown.
BIN
UITests/Sources/__Snapshots__/Application/pseudo-iPhone-14.bugReport-3.png
(Stored with Git LFS)
BIN
UITests/Sources/__Snapshots__/Application/pseudo-iPhone-14.bugReport-3.png
(Stored with Git LFS)
Binary file not shown.
BIN
UITests/Sources/__Snapshots__/Application/pseudo-iPhone-14.bugReportWithScreenshot.png
(Stored with Git LFS)
BIN
UITests/Sources/__Snapshots__/Application/pseudo-iPhone-14.bugReportWithScreenshot.png
(Stored with Git LFS)
Binary file not shown.
@ -39,6 +39,7 @@ class BugReportServiceTests: XCTestCase {
|
||||
text: "i cannot send message",
|
||||
includeLogs: true,
|
||||
includeCrashLog: true,
|
||||
canContact: false,
|
||||
githubLabels: [],
|
||||
files: [])
|
||||
let progressSubject = CurrentValueSubject<Double, Never>(0.0)
|
||||
@ -67,6 +68,7 @@ class BugReportServiceTests: XCTestCase {
|
||||
text: "i cannot send message",
|
||||
includeLogs: true,
|
||||
includeCrashLog: true,
|
||||
canContact: false,
|
||||
githubLabels: [],
|
||||
files: [])
|
||||
let progressSubject = CurrentValueSubject<Double, Never>(0.0)
|
||||
|
@ -84,7 +84,7 @@ class BugReportViewModelTests: XCTestCase {
|
||||
}
|
||||
|
||||
XCTAssert(mockService.submitBugReportProgressListenerCallsCount == 1)
|
||||
XCTAssert(mockService.submitBugReportProgressListenerReceivedArguments?.bugReport == BugReport(userID: "@mock.client.com", deviceID: nil, text: "", includeLogs: true, includeCrashLog: true, githubLabels: [], files: []))
|
||||
XCTAssert(mockService.submitBugReportProgressListenerReceivedArguments?.bugReport == BugReport(userID: "@mock.client.com", deviceID: nil, text: "", includeLogs: true, includeCrashLog: true, canContact: false, githubLabels: [], files: []))
|
||||
}
|
||||
|
||||
func testSendReportWithError() async throws {
|
||||
@ -110,6 +110,6 @@ class BugReportViewModelTests: XCTestCase {
|
||||
}
|
||||
|
||||
XCTAssert(mockService.submitBugReportProgressListenerCallsCount == 1)
|
||||
XCTAssert(mockService.submitBugReportProgressListenerReceivedArguments?.bugReport == BugReport(userID: "@mock.client.com", deviceID: nil, text: "", includeLogs: true, includeCrashLog: true, githubLabels: [], files: []))
|
||||
XCTAssert(mockService.submitBugReportProgressListenerReceivedArguments?.bugReport == BugReport(userID: "@mock.client.com", deviceID: nil, text: "", includeLogs: true, includeCrashLog: true, canContact: false, githubLabels: [], files: []))
|
||||
}
|
||||
}
|
||||
|
1
changelog.d/1299.feature
Normal file
1
changelog.d/1299.feature
Normal file
@ -0,0 +1 @@
|
||||
Contact Me switch added to the Bug Report screen.
|
Loading…
x
Reference in New Issue
Block a user