Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Chore] Refactor Test Plan #112

Merged
merged 8 commits into from
Jan 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .github/workflows/ios_review_pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,13 @@ jobs:
- name: Build and Test
run: bundle exec fastlane build_and_test

- name: Upload Failed Screenshots
uses: actions/upload-artifact@v3
with:
name: kif-failed-screenshots
path: iosApp/Failed_Screenshots
if-no-files-found: ignore

- name: Run iOS Danger
uses: MeilCli/danger-action@v5
with:
Expand Down
7 changes: 7 additions & 0 deletions .github/workflows/ios_sanity_full_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -88,3 +88,10 @@ jobs:

- name: Build and Test
run: bundle exec fastlane build_and_full_test

- name: Upload Failed Screenshots
uses: actions/upload-artifact@v3
with:
name: kif-failed-screenshots
path: iosApp/Failed_Screenshots
if-no-files-found: ignore
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,10 @@ iosApp/fastlane/screenshots/**/*.png
iosApp/fastlane/test_output
iosApp/fastlane/xcov_output

# Testing

iosApp/Failed_Screenshots

# Sourcery
*.generated.swift

Expand Down
7 changes: 7 additions & 0 deletions iosApp/CICDTests.xctestplan
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@
}
],
"defaultOptions" : {
"environmentVariableEntries" : [
{
"key" : "KIF_SCREENSHOTS",
"value" : "$(PROJECT_DIR)\/Failed_Screenshots"
}
],
"targetForVariableExpansion" : {
"containerPath" : "container:Survey.xcodeproj",
"identifier" : "3AC192947DB2FAD63AFCCAEB",
Expand All @@ -24,6 +30,7 @@
}
},
{
"enabled" : false,
"skippedTests" : [
"LoginSpec\/a_Login_screen__its_open__it_shows_its_ui_components()",
"LoginSpec\/a_Login_screen__its_open__when_fill_in_invalid_credentials__shows_an_alert_after_the_request_fails()",
Expand Down
5 changes: 4 additions & 1 deletion iosApp/Dangerfile
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@ xcresultPath = "iosApp/#{Constants.TEST_OUTPUT_DIRECTORY_PATH}/#{Constants.TESTS
changed_files = (git.modified_files - git.deleted_files) + git.added_files
xcode_summary.ignored_results { |result|
if result.location
not changed_files.include?(result.location.file_path)
(
not changed_files.include?(result.location.file_path) or
result.message.include?("AA_AppLoadSpec")
)
else
true
end
Expand Down
14 changes: 12 additions & 2 deletions iosApp/Survey.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@
0982A80829278EC200FC1976 /* LoginFlow.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0982A7EE29223DA600FC1976 /* LoginFlow.swift */; };
0982A809292B6BCA00FC1976 /* ViewId+Splash.swift in Sources */ = {isa = PBXBuildFile; fileRef = 09495F6728FF97490036BDFB /* ViewId+Splash.swift */; };
0982A880292F847900FC1976 /* ResetPassword+DataSource.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0982A87F292F847900FC1976 /* ResetPassword+DataSource.swift */; };
098832B029713BAD0015BAC2 /* AA_AppLoadSpec.swift in Sources */ = {isa = PBXBuildFile; fileRef = 098832AF29713BAD0015BAC2 /* AA_AppLoadSpec.swift */; };
098CC7AD294C266000C3A6A5 /* XCTestCase+PermissionInteruption.swift in Sources */ = {isa = PBXBuildFile; fileRef = 098CC7AC294C266000C3A6A5 /* XCTestCase+PermissionInteruption.swift */; };
09A9F8D62952B3FC009DE583 /* LoginScreen.swift in Sources */ = {isa = PBXBuildFile; fileRef = 09A9F8D42952B3F8009DE583 /* LoginScreen.swift */; };
09A9F8D92952B431009DE583 /* GenericScreen.swift in Sources */ = {isa = PBXBuildFile; fileRef = 09A9F8D72952B42D009DE583 /* GenericScreen.swift */; };
Expand All @@ -100,8 +101,10 @@
09CE772728E2C44D00EAA9EE /* View+BackButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = 09CE772628E2C44D00EAA9EE /* View+BackButton.swift */; };
09CE773328E2ED2300EAA9EE /* KoinApplication.swift in Sources */ = {isa = PBXBuildFile; fileRef = 09CE773028E2ED2300EAA9EE /* KoinApplication.swift */; };
09CE773428E2ED2300EAA9EE /* Typealias+Koin.swift in Sources */ = {isa = PBXBuildFile; fileRef = 09CE773128E2ED2300EAA9EE /* Typealias+Koin.swift */; };
09D09DB92963EC39009F88AF /* Image+Url.swift in Sources */ = {isa = PBXBuildFile; fileRef = 09D09DB82963EC39009F88AF /* Image+Url.swift */; };
09D09DB2295C56A1009F88AF /* SurveySelectionSpec.swift in Sources */ = {isa = PBXBuildFile; fileRef = 09D09DB1295C56A1009F88AF /* SurveySelectionSpec.swift */; };
09D09DB92963EC39009F88AF /* Image+Url.swift in Sources */ = {isa = PBXBuildFile; fileRef = 09D09DB82963EC39009F88AF /* Image+Url.swift */; };
09D09DFA296E4B85009F88AF /* ResetPasswordSpec.swift in Sources */ = {isa = PBXBuildFile; fileRef = 09D09DF9296E4B85009F88AF /* ResetPasswordSpec.swift */; };
09D09E0C296EBA20009F88AF /* TimeInterval+Constants.swift in Sources */ = {isa = PBXBuildFile; fileRef = 09C2F4012934588400F44818 /* TimeInterval+Constants.swift */; };
09E6ABF32951D105007F1EE3 /* KIF+Swift.swift in Sources */ = {isa = PBXBuildFile; fileRef = 09E6ABF12951D103007F1EE3 /* KIF+Swift.swift */; };
09E6ABFD2951D32F007F1EE3 /* ViewId.swift in Sources */ = {isa = PBXBuildFile; fileRef = 09636B1428D8148C00A5CB97 /* ViewId.swift */; };
09E6ABFE2951D333007F1EE3 /* ViewId+General.swift in Sources */ = {isa = PBXBuildFile; fileRef = 09636B2F28D8267D00A5CB97 /* ViewId+General.swift */; };
Expand Down Expand Up @@ -248,6 +251,7 @@
0982A80029278E9000FC1976 /* SurveyItemLoading.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SurveyItemLoading.swift; sourceTree = "<group>"; };
0982A80129278E9000FC1976 /* SurveyHeaderLoading.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SurveyHeaderLoading.swift; sourceTree = "<group>"; };
0982A87F292F847900FC1976 /* ResetPassword+DataSource.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "ResetPassword+DataSource.swift"; sourceTree = "<group>"; };
098832AF29713BAD0015BAC2 /* AA_AppLoadSpec.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AA_AppLoadSpec.swift; sourceTree = "<group>"; };
098CC7AC294C266000C3A6A5 /* XCTestCase+PermissionInteruption.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "XCTestCase+PermissionInteruption.swift"; sourceTree = "<group>"; };
09A9F8D42952B3F8009DE583 /* LoginScreen.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LoginScreen.swift; sourceTree = "<group>"; };
09A9F8D72952B42D009DE583 /* GenericScreen.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GenericScreen.swift; sourceTree = "<group>"; };
Expand All @@ -274,8 +278,9 @@
09CE772F28E2ED2300EAA9EE /* LazyKoin.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LazyKoin.swift; sourceTree = "<group>"; };
09CE773028E2ED2300EAA9EE /* KoinApplication.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = KoinApplication.swift; sourceTree = "<group>"; };
09CE773128E2ED2300EAA9EE /* Typealias+Koin.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "Typealias+Koin.swift"; sourceTree = "<group>"; };
09D09DB82963EC39009F88AF /* Image+Url.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Image+Url.swift"; sourceTree = "<group>"; };
09D09DB1295C56A1009F88AF /* SurveySelectionSpec.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SurveySelectionSpec.swift; sourceTree = "<group>"; };
09D09DB82963EC39009F88AF /* Image+Url.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Image+Url.swift"; sourceTree = "<group>"; };
09D09DF9296E4B85009F88AF /* ResetPasswordSpec.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ResetPasswordSpec.swift; sourceTree = "<group>"; };
09E6ABE42951CF3E007F1EE3 /* SurveyKIFUITests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = SurveyKIFUITests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
09E6ABF12951D103007F1EE3 /* KIF+Swift.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "KIF+Swift.swift"; sourceTree = "<group>"; };
09E6AC0B2951D5DD007F1EE3 /* AccountSpec.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AccountSpec.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -889,7 +894,9 @@
09E6AC0A2951D5D1007F1EE3 /* Module */ = {
isa = PBXGroup;
children = (
098832AF29713BAD0015BAC2 /* AA_AppLoadSpec.swift */,
09E6AC0B2951D5DD007F1EE3 /* AccountSpec.swift */,
09D09DF9296E4B85009F88AF /* ResetPasswordSpec.swift */,
09D09DB1295C56A1009F88AF /* SurveySelectionSpec.swift */,
);
path = Module;
Expand Down Expand Up @@ -1774,13 +1781,16 @@
09A9F8D62952B3FC009DE583 /* LoginScreen.swift in Sources */,
09E6AC0D2951D61E007F1EE3 /* AccountSpec.swift in Sources */,
09E6AC032951D333007F1EE3 /* ViewId+Account.swift in Sources */,
09D09DFA296E4B85009F88AF /* ResetPasswordSpec.swift in Sources */,
09E6ABFE2951D333007F1EE3 /* ViewId+General.swift in Sources */,
09E6AC012951D333007F1EE3 /* ViewId+Login.swift in Sources */,
09E6ABFF2951D333007F1EE3 /* ViewId+SurveySelection.swift in Sources */,
09D09E0C296EBA20009F88AF /* TimeInterval+Constants.swift in Sources */,
09D09DB2295C56A1009F88AF /* SurveySelectionSpec.swift in Sources */,
09E6AC042951D333007F1EE3 /* ViewId+Splash.swift in Sources */,
09E6ABF32951D105007F1EE3 /* KIF+Swift.swift in Sources */,
09E6ABFD2951D32F007F1EE3 /* ViewId.swift in Sources */,
098832B029713BAD0015BAC2 /* AA_AppLoadSpec.swift in Sources */,
09A9F8DC2952B574009DE583 /* SurveyScreen.swift in Sources */,
09E6AC002951D333007F1EE3 /* ViewId+SurveyLoading.swift in Sources */,
09A9F8DF2952B585009DE583 /* AccountScreen.swift in Sources */,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ struct LoginView: View {
.onTapGesture {
hideKeyboard()
}
.accessibilityElement(children: .contain)
.hideBackButtonTitle()
.onAppear {
withAnimation(.easeIn(duration: animationDuration)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,6 @@ extension ViewId {

case keyboard = "general.keyboard"
case loadingSpinner = "general.loading.spinner"
case back = "Back"
}
}
7 changes: 4 additions & 3 deletions iosApp/SurveyKIFUITests/Sources/Screens/AccountScreen.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,13 @@ import Foundation
final class AccountScreen: GenericScreen {

func navigateToHome() {
if tester.tryFindingView(withAccessibilityIdentifier: ViewId.account(.logoutButton)()) {
tester.tapScreen(at: .init(x: 10.0, y: 100.0))
if tester().tryFindingView(withAccessibilityIdentifier: ViewId.account(.logoutButton)()) {
tester().tapScreen(at: .init(x: 10.0, y: 100.0))
system().wait(forTimeInterval: .instant)
}
}

func logOut() {
tester.tapView(withAccessibilityIdentifier: ViewId.account(.logoutButton)())
tester().tapView(withAccessibilityIdentifier: ViewId.account(.logoutButton)())
}
}
17 changes: 13 additions & 4 deletions iosApp/SurveyKIFUITests/Sources/Screens/GenericScreen.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,20 @@ class GenericScreen {

weak var testCase: XCTestCase!

var tester: KIFUITestActor {
testCase.tester()
}

init(_ testCase: XCTestCase!) {
self.testCase = testCase
}

func tester(file: String = #file, _ line: Int = #line) -> KIFUITestActor {
return testCase.tester(file: file, line)
}

func system(file: String = #file, _ line: Int = #line) -> KIFSystemTestActor {
return testCase.system(file: file, line)
}

func pressBack() {
tester().waitForAnimationsToFinish()
tester().tapView(withAccessibilityLabel: ViewId.general(.back)())
}
}
32 changes: 26 additions & 6 deletions iosApp/SurveyKIFUITests/Sources/Screens/LoginScreen.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,38 @@
// Copyright © 2022 Nimble. All rights reserved.
//

import Shared

final class LoginScreen: GenericScreen {

func loginIfNeeded() {
if tester.tryFindingView(withAccessibilityIdentifier: ViewId.surveySelection(.view)()) {
if tester().tryFindingView(withAccessibilityIdentifier: ViewId.surveySelection(.view)()) {
return
}
if tester.tryFindingView(withAccessibilityIdentifier: ViewId.splash(.view)()) {
tester.waitForAbsenceOfView(withAccessibilityIdentifier: ViewId.splash(.view)())
if tester().tryFindingView(withAccessibilityIdentifier: ViewId.splash(.view)()) {
tester().waitForAbsenceOfView(withAccessibilityIdentifier: ViewId.splash(.view)())
}
if tester.tryFindingView(withAccessibilityIdentifier: ViewId.login(.view)()) {
tester.waitForTappableView(withAccessibilityIdentifier: ViewId.login(.loginButton)())
tester.tapView(withAccessibilityIdentifier: ViewId.login(.loginButton)())
if tester().tryFindingView(withAccessibilityIdentifier: ViewId.login(.view)()) {
tester().waitForTappableView(withAccessibilityIdentifier: ViewId.login(.loginButton)())
tester().tapView(withAccessibilityIdentifier: ViewId.login(.loginButton)())
tester().waitForAbsenceOfView(withAccessibilityIdentifier: ViewId.login(.view)())
}
}

func waitForAppearance() {
tester().waitForView(withAccessibilityIdentifier: ViewId.login(.view)())
}

func navigateToResetPassword() {
tester().clearTextFromView(withAccessibilityIdentifier: ViewId.login(.passwordField)())
tester().tapView(withAccessibilityIdentifier: ViewId.login(.forgotButton)())
}

func fillCredentialIfNeeded() {
let uiTestConfig = SharedBuildConfig.UITestConfig()
tester().clearText(
fromAndThenEnterText: uiTestConfig.password(),
intoViewWithAccessibilityIdentifier: ViewId.login(.passwordField)()
)
}
}
26 changes: 23 additions & 3 deletions iosApp/SurveyKIFUITests/Sources/Screens/SurveyScreen.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,38 @@
final class SurveyScreen: GenericScreen {

func waitForAppearance() {
tester.waitForView(withAccessibilityIdentifier: ViewId.surveySelection(.view)())
tester()
.usingTimeout(.long)
.waitForView(withAccessibilityIdentifier: ViewId.surveySelection(.mainImage)())
}

func navigateToAccount() {
waitForAppearance()
tester.tapView(withAccessibilityIdentifier: ViewId.surveySelection(.headerProfileImage)())
if !tester().tryFindingView(
withAccessibilityIdentifier: ViewId.account(.profileImage)()
) {
tester().tapView(withAccessibilityIdentifier: ViewId.surveySelection(.headerProfileImage)())
}
}

func swipeRight() {
tester.swipeView(
tester().swipeView(
withAccessibilityIdentifier: ViewId.surveySelection(.detailText)(),
in: .left
)
}

func logoutIfNeeded() {
if tester().tryFindingView(withAccessibilityIdentifier: ViewId.login(.view)()) {
return
}
if tester().tryFindingView(withAccessibilityIdentifier: ViewId.splash(.view)()) {
tester().waitForAbsenceOfView(withAccessibilityIdentifier: ViewId.splash(.view)())
}
if tester().tryFindingView(withAccessibilityIdentifier: ViewId.surveySelection(.view)()) {
navigateToAccount()
tester().tapView(withAccessibilityIdentifier: ViewId.account(.logoutButton)())
}
tester().waitForAnimationsToFinish()
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
//
// AA_AppLoadSpec.swift
// SurveyKIFUITests
//
// Created by Bliss on 13/1/23.
// Copyright © 2023 Nimble. All rights reserved.
//

import Nimble
import Quick

// Named to be the first test
final class AA_AppLoadSpec: QuickSpec {

override func spec() {

var loginScreen: LoginScreen!
var surveyScreen: SurveyScreen!

describe("the app") {

beforeEach {
loginScreen = LoginScreen(self)
surveyScreen = SurveyScreen(self)
}

describe("its launch") {

context("when log in") {

beforeEach {
loginScreen.loginIfNeeded()
}

it("it loads") {
surveyScreen.waitForAppearance()
}
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ final class AccountSpec: QuickSpec {
context("when tapped") {

beforeEach {
surveyScreen.navigateToAccount()
accountScreen.logOut()
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
//
// ResetPasswordSpec.swift
// SurveyKIFUITests
//
// Created by Bliss on 11/1/23.
// Copyright © 2023 Nimble. All rights reserved.
//

import Nimble
import Quick

final class ResetPasswordSpec: QuickSpec {

override func spec() {

var loginScreen: LoginScreen!
var surveyScreen: SurveyScreen!

describe("a Reset Password screen") {

beforeEach {
loginScreen = LoginScreen(self)
surveyScreen = SurveyScreen(self)
}

describe("its open") {

beforeEach {
surveyScreen.logoutIfNeeded()
loginScreen.navigateToResetPassword()
}

afterEach {
loginScreen.pressBack()
loginScreen.waitForAppearance()
loginScreen.fillCredentialIfNeeded()
}

it("it shows its ui components") {
self.tester().waitForView(
withAccessibilityIdentifier: ViewId.resetPassword(.resetButton)()
)
self.tester().waitForView(
withAccessibilityIdentifier: ViewId.resetPassword(.emailField)()
)
}
}
}
}
}
1 change: 0 additions & 1 deletion iosApp/fastlane/Fastfile
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ platform :ios do
testplan: Constants.TEST_PLAN,
targets: [
Constants.TESTS_TARGET,
Constants.UI_TESTS_TARGET,
Constants.KIF_UI_TESTS_TARGET
]
)
Expand Down