Skip to content

Commit f0d00fe

Browse files
committed
설정화면 UITest
- 기록 백업/복원 테스트 - 알림 설정 시간 변경 테스트 - 개인정보 처리 방침 이동 테스트
1 parent 5b48726 commit f0d00fe

9 files changed

+209
-74
lines changed

PlantingMind/PlantingMind.xcodeproj/project.pbxproj

+8-4
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
7B34415D2BA1B87A00DA43F6 /* MonthPickerViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7B34415C2BA1B87A00DA43F6 /* MonthPickerViewModel.swift */; };
2626
7B34415F2BA1F85600DA43F6 /* MonthPickerViewModelTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7B34415E2BA1F85600DA43F6 /* MonthPickerViewModelTests.swift */; };
2727
7B3FA1BF2BCFDE6C007C3633 /* PlantingMindUITests_MoodRecord.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7B3FA1BE2BCFDE6C007C3633 /* PlantingMindUITests_MoodRecord.swift */; };
28+
7B3FA1C12BCFDEF0007C3633 /* PlantingMindUITests_Settings.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7B3FA1C02BCFDEF0007C3633 /* PlantingMindUITests_Settings.swift */; };
2829
7B4C07B62BB6B42E00B60CCD /* MoodAnalysisModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7B4C07B52BB6B42E00B60CCD /* MoodAnalysisModel.swift */; };
2930
7B4C07B82BB6B6B200B60CCD /* AnalysisView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7B4C07B72BB6B6B200B60CCD /* AnalysisView.swift */; };
3031
7B4C07BC2BB6C1F200B60CCD /* AnalysisViewModelTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7B4C07BB2BB6C1F200B60CCD /* AnalysisViewModelTests.swift */; };
@@ -69,6 +70,7 @@
6970
7BA66A8B2BCFEC21009BD9E8 /* AccessibilityIdentifiers.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7BA66A892BCFEB41009BD9E8 /* AccessibilityIdentifiers.swift */; };
7071
7BA66A8D2BCFFB0D009BD9E8 /* XCTestsExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7BA66A8C2BCFFB0D009BD9E8 /* XCTestsExtension.swift */; };
7172
7BA66A922BD00C0F009BD9E8 /* Localizable.xcstrings in Resources */ = {isa = PBXBuildFile; fileRef = 7B95D1792BA1645C00484F9D /* Localizable.xcstrings */; };
73+
7BA66A942BD0DCCE009BD9E8 /* LocalizedHelper.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7BA66A932BD0DCCE009BD9E8 /* LocalizedHelper.swift */; };
7274
7BAB04F42B9466BC00948CF2 /* Mood.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7BAB04F32B9466BC00948CF2 /* Mood.swift */; };
7375
7BAB04F62B946B8700948CF2 /* MoodRecordViewModelTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7BAB04F52B946B8700948CF2 /* MoodRecordViewModelTests.swift */; };
7476
7BABB0112B5F850200EEEEBB /* ColorExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7BABB0102B5F850200EEEEBB /* ColorExtension.swift */; };
@@ -78,7 +80,6 @@
7880
7BC300F72B5E525900059068 /* CalendarModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7BC300F62B5E525900059068 /* CalendarModel.swift */; };
7981
7BC300F92B5E5F8E00059068 /* CalendarViewModelTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7BC300F82B5E5F8E00059068 /* CalendarViewModelTests.swift */; };
8082
7BDA3CD72B58F25F006D74FB /* CalendarHeaderView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7BDA3CD62B58F25F006D74FB /* CalendarHeaderView.swift */; };
81-
7BE2475F2BCA3CA900DD3B76 /* PrivacyPolicyWebview.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7BE2475E2BCA3CA900DD3B76 /* PrivacyPolicyWebview.swift */; };
8283
/* End PBXBuildFile section */
8384

