|
| 1 | +// |
| 2 | +// PlantingMindUITests_MoodRecord.swift |
| 3 | +// PlantingMindUITests |
| 4 | +// |
| 5 | +// Created by 최은주 on 4/17/24. |
| 6 | +// |
| 7 | + |
| 8 | +import XCTest |
| 9 | + |
| 10 | +final class PlantingMindUITests_MoodRecord: XCTestCase { |
| 11 | + let app = XCUIApplication() |
| 12 | + |
| 13 | + override func setUpWithError() throws { |
| 14 | + continueAfterFailure = false |
| 15 | + } |
| 16 | + |
| 17 | + func test_01_감정기록_후_마음현황_체크() { |
| 18 | + app.launch() |
| 19 | + |
| 20 | + checkString(element: app.staticTexts[AccessibilityIdentifiers.emptyMoodText.rawValue], |
| 21 | + expectedString: localized("mood_statistics_empty")) |
| 22 | + |
| 23 | + tapButton(element: app.buttons["1"]) |
| 24 | + tapButton(element: app.buttons[AccessibilityIdentifiers.cancelButton.rawValue]) |
| 25 | + |
| 26 | + tapButton(element: app.buttons["1"]) |
| 27 | + checkString(element: app.staticTexts[AccessibilityIdentifiers.moodTitleText.rawValue], |
| 28 | + expectedString: localized("mood_title")) |
| 29 | + |
| 30 | + tapButton(element: app.buttons[AccessibilityIdentifiers.nice.rawValue]) |
| 31 | + |
| 32 | + let textEditor = app.textViews[AccessibilityIdentifiers.moodReasonTextEditor.rawValue] |
| 33 | + XCTAssertTrue(textEditor.waitForExistence(timeout: 1.0)) |
| 34 | + textEditor.tap() |
| 35 | + textEditor.typeText("test string") |
| 36 | + |
| 37 | + tapButton(element: app.buttons[AccessibilityIdentifiers.saveButton.rawValue]) |
| 38 | + let chart = app.otherElements[AccessibilityIdentifiers.moodChart.rawValue].firstMatch |
| 39 | + XCTAssertTrue(chart.waitForExistence(timeout: 1.0)) |
| 40 | + XCTAssertTrue(chart.otherElements[localized("nice")].value as? String == "1") |
| 41 | + } |
| 42 | + |
| 43 | + func test_02_감정기록_수정_취소() { |
| 44 | + tapButton(element: app.buttons["1"]) |
| 45 | + |
| 46 | + checkString(element: app.staticTexts[AccessibilityIdentifiers.moodTitleText.rawValue], |
| 47 | + expectedString: localized("mood_title")) |
| 48 | + |
| 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]) |
| 53 | + } |
| 54 | + |
| 55 | + func test_03_감정기록_수정_저장_후_마음현황_체크() { |
| 56 | + tapButton(element: app.buttons["1"]) |
| 57 | + |
| 58 | + checkString(element: app.staticTexts[AccessibilityIdentifiers.moodTitleText.rawValue], |
| 59 | + expectedString: localized("mood_title")) |
| 60 | + |
| 61 | + tapButton(element: app.buttons[AccessibilityIdentifiers.normal.rawValue]) |
| 62 | + tapButton(element: app.buttons[AccessibilityIdentifiers.saveButton.rawValue]) |
| 63 | + |
| 64 | + let chart = app.otherElements[AccessibilityIdentifiers.moodChart.rawValue].firstMatch |
| 65 | + XCTAssertTrue(chart.waitForExistence(timeout: 1.0)) |
| 66 | + XCTAssertTrue(chart.otherElements[localized("normal")].value as? String == "1") |
| 67 | + } |
| 68 | + |
| 69 | + 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]) |
| 74 | + 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: "") |
| 81 | + } |
| 82 | +} |
0 commit comments