SettingsUITests.swift 3.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. // Copyright 2023 Google LLC
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. import XCTest
  15. class SettingsUITests: XCTestCase {
  16. var app: XCUIApplication!
  17. override func setUp() {
  18. super.setUp()
  19. continueAfterFailure = false
  20. app = XCUIApplication()
  21. app.launch()
  22. }
  23. func testSettings() {
  24. app.staticTexts["Settings"].tap()
  25. wait(forElement: app.navigationBars["Settings"], timeout: 5.0)
  26. XCTAssertTrue(app.navigationBars["Settings"].exists)
  27. // Test Identity toolkit
  28. let identityCell = app.cells.containing(.staticText, identifier: "Identity Toolkit").element
  29. XCTAssertTrue(identityCell.staticTexts["www.googleapis.com"].exists)
  30. identityCell.tap()
  31. XCTAssertTrue(identityCell.staticTexts["staging-www.sandbox.googleapis.com"].exists)
  32. identityCell.tap()
  33. XCTAssertTrue(identityCell.staticTexts["www.googleapis.com"].exists)
  34. // Test Secure Token
  35. let secureTokenCell = app.cells.containing(.staticText, identifier: "Secure Token").element
  36. XCTAssertTrue(secureTokenCell.staticTexts["securetoken.googleapis.com"].exists)
  37. secureTokenCell.tap()
  38. XCTAssertTrue(secureTokenCell.staticTexts["staging-securetoken.sandbox.googleapis.com"].exists)
  39. secureTokenCell.tap()
  40. XCTAssertTrue(secureTokenCell.staticTexts["securetoken.googleapis.com"].exists)
  41. // Swap Firebase App
  42. let appCell = app.cells.containing(.staticText, identifier: "Active App").element
  43. XCTAssertTrue(appCell.staticTexts["fir-ios-auth-sample"].exists)
  44. appCell.tap()
  45. XCTAssertTrue(appCell.staticTexts["fb-sa-upgraded"].exists)
  46. appCell.tap()
  47. XCTAssertTrue(appCell.staticTexts["fir-ios-auth-sample"].exists)
  48. // Current Access Group
  49. let accessCell = app.cells.containing(.staticText, identifier: "Current Access Group").element
  50. XCTAssertTrue(accessCell.staticTexts["[none]"].exists)
  51. // TODO: Debug why the following works locally but crashes app in GitHub Actions.
  52. // accessCell.tap()
  53. // let predicate = NSPredicate(format: "label CONTAINS
  54. // 'com.google.firebase.auth.keychainGroup1'")
  55. // let createAccountText = accessCell.staticTexts.containing(predicate).element.exists
  56. // accessCell.tap()
  57. // XCTAssertTrue(accessCell.staticTexts["[none]"].exists)
  58. // Auth Language
  59. let languageCell = app.cells.containing(.staticText, identifier: "Auth Language").element
  60. XCTAssertTrue(languageCell.staticTexts["[none]"].exists)
  61. languageCell.tap()
  62. app.typeText("abc")
  63. app.buttons["OK"].tap()
  64. XCTAssertTrue(languageCell.staticTexts["abc"].exists)
  65. // TODO: PhoneAuth
  66. // Click to Use App Language
  67. let appLanguageCell = app.cells.containing(.staticText,
  68. identifier: "Click to Use App Language").element
  69. appLanguageCell.tap()
  70. // Check for either Xcode 14 or Xcode 15 strings.
  71. XCTAssertTrue(languageCell.staticTexts["en"].exists || languageCell.staticTexts["en-US"].exists)
  72. // Disable App Verification
  73. let disabledCell = app.cells.containing(.staticText,
  74. identifier: "Disable App Verification (Phone)")
  75. .element
  76. XCTAssertTrue(disabledCell.staticTexts["NO"].exists, "App verification should NOT be disabled")
  77. disabledCell.tap()
  78. XCTAssertTrue(disabledCell.staticTexts["YES"].exists, "App verification should NOW be disabled")
  79. disabledCell.tap()
  80. XCTAssertTrue(disabledCell.staticTexts["NO"].exists, "App verification should NOT be disabled")
  81. }
  82. }