8485
/* Begin PBXContainerItemProxy section */
@@ -139,6 +140,7 @@
139140
7B34415C2BA1B87A00DA43F6 /* MonthPickerViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MonthPickerViewModel.swift; sourceTree = "<group>"; };
140141
7B34415E2BA1F85600DA43F6 /* MonthPickerViewModelTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MonthPickerViewModelTests.swift; sourceTree = "<group>"; };
141142
7B3FA1BE2BCFDE6C007C3633 /* PlantingMindUITests_MoodRecord.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PlantingMindUITests_MoodRecord.swift; sourceTree = "<group>"; };
143+
7B3FA1C02BCFDEF0007C3633 /* PlantingMindUITests_Settings.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PlantingMindUITests_Settings.swift; sourceTree = "<group>"; };
142144
7B4C07B52BB6B42E00B60CCD /* MoodAnalysisModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MoodAnalysisModel.swift; sourceTree = "<group>"; };
143145
7B4C07B72BB6B6B200B60CCD /* AnalysisView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AnalysisView.swift; sourceTree = "<group>"; };
144146
7B4C07BB2BB6C1F200B60CCD /* AnalysisViewModelTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AnalysisViewModelTests.swift; sourceTree = "<group>"; };
@@ -178,6 +180,7 @@
178180
7BA079912BAAD5EA009B5E46 /* PlantingWidgetExtension.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = PlantingWidgetExtension.entitlements; sourceTree = "<group>"; };
179181
7BA66A892BCFEB41009BD9E8 /* AccessibilityIdentifiers.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AccessibilityIdentifiers.swift; sourceTree = "<group>"; };
180182
7BA66A8C2BCFFB0D009BD9E8 /* XCTestsExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = XCTestsExtension.swift; sourceTree = "<group>"; };
183+
7BA66A932BD0DCCE009BD9E8 /* LocalizedHelper.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LocalizedHelper.swift; sourceTree = "<group>"; };
181184
7BAB04F32B9466BC00948CF2 /* Mood.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Mood.swift; sourceTree = "<group>"; };
182185
7BAB04F52B946B8700948CF2 /* MoodRecordViewModelTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MoodRecordViewModelTests.swift; sourceTree = "<group>"; };
183186
7BABB0102B5F850200EEEEBB /* ColorExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ColorExtension.swift; sourceTree = "<group>"; };
@@ -186,7 +189,6 @@
186189
7BC300F62B5E525900059068 /* CalendarModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CalendarModel.swift; sourceTree = "<group>"; };
187190
7BC300F82B5E5F8E00059068 /* CalendarViewModelTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CalendarViewModelTests.swift; sourceTree = "<group>"; };
188191
7BDA3CD62B58F25F006D74FB /* CalendarHeaderView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CalendarHeaderView.swift; sourceTree = "<group>"; };
189-
7BE2475E2BCA3CA900DD3B76 /* PrivacyPolicyWebview.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PrivacyPolicyWebview.swift; sourceTree = "<group>"; };
190192
/* End PBXFileReference section */
191193

