mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-04 01:20:12 +00:00
Contact me added in Bug Report Screen (#1307)
* contact me added * fixing tests
This commit is contained in:
@@ -45,6 +45,7 @@ struct A11yIdentifiers {
|
|||||||
struct BugReportScreen {
|
struct BugReportScreen {
|
||||||
let report = "bug_report-report"
|
let report = "bug_report-report"
|
||||||
let sendLogs = "bug_report-send_logs"
|
let sendLogs = "bug_report-send_logs"
|
||||||
|
let canContact = "bug_report-can_contact"
|
||||||
let screenshot = "bug_report-screenshot"
|
let screenshot = "bug_report-screenshot"
|
||||||
let removeScreenshot = "bug_report-remove_screenshot"
|
let removeScreenshot = "bug_report-remove_screenshot"
|
||||||
let attachScreenshot = "bug-report-attach_screenshot"
|
let attachScreenshot = "bug-report-attach_screenshot"
|
||||||
|
|||||||
@@ -33,6 +33,7 @@ struct BugReportScreenViewState: BindableState {
|
|||||||
struct BugReportScreenViewStateBindings {
|
struct BugReportScreenViewStateBindings {
|
||||||
var reportText: String
|
var reportText: String
|
||||||
var sendingLogsEnabled: Bool
|
var sendingLogsEnabled: Bool
|
||||||
|
var canContact: Bool
|
||||||
}
|
}
|
||||||
|
|
||||||
enum BugReportScreenViewAction {
|
enum BugReportScreenViewAction {
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ class BugReportScreenViewModel: BugReportScreenViewModelType, BugReportScreenVie
|
|||||||
self.userID = userID
|
self.userID = userID
|
||||||
self.deviceID = deviceID
|
self.deviceID = deviceID
|
||||||
|
|
||||||
let bindings = BugReportScreenViewStateBindings(reportText: "", sendingLogsEnabled: true)
|
let bindings = BugReportScreenViewStateBindings(reportText: "", sendingLogsEnabled: true, canContact: false)
|
||||||
super.init(initialViewState: BugReportScreenViewState(screenshot: screenshot,
|
super.init(initialViewState: BugReportScreenViewState(screenshot: screenshot,
|
||||||
bindings: bindings,
|
bindings: bindings,
|
||||||
isModallyPresented: isModallyPresented))
|
isModallyPresented: isModallyPresented))
|
||||||
@@ -84,6 +84,7 @@ class BugReportScreenViewModel: BugReportScreenViewModelType, BugReportScreenVie
|
|||||||
text: context.reportText,
|
text: context.reportText,
|
||||||
includeLogs: context.sendingLogsEnabled,
|
includeLogs: context.sendingLogsEnabled,
|
||||||
includeCrashLog: true,
|
includeCrashLog: true,
|
||||||
|
canContact: context.canContact,
|
||||||
githubLabels: [],
|
githubLabels: [],
|
||||||
files: files)
|
files: files)
|
||||||
|
|
||||||
|
|||||||
@@ -26,10 +26,9 @@ struct BugReportScreen: View {
|
|||||||
var body: some View {
|
var body: some View {
|
||||||
Form {
|
Form {
|
||||||
textFieldSection
|
textFieldSection
|
||||||
|
|
||||||
attachScreenshotSection
|
attachScreenshotSection
|
||||||
|
|
||||||
sendLogsSection
|
sendLogsSection
|
||||||
|
canContactSection
|
||||||
}
|
}
|
||||||
.scrollDismissesKeyboard(.immediately)
|
.scrollDismissesKeyboard(.immediately)
|
||||||
.compoundForm()
|
.compoundForm()
|
||||||
@@ -77,6 +76,18 @@ struct BugReportScreen: View {
|
|||||||
.compoundFormSection()
|
.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
|
@ViewBuilder
|
||||||
private var attachScreenshotSection: some View {
|
private var attachScreenshotSection: some View {
|
||||||
Section {
|
Section {
|
||||||
|
|||||||
@@ -103,7 +103,8 @@ class BugReportService: NSObject, BugReportServiceProtocol {
|
|||||||
progressListener: CurrentValueSubject<Double, Never>) async -> Result<SubmitBugReportResponse, BugReportServiceError> {
|
progressListener: CurrentValueSubject<Double, Never>) async -> Result<SubmitBugReportResponse, BugReportServiceError> {
|
||||||
var params = [
|
var params = [
|
||||||
MultipartFormData(key: "user_id", type: .text(value: bugReport.userID)),
|
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 {
|
if let deviceID = bugReport.deviceID {
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ struct BugReport: Equatable {
|
|||||||
let text: String
|
let text: String
|
||||||
let includeLogs: Bool
|
let includeLogs: Bool
|
||||||
let includeCrashLog: Bool
|
let includeCrashLog: Bool
|
||||||
|
let canContact: Bool
|
||||||
let githubLabels: [String]
|
let githubLabels: [String]
|
||||||
let files: [URL]
|
let files: [URL]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,11 +32,13 @@ class BugReportUITests: XCTestCase {
|
|||||||
// Type 4 characters and the send button should be disabled.
|
// Type 4 characters and the send button should be disabled.
|
||||||
app.textViews[A11yIdentifiers.bugReportScreen.report].clearAndTypeText("Text")
|
app.textViews[A11yIdentifiers.bugReportScreen.report].clearAndTypeText("Text")
|
||||||
XCTAssert(app.switches[A11yIdentifiers.bugReportScreen.sendLogs].isOn)
|
XCTAssert(app.switches[A11yIdentifiers.bugReportScreen.sendLogs].isOn)
|
||||||
|
XCTAssert(!app.switches[A11yIdentifiers.bugReportScreen.canContact].isOn)
|
||||||
try await app.assertScreenshot(.bugReport, step: 2)
|
try await app.assertScreenshot(.bugReport, step: 2)
|
||||||
|
|
||||||
// Type more than 4 characters and send the button should become enabled.
|
// Type more than 4 characters and send the button should become enabled.
|
||||||
app.textViews[A11yIdentifiers.bugReportScreen.report].clearAndTypeText("Longer text")
|
app.textViews[A11yIdentifiers.bugReportScreen.report].clearAndTypeText("Longer text")
|
||||||
XCTAssert(app.switches[A11yIdentifiers.bugReportScreen.sendLogs].isOn)
|
XCTAssert(app.switches[A11yIdentifiers.bugReportScreen.sendLogs].isOn)
|
||||||
|
XCTAssert(!app.switches[A11yIdentifiers.bugReportScreen.canContact].isOn)
|
||||||
try await app.assertScreenshot(.bugReport, step: 3)
|
try await app.assertScreenshot(.bugReport, step: 3)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,3 @@
|
|||||||
version https://git-lfs.github.com/spec/v1
|
version https://git-lfs.github.com/spec/v1
|
||||||
oid sha256:91fa2db4be815bce136476867ba1d0026b4ebd55d2d6a38d2e696b0d5b426376
|
oid sha256:70935aa783ef9392f8a1160fb68af5b7bf16dea9709ce1a5f049bcf6276309f1
|
||||||
size 112889
|
size 126496
|
||||||
|
|||||||
@@ -1,3 +1,3 @@
|
|||||||
version https://git-lfs.github.com/spec/v1
|
version https://git-lfs.github.com/spec/v1
|
||||||
oid sha256:a7eef4aaf57e32e59fb8657dc963695297bb96ba2c9c6865965f5bcabc572e4a
|
oid sha256:16e201d435c12a555bbee2746ebc35f011c6d2bb3a20bacf87c3341f1b5b0229
|
||||||
size 179988
|
size 194229
|
||||||
|
|||||||
@@ -1,3 +1,3 @@
|
|||||||
version https://git-lfs.github.com/spec/v1
|
version https://git-lfs.github.com/spec/v1
|
||||||
oid sha256:2c650cc5cb2e4d206cdebb9b8c310792f2c75a3e933e33bc6a5d40dcc7299b97
|
oid sha256:d1eb3e91e264f86c6e9cded9159bbce88bd4bbe50242a609c37b514fdc2b0590
|
||||||
size 186963
|
size 201099
|
||||||
|
|||||||
+2
-2
@@ -1,3 +1,3 @@
|
|||||||
version https://git-lfs.github.com/spec/v1
|
version https://git-lfs.github.com/spec/v1
|
||||||
oid sha256:ff279aff4d3506bdd4c22135408e222dd63d6e9844e3f48b5a12addaad8e1006
|
oid sha256:6ee871f1bbee6b3b9208880b6d5b5da72422ffde72c6131dbaec96422b576caa
|
||||||
size 123928
|
size 137938
|
||||||
|
|||||||
@@ -1,3 +1,3 @@
|
|||||||
version https://git-lfs.github.com/spec/v1
|
version https://git-lfs.github.com/spec/v1
|
||||||
oid sha256:b2f9a2de429cf6a1d090553f92848523208d7d9691069c17e96fab746d5f4372
|
oid sha256:75b4447894f5d3b8278c6118dc41f7c99efa5626491894d0ab287ff89af7f9ef
|
||||||
size 145973
|
size 166816
|
||||||
|
|||||||
@@ -1,3 +1,3 @@
|
|||||||
version https://git-lfs.github.com/spec/v1
|
version https://git-lfs.github.com/spec/v1
|
||||||
oid sha256:bb24e61058620e4eb0746800805a9250aa219ad02a98b0f6640a583c6050cc68
|
oid sha256:6ab050acaee21d58c9afcf68fa7ee861c4d67cd87156aaf46f299ce23c49790d
|
||||||
size 203891
|
size 210535
|
||||||
|
|||||||
@@ -1,3 +1,3 @@
|
|||||||
version https://git-lfs.github.com/spec/v1
|
version https://git-lfs.github.com/spec/v1
|
||||||
oid sha256:8c394a15f13a0061b519ed3671ee36621dd641e6f8744a23070c96c94f44916f
|
oid sha256:e47165276d97ab3f740508db22c7cea02c9de7954eb4d556870242521a8271b3
|
||||||
size 209242
|
size 219096
|
||||||
|
|||||||
+2
-2
@@ -1,3 +1,3 @@
|
|||||||
version https://git-lfs.github.com/spec/v1
|
version https://git-lfs.github.com/spec/v1
|
||||||
oid sha256:e58b19c9f9b9b96787c8b016e2ecd3e154a300db9f87425cda2fd356eed9dbdb
|
oid sha256:55f92756942d4a336258c2b3f46eec47561f1a2e3dd1265756fdeb7c66c54205
|
||||||
size 159723
|
size 181095
|
||||||
|
|||||||
+2
-2
@@ -1,3 +1,3 @@
|
|||||||
version https://git-lfs.github.com/spec/v1
|
version https://git-lfs.github.com/spec/v1
|
||||||
oid sha256:854024a9b590fb08d3b931751581a39ac43c6ea42ac0d70da7d6885a0d1b7dc3
|
oid sha256:c807972e64f0977aca1a0db35ecbeda82aaf6452889473a9dcc197b6e976f757
|
||||||
size 142990
|
size 160832
|
||||||
|
|||||||
+2
-2
@@ -1,3 +1,3 @@
|
|||||||
version https://git-lfs.github.com/spec/v1
|
version https://git-lfs.github.com/spec/v1
|
||||||
oid sha256:d7787d75a219b2dbdd451cce93706f921c798f7f2babfe297ebd12f547b6e959
|
oid sha256:fd33425f8f03217992dbe5a9b8f5356c23c6360cabbe880f696d95eb1dd80049
|
||||||
size 209561
|
size 226953
|
||||||
|
|||||||
+2
-2
@@ -1,3 +1,3 @@
|
|||||||
version https://git-lfs.github.com/spec/v1
|
version https://git-lfs.github.com/spec/v1
|
||||||
oid sha256:966fe21fd6f8b54bcec71acbf66f073dc40645536ed30080edeab0c6fb9c23b6
|
oid sha256:bf757b59634c398a83226d31292c5667c74493434c7e3aea00b6dac73270b1e8
|
||||||
size 215546
|
size 232739
|
||||||
|
|||||||
+2
-2
@@ -1,3 +1,3 @@
|
|||||||
version https://git-lfs.github.com/spec/v1
|
version https://git-lfs.github.com/spec/v1
|
||||||
oid sha256:86f359ef40188f70a40345abea9421a4066c7fe0ae9c0e18fa3ec71b6ae12fa2
|
oid sha256:05aaadb39c04411e8d6aec7d486e59a22dd2995245fadbe7605faf7288f1daa8
|
||||||
size 153047
|
size 169803
|
||||||
|
|||||||
@@ -1,3 +1,3 @@
|
|||||||
version https://git-lfs.github.com/spec/v1
|
version https://git-lfs.github.com/spec/v1
|
||||||
oid sha256:9f815b83498f64348db9171f4c188231d5e7baf1f6d6a9b67d77761427073be7
|
oid sha256:0a56b27e07517a4492fde3e838ee817f511b05d47c40f98ca9eecc2134735817
|
||||||
size 204713
|
size 235551
|
||||||
|
|||||||
@@ -1,3 +1,3 @@
|
|||||||
version https://git-lfs.github.com/spec/v1
|
version https://git-lfs.github.com/spec/v1
|
||||||
oid sha256:c6edbff1d9a1aeef4d1eb24e7a8e8ded8be34e169538f92679f30445533ea2eb
|
oid sha256:5ded0d89aaaa438e2f7627e01ba763fcce9c5c50323625367f3c1c6807287564
|
||||||
size 215565
|
size 220367
|
||||||
|
|||||||
@@ -1,3 +1,3 @@
|
|||||||
version https://git-lfs.github.com/spec/v1
|
version https://git-lfs.github.com/spec/v1
|
||||||
oid sha256:7cf2c6ee69ac19781a2c56196c4e41c4c7b002726d56cbe272378b6b675c3a79
|
oid sha256:e93c55f85674a2698d8d8569dc86b49c2b7a474b4398b480d0188789984b06fb
|
||||||
size 221016
|
size 225752
|
||||||
|
|||||||
+2
-2
@@ -1,3 +1,3 @@
|
|||||||
version https://git-lfs.github.com/spec/v1
|
version https://git-lfs.github.com/spec/v1
|
||||||
oid sha256:a9ef30447288fadd2b27dfced005d848cd1229ca1ce07a4253f96dbe027fa443
|
oid sha256:ef8aaf01bff6866112fa5c34c53cce291811be26a12c6ec16011a92987074cb5
|
||||||
size 211129
|
size 239739
|
||||||
|
|||||||
@@ -39,6 +39,7 @@ class BugReportServiceTests: XCTestCase {
|
|||||||
text: "i cannot send message",
|
text: "i cannot send message",
|
||||||
includeLogs: true,
|
includeLogs: true,
|
||||||
includeCrashLog: true,
|
includeCrashLog: true,
|
||||||
|
canContact: false,
|
||||||
githubLabels: [],
|
githubLabels: [],
|
||||||
files: [])
|
files: [])
|
||||||
let progressSubject = CurrentValueSubject<Double, Never>(0.0)
|
let progressSubject = CurrentValueSubject<Double, Never>(0.0)
|
||||||
@@ -67,6 +68,7 @@ class BugReportServiceTests: XCTestCase {
|
|||||||
text: "i cannot send message",
|
text: "i cannot send message",
|
||||||
includeLogs: true,
|
includeLogs: true,
|
||||||
includeCrashLog: true,
|
includeCrashLog: true,
|
||||||
|
canContact: false,
|
||||||
githubLabels: [],
|
githubLabels: [],
|
||||||
files: [])
|
files: [])
|
||||||
let progressSubject = CurrentValueSubject<Double, Never>(0.0)
|
let progressSubject = CurrentValueSubject<Double, Never>(0.0)
|
||||||
|
|||||||
@@ -84,7 +84,7 @@ class BugReportViewModelTests: XCTestCase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
XCTAssert(mockService.submitBugReportProgressListenerCallsCount == 1)
|
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 {
|
func testSendReportWithError() async throws {
|
||||||
@@ -110,6 +110,6 @@ class BugReportViewModelTests: XCTestCase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
XCTAssert(mockService.submitBugReportProgressListenerCallsCount == 1)
|
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: []))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1 @@
|
|||||||
|
Contact Me switch added to the Bug Report screen.
|
||||||
Reference in New Issue
Block a user