Skip to content

Commit

Permalink
fix: CI
Browse files Browse the repository at this point in the history
  • Loading branch information
kirillzyusko committed Feb 22, 2024
1 parent 0cae779 commit 2d56f72
Show file tree
Hide file tree
Showing 13 changed files with 132 additions and 129 deletions.
2 changes: 1 addition & 1 deletion FabricExample/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1407,7 +1407,7 @@ SPEC CHECKSUMS:
React-jsiexecutor: c7f826e40fa9cab5d37cab6130b1af237332b594
React-jsinspector: aaed4cf551c4a1c98092436518c2d267b13a673f
React-logger: da1ebe05ae06eb6db4b162202faeafac4b435e77
react-native-keyboard-controller: 7d3273fbbc23c2ab463d58def0a2e1a512b17dd1
react-native-keyboard-controller: cf06de91623310fc8a3e77986c92a1b416f9907e
react-native-safe-area-context: a283130af276caa22ecfed30c3d1eb450bc83439
React-NativeModulesApple: edb5ace14f73f4969df6e7b1f3e41bef0012740f
React-perflogger: 496a1a3dc6737f964107cb3ddae7f9e265ddda58
Expand Down
6 changes: 3 additions & 3 deletions example/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -706,7 +706,7 @@ EXTERNAL SOURCES:
SPEC CHECKSUMS:
boost: 57d2868c099736d80fcd648bf211b4431e51a558
CocoaAsyncSocket: 065fd1e645c7abab64f7a6a2007a48038fdc6a99
DoubleConversion: fea03f2699887d960129cc54bba7e52542b6f953
DoubleConversion: 5189b271737e1565bdce30deb4a08d647e3f5f54
FBLazyVector: 5d4a3b7f411219a45a6d952f77d2c0a6c9989da5
FBReactNativeSpec: 3fc2d478e1c4b08276f9dd9128f80ec6d5d85c1f
Flipper: 6edb735e6c3e332975d1b17956bcc584eccf5818
Expand All @@ -718,7 +718,7 @@ SPEC CHECKSUMS:
Flipper-PeerTalk: 116d8f857dc6ef55c7a5a75ea3ceaafe878aadc9
FlipperKit: 2efad7007d6745a3f95e4034d547be637f89d3f6
fmt: ff9d55029c625d3757ed641535fd4a75fedc7ce9
glog: c5d68082e772fa1c511173d6b30a9de2c05a69a2
glog: 04b94705f318337d7ead9e6d17c019bd9b1f6b1b
hermes-engine: 81191603c4eaa01f5e4ae5737a9efcf64756c7b2
InputMask: 71d291dc54d2deaeac6512afb6ec2304228c0bb7
libevent: 4049cae6c81cdb3654a443be001fb9bdceff7913
Expand All @@ -740,7 +740,7 @@ SPEC CHECKSUMS:
React-jsiexecutor: c7f826e40fa9cab5d37cab6130b1af237332b594
React-jsinspector: aaed4cf551c4a1c98092436518c2d267b13a673f
React-logger: da1ebe05ae06eb6db4b162202faeafac4b435e77
react-native-keyboard-controller: 30f2304b54b2b34e9a6678c33d8ea12830b9cda1
react-native-keyboard-controller: 5fec21f7f16086770aa28069fb686ab0d0a1be61
react-native-safe-area-context: 9697629f7b2cda43cf52169bb7e0767d330648c2
react-native-text-input-mask: 22ca8eeef84d42a896f79428f7d175a5eb8b1c4e
React-NativeModulesApple: edb5ace14f73f4969df6e7b1f3e41bef0012740f
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"colors" : [
"colors": [
{
"idiom" : "universal"
"idiom": "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
"info": {
"author": "xcode",
"version": 1
}
}
14 changes: 7 additions & 7 deletions ios/Tests/Tests/Assets.xcassets/AppIcon.appiconset/Contents.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{
"images" : [
"images": [
{
"idiom" : "universal",
"platform" : "ios",
"size" : "1024x1024"
"idiom": "universal",
"platform": "ios",
"size": "1024x1024"
}
],
"info" : {
"author" : "xcode",
"version" : 1
"info": {
"author": "xcode",
"version": 1
}
}
6 changes: 3 additions & 3 deletions ios/Tests/Tests/Assets.xcassets/Contents.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"info" : {
"author" : "xcode",
"version" : 1
"info": {
"author": "xcode",
"version": 1
}
}
18 changes: 9 additions & 9 deletions ios/Tests/Tests/ContentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,17 @@
import SwiftUI

struct ContentView: View {
var body: some View {
VStack {
Image(systemName: "globe")
.imageScale(.large)
.foregroundStyle(.tint)
Text("Hello, world!")
}
.padding()
var body: some View {
VStack {
Image(systemName: "globe")
.imageScale(.large)
.foregroundStyle(.tint)
Text("Hello, world!")
}
.padding()
}
}

#Preview {
ContentView()
ContentView()
}
2 changes: 1 addition & 1 deletion ios/Tests/Tests/Extension+UIView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ import UIKit

public extension UIView {
var reactTag: NSNumber {
return self.tag as NSNumber
return tag as NSNumber
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"info" : {
"author" : "xcode",
"version" : 1
"info": {
"author": "xcode",
"version": 1
}
}
8 changes: 4 additions & 4 deletions ios/Tests/Tests/TestsApp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ import SwiftUI

@main
struct TestsApp: App {
var body: some Scene {
WindowGroup {
ContentView()
}
var body: some Scene {
WindowGroup {
ContentView()
}
}
}
96 changes: 50 additions & 46 deletions ios/Tests/TestsTests/TestsTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,68 +5,72 @@
// Created by Kiryl Ziusko on 21/02/2024.
//

import XCTest
@testable import Tests
import XCTest

class TestableTextField: UITextField {
var becomeFirstResponderCalled = false
var becomeFirstResponderCalled = false

override func becomeFirstResponder() -> Bool {
becomeFirstResponderCalled = true
return super.becomeFirstResponder()
}
override func becomeFirstResponder() -> Bool {
becomeFirstResponderCalled = true
return super.becomeFirstResponder()
}
}

class TestableTextView: UITextView {
var becomeFirstResponderCalled = false
var becomeFirstResponderCalled = false

override func becomeFirstResponder() -> Bool {
becomeFirstResponderCalled = true
return super.becomeFirstResponder()
}
override func becomeFirstResponder() -> Bool {
becomeFirstResponderCalled = true
return super.becomeFirstResponder()
}
}

final class TestsTests: XCTestCase {
override func setUpWithError() throws {
// Put setup code here. This method is called before the invocation of each test method in the class.
}

override func setUpWithError() throws {
// Put setup code here. This method is called before the invocation of each test method in the class.
}
override func tearDownWithError() throws {
// Put teardown code here. This method is called after the invocation of each test method in the class.
}

override func tearDownWithError() throws {
// Put teardown code here. This method is called after the invocation of each test method in the class.
}
func testExample() throws {
// Setup
let rootView = UIView()
let firstTextInput = TestableTextField()
firstTextInput.isEnabled = true
let secondTextInput = TestableTextView()
secondTextInput.isEditable = true
let nonTextInput = UIView()
rootView.addSubview(firstTextInput)
rootView.addSubview(nonTextInput) // Non-text input view
rootView.addSubview(secondTextInput)

func testExample() throws {
// Setup
let rootView = UIView()
let firstTextInput = TestableTextField()
firstTextInput.isEnabled = true
let secondTextInput = TestableTextView()
secondTextInput.isEditable = true
let nonTextInput = UIView()
rootView.addSubview(firstTextInput)
rootView.addSubview(nonTextInput) // Non-text input view
rootView.addSubview(secondTextInput)

FocusedInputHolder.shared.set(firstTextInput)
FocusedInputHolder.shared.set(firstTextInput)

XCTAssertFalse(secondTextInput.becomeFirstResponderCalled, "The focus should be set to the second text input")

ViewHierarchyNavigator.setFocusTo(direction: "next")

let expectation = XCTestExpectation(description: "Wait for next focus change")
DispatchQueue.main.async {
XCTAssertTrue(secondTextInput.becomeFirstResponderCalled, "The focus should be set to the second text input")
expectation.fulfill()
}
wait(for: [expectation], timeout: 10.0)
}
XCTAssertFalse(
secondTextInput.becomeFirstResponderCalled,
"The focus should be set to the second text input"
)

func testPerformanceExample() throws {
// This is an example of a performance test case.
self.measure {
// Put the code you want to measure the time of here.
}
ViewHierarchyNavigator.setFocusTo(direction: "next")

let expectation = XCTestExpectation(description: "Wait for next focus change")
DispatchQueue.main.async {
XCTAssertTrue(
secondTextInput.becomeFirstResponderCalled,
"The focus should be set to the second text input"
)
expectation.fulfill()
}
wait(for: [expectation], timeout: 10.0)
}

func testPerformanceExample() throws {
// This is an example of a performance test case.
measure {
// Put the code you want to measure the time of here.
}
}
}
58 changes: 29 additions & 29 deletions ios/Tests/TestsUITests/TestsUITests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,34 +8,34 @@
import XCTest

final class TestsUITests: XCTestCase {

override func setUpWithError() throws {
// Put setup code here. This method is called before the invocation of each test method in the class.

// In UI tests it is usually best to stop immediately when a failure occurs.
continueAfterFailure = false

// In UI tests it’s important to set the initial state - such as interface orientation - required for your tests before they run. The setUp method is a good place to do this.
}

override func tearDownWithError() throws {
// Put teardown code here. This method is called after the invocation of each test method in the class.
}

func testExample() throws {
// UI tests must launch the application that they test.
let app = XCUIApplication()
app.launch()

// Use XCTAssert and related functions to verify your tests produce the correct results.
}

func testLaunchPerformance() throws {
if #available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 7.0, *) {
// This measures how long it takes to launch your application.
measure(metrics: [XCTApplicationLaunchMetric()]) {
XCUIApplication().launch()
}
}
override func setUpWithError() throws {
// Put setup code here. This method is called before the invocation of each test method in the class.

// In UI tests it is usually best to stop immediately when a failure occurs.
continueAfterFailure = false

// In UI tests it’s important to set the initial state - such as interface orientation - required
// for your tests before they run. The setUp method is a good place to do this.
}

override func tearDownWithError() throws {
// Put teardown code here. This method is called after the invocation of each test method in the class.
}

func testExample() throws {
// UI tests must launch the application that they test.
let app = XCUIApplication()
app.launch()

// Use XCTAssert and related functions to verify your tests produce the correct results.
}

func testLaunchPerformance() throws {
if #available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 7.0, *) {
// This measures how long it takes to launch your application.
measure(metrics: [XCTApplicationLaunchMetric()]) {
XCUIApplication().launch()
}
}
}
}
33 changes: 16 additions & 17 deletions ios/Tests/TestsUITests/TestsUITestsLaunchTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,24 @@
import XCTest

final class TestsUITestsLaunchTests: XCTestCase {
override class var runsForEachTargetApplicationUIConfiguration: Bool {
true
}

override class var runsForEachTargetApplicationUIConfiguration: Bool {
true
}
override func setUpWithError() throws {
continueAfterFailure = false
}

override func setUpWithError() throws {
continueAfterFailure = false
}
func testLaunch() throws {
let app = XCUIApplication()
app.launch()

func testLaunch() throws {
let app = XCUIApplication()
app.launch()
// Insert steps here to perform after app launch but before taking a screenshot,
// such as logging into a test account or navigating somewhere in the app

// Insert steps here to perform after app launch but before taking a screenshot,
// such as logging into a test account or navigating somewhere in the app

let attachment = XCTAttachment(screenshot: app.screenshot())
attachment.name = "Launch Screen"
attachment.lifetime = .keepAlways
add(attachment)
}
let attachment = XCTAttachment(screenshot: app.screenshot())
attachment.name = "Launch Screen"
attachment.lifetime = .keepAlways
add(attachment)
}
}
2 changes: 1 addition & 1 deletion react-native-keyboard-controller.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Pod::Spec.new do |s|
s.source = { :git => "https://github.com/kirillzyusko/react-native-keyboard-controller.git", :tag => "#{s.version}" }

s.source_files = "ios/**/*.{h,m,mm,swift}"
s.exclude_files = "ios/Tests/**"
s.exclude_files = "ios/Tests/**/*"
s.public_header_files = "ios/**/*.h"

s.dependency "React-Core"
Expand Down

0 comments on commit 2d56f72

Please sign in to comment.