192194
/* Begin PBXFrameworksBuildPhase section */
@@ -333,7 +335,9 @@
333335
children = (
334336
7B11F8422B4549E000346A41 /* PlantingMindUITests_Calendar.swift */,
335337
7B3FA1BE2BCFDE6C007C3633 /* PlantingMindUITests_MoodRecord.swift */,
338+
7B3FA1C02BCFDEF0007C3633 /* PlantingMindUITests_Settings.swift */,
336339
7BA66A8C2BCFFB0D009BD9E8 /* XCTestsExtension.swift */,
340+
7BA66A932BD0DCCE009BD9E8 /* LocalizedHelper.swift */,
337341
);
338342
path = PlantingMindUITests;
339343
sourceTree = "<group>";
@@ -419,7 +423,6 @@
419423
children = (
420424
7B786A722BCD09FE005D69A0 /* Notification */,
421425
7B9F19F52BC694BF0063E613 /* MindDocument.swift */,
422-
7BE2475E2BCA3CA900DD3B76 /* PrivacyPolicyWebview.swift */,
423426
7B9F19EF2BC528980063E613 /* SettingsView.swift */,
424427
7B9F19F12BC52FED0063E613 /* SettingsViewModel.swift */,
425428
);
@@ -663,7 +666,6 @@
663666
7BC300F52B5E4CE100059068 /* CalendarView.swift in Sources */,
664667
7B2CFC1D2B5A6FFB00641F6D /* CalendarGridView.swift in Sources */,
665668
7B661C382B6393880082F9DB /* MoodRecordView.swift in Sources */,
666-
7BE2475F2BCA3CA900DD3B76 /* PrivacyPolicyWebview.swift in Sources */,
667669
7B907F7A2B9B4FBE0050D05B /* UpdateNoticiationExtension.swift in Sources */,
668670
7B34415D2BA1B87A00DA43F6 /* MonthPickerViewModel.swift in Sources */,
669671
7BAB04F42B9466BC00948CF2 /* Mood.swift in Sources */,
@@ -704,8 +706,10 @@
704706
files = (
705707
7B11F8432B4549E000346A41 /* PlantingMindUITests_Calendar.swift in Sources */,
706708
7BA66A8D2BCFFB0D009BD9E8 /* XCTestsExtension.swift in Sources */,
709+
7B3FA1C12BCFDEF0007C3633 /* PlantingMindUITests_Settings.swift in Sources */,
707710
7B3FA1BF2BCFDE6C007C3633 /* PlantingMindUITests_MoodRecord.swift in Sources */,
708711
7BA66A8B2BCFEC21009BD9E8 /* AccessibilityIdentifiers.swift in Sources */,
712+
7BA66A942BD0DCCE009BD9E8 /* LocalizedHelper.swift in Sources */,
709713
);
710714
runOnlyForDeploymentPostprocessing = 0;
711715
};

PlantingMind/PlantingMind/AccessibilityIdentifiers.swift

+3
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,7 @@ enum AccessibilityIdentifiers: String {
3636
case normal
3737
case notBad
3838
case bad
39+
40+
// Settings
41+
case timePicker
3942
}

PlantingMind/PlantingMind/Settings/Notification/NotificationSettingView.swift

+1
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ struct NotificationSettingView: View {
6767
HStack {
6868
Text("set_time_picker")
6969
DatePicker("", selection: $viewModel.pickedTime, displayedComponents: [.hourAndMinute])
70+
.accessibilityIdentifier(AccessibilityIdentifiers.timePicker.rawValue)
7071
}
7172
}
7273
}

PlantingMind/PlantingMind/Settings/PrivacyPolicyWebview.swift

-30
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
//
2+
// LocalizedHelper.swift
3+
// PlantingMindUITests
4+
//
5+
// Created by 최은주 on 4/18/24.
6+
//
7+
8+
import Foundation
9+
10+
class LocalizedHelper {
11+
func localized(_ key: String) -> String {
12+
let uiTestBundle = Bundle(for: type(of: self))
13+
return NSLocalizedString(key, bundle: uiTestBundle, comment: "")
14+
}
15+
}

PlantingMind/PlantingMindUITests/PlantingMindUITests_Calendar.swift

+5-8
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ final class PlantingMindUITests_Calendar: XCTestCase {
2222

2323
func test_01_달력_Picker로_이동() {
2424
let monthPickerButton = app.buttons[AccessibilityIdentifiers.monthPickerButton.rawValue]
25-
tapButton(element: monthPickerButton)
25+
tap(element: monthPickerButton)
2626

2727
let yearPicker = app.pickers[AccessibilityIdentifiers.yearPicker.rawValue].pickerWheels.firstMatch
2828
XCTAssertTrue(yearPicker.waitForExistence(timeout: 1.0))
@@ -33,17 +33,17 @@ final class PlantingMindUITests_Calendar: XCTestCase {
3333
yearPicker.adjust(toPickerWheelValue: "2024")
3434
monthPicker.adjust(toPickerWheelValue: "01")
3535

36-
tapButton(element: app.buttons[AccessibilityIdentifiers.doneButton.rawValue])
36+
tap(element: app.buttons[AccessibilityIdentifiers.doneButton.rawValue])
3737
checkString(element: monthPickerButton, expectedString: "2024. 01")
3838
}
3939

4040
func test_02_좌우버튼으로_이동() {
4141
let monthPickerButton = app.buttons[AccessibilityIdentifiers.monthPickerButton.rawValue]
4242

43-
tapButton(element: app.buttons[AccessibilityIdentifiers.nextMonthButton.rawValue])
43+
tap(element: app.buttons[AccessibilityIdentifiers.nextMonthButton.rawValue])
4444
checkString(element: monthPickerButton, expectedString: "2024. 02")
4545

46-
tapButton(element: app.buttons[AccessibilityIdentifiers.previousMonthButton.rawValue])
46+
tap(element: app.buttons[AccessibilityIdentifiers.previousMonthButton.rawValue])
4747
checkString(element: monthPickerButton, expectedString: "2024. 01")
4848
}
4949

@@ -60,10 +60,7 @@ final class PlantingMindUITests_Calendar: XCTestCase {
6060

6161
private func removeNotificationAllowAlert() {
6262
addUIInterruptionMonitor(withDescription: "Allow push") { (alerts) -> Bool in
63-
let firstMatchButton = alerts.buttons.element(boundBy: 1)
64-
if(firstMatchButton.exists){
65-
firstMatchButton.tap();
66-
}
63+
self.tap(element: alerts.buttons.lastMatch)
6764
return true;
6865
}
6966

PlantingMind/PlantingMindUITests/PlantingMindUITests_MoodRecord.swift

+28-29
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import XCTest
99

1010
final class PlantingMindUITests_MoodRecord: XCTestCase {
1111
let app = XCUIApplication()
12+
let localizedHelper = LocalizedHelper()
1213

1314
override func setUpWithError() throws {
1415
continueAfterFailure = false
@@ -18,65 +19,63 @@ final class PlantingMindUITests_MoodRecord: XCTestCase {
1819
app.launch()
1920

2021
checkString(element: app.staticTexts[AccessibilityIdentifiers.emptyMoodText.rawValue],
21-
expectedString: localized("mood_statistics_empty"))
22+
expectedString: localizedHelper.localized("mood_statistics_empty"))
2223

23-
tapButton(element: app.buttons["1"])
24-
tapButton(element: app.buttons[AccessibilityIdentifiers.cancelButton.rawValue])
24+
tap(element: app.buttons["1"])
25+
tap(element: app.buttons[AccessibilityIdentifiers.cancelButton.rawValue])
2526

26-
tapButton(element: app.buttons["1"])
27+
tap(element: app.buttons["1"])
2728
checkString(element: app.staticTexts[AccessibilityIdentifiers.moodTitleText.rawValue],
28-
expectedString: localized("mood_title"))
29+
expectedString: localizedHelper.localized("mood_title"))
2930

30-
tapButton(element: app.buttons[AccessibilityIdentifiers.nice.rawValue])
31+
tap(element: app.buttons[AccessibilityIdentifiers.nice.rawValue])
3132

3233
let textEditor = app.textViews[AccessibilityIdentifiers.moodReasonTextEditor.rawValue]
3334
XCTAssertTrue(textEditor.waitForExistence(timeout: 1.0))
3435
textEditor.tap()
3536
textEditor.typeText("test string")
3637

37-
tapButton(element: app.buttons[AccessibilityIdentifiers.saveButton.rawValue])
38+
tap(element: app.buttons[AccessibilityIdentifiers.saveButton.rawValue])
3839
let chart = app.otherElements[AccessibilityIdentifiers.moodChart.rawValue].firstMatch
3940
XCTAssertTrue(chart.waitForExistence(timeout: 1.0))
40-
XCTAssertTrue(chart.otherElements[localized("nice")].value as? String == "1")
41+
XCTAssertTrue(chart.otherElements[localizedHelper.localized("nice")].value as? String == "1")
4142
}
4243

4344
func test_02_감정기록_수정_취소() {
44-
tapButton(element: app.buttons["1"])
45+
tap(element: app.buttons["1"])
4546

4647
checkString(element: app.staticTexts[AccessibilityIdentifiers.moodTitleText.rawValue],
47-
expectedString: localized("mood_title"))
48+
expectedString: localizedHelper.localized("mood_title"))
4849

49-
tapButton(element: app.buttons[AccessibilityIdentifiers.normal.rawValue])
50-
tapButton(element: app.buttons[AccessibilityIdentifiers.cancelButton.rawValue])
51-
XCTAssertTrue(app.staticTexts[localized("record_cancel_alert")].waitForExistence(timeout: 2.0))
52-
tapButton(element: app.buttons[AccessibilityIdentifiers.confirmButton.rawValue])
50+
tap(element: app.buttons[AccessibilityIdentifiers.normal.rawValue])
51+
tap(element: app.buttons[AccessibilityIdentifiers.cancelButton.rawValue])
52+
53+
XCTAssertTrue(app.staticTexts[localizedHelper.localized("record_cancel_alert")].waitForExistence(timeout: 2.0))
54+
tap(element: app.buttons[AccessibilityIdentifiers.confirmButton.rawValue])
5355
}
5456

5557
func test_03_감정기록_수정_저장_후_마음현황_체크() {
56-
tapButton(element: app.buttons["1"])
58+
tap(element: app.buttons["1"])
5759

5860
checkString(element: app.staticTexts[AccessibilityIdentifiers.moodTitleText.rawValue],
59-
expectedString: localized("mood_title"))
61+
expectedString: localizedHelper.localized("mood_title"))
6062

61-
tapButton(element: app.buttons[AccessibilityIdentifiers.normal.rawValue])
62-
tapButton(element: app.buttons[AccessibilityIdentifiers.saveButton.rawValue])
63+
tap(element: app.buttons[AccessibilityIdentifiers.normal.rawValue])
64+
tap(element: app.buttons[AccessibilityIdentifiers.saveButton.rawValue])
6365

6466
let chart = app.otherElements[AccessibilityIdentifiers.moodChart.rawValue].firstMatch
6567
XCTAssertTrue(chart.waitForExistence(timeout: 1.0))
66-
XCTAssertTrue(chart.otherElements[localized("normal")].value as? String == "1")
68+
XCTAssertTrue(chart.otherElements[localizedHelper.localized("normal")].value as? String == "1")
6769
}
6870

6971
func test_04_감정기록_삭제_후_마음현황_체크() {
70-
tapButton(element: app.buttons["1"])
71-
tapButton(element: app.buttons[AccessibilityIdentifiers.removeButton.rawValue])
72-
XCTAssertTrue(app.staticTexts[localized("delete_alert")].waitForExistence(timeout: 1.0))
73-
tapButton(element: app.buttons[AccessibilityIdentifiers.confirmButton.rawValue])
72+
tap(element: app.buttons["1"])
73+
tap(element: app.buttons[AccessibilityIdentifiers.removeButton.rawValue])
74+
75+
checkAlert(app: app, string: localizedHelper.localized("delete_alert"))
76+
tap(element: app.buttons[AccessibilityIdentifiers.confirmButton.rawValue])
77+
7478
checkString(element: app.staticTexts[AccessibilityIdentifiers.emptyMoodText.rawValue],
75-
expectedString: localized("mood_statistics_empty"))
76-
}
77-
78-
func localized(_ key: String) -> String {
79-
let uiTestBundle = Bundle(for: type(of: self))
80-
return NSLocalizedString(key, bundle: uiTestBundle, comment: "")
79+
expectedString: localizedHelper.localized("mood_statistics_empty"))
8180
}
8281
}

0 commit comments

Comments
 (0)