Skip to content

Commit 3b35af2

Browse files
authored
Accelerated Checkouts Tests (#289)
* Add tests for AcceleratedCheckouts * Remove iOS 16 guards in tests * Remove fromString, add == func, improve tests * Remove AcceleratedCheckoutRuntime * Remove major var from CI * Fix tests in CI
1 parent a6f7051 commit 3b35af2

File tree

8 files changed

+395
-37
lines changed

8 files changed

+395
-37
lines changed
Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
name: Setup
2-
description: Setup Node.js and install dependencies
1+
name: Setup iOS Simulator
2+
description: Prepare a simulator for a specific iOS major version
33

44
runs:
55
using: composite
@@ -10,7 +10,8 @@ runs:
1010
xcode-select -p
1111
xcrun xcodebuild -version
1212
xcrun simctl list runtimes
13-
xcrun simctl list devicetypes
13+
xcrun simctl list devicetypes | grep iPhone
1414
xcrun simctl delete all
15+
1516
CURRENT_SIMULATOR_UUID=$(xcrun simctl create TestDevice "iPhone 16 Pro")
1617
echo "CURRENT_SIMULATOR_UUID=$CURRENT_SIMULATOR_UUID" >> $GITHUB_ENV

.github/workflows/ci.yml

Lines changed: 8 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,6 @@ env:
1111
JAVA_VERSION: '22'
1212

1313
jobs:
14-
lint-swift:
15-
name: Lint Swift code
16-
runs-on: ubuntu-latest
17-
timeout-minutes: 5
18-
steps:
19-
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
20-
21-
- name: Run SwiftLint
22-
uses: norio-nomura/action-swiftlint@9f4dcd7fd46b4e75d7935cf2f4df406d5cae3684 # 3.2.1
23-
with:
24-
args: --strict
25-
2614
license:
2715
name: Verify license headers
2816
runs-on: ubuntu-latest
@@ -56,6 +44,11 @@ jobs:
5644
steps:
5745
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
5846

47+
- name: Run SwiftLint
48+
uses: norio-nomura/action-swiftlint@9f4dcd7fd46b4e75d7935cf2f4df406d5cae3684 # 3.2.1
49+
with:
50+
args: --strict
51+
5952
- name: Setup
6053
uses: ./.github/actions/setup
6154

@@ -123,10 +116,10 @@ jobs:
123116
yarn sample test:android --no-daemon
124117
125118
test-ios:
126-
name: Run iOS Tests
127-
runs-on: macos-15-xlarge
119+
name: Run Swift Tests
120+
runs-on: macos-15
128121
timeout-minutes: 20
129-
needs: [lint, lint-swift, test]
122+
needs: [lint, test]
130123
steps:
131124
- name: Checkout
132125
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
@@ -145,15 +138,6 @@ jobs:
145138
- name: Setup
146139
uses: ./.github/actions/setup
147140

148-
- name: Check turbo cache
149-
uses: ./.github/actions/use-turbo-cache
150-
151-
- name: Check build cache
152-
run: |
153-
CACHE_STATUS=$(./scripts/check_cache sample test:ios)
154-
echo "[sample] build:ios - $CACHE_STATUS"
155-
echo "turbo_cache_hit=$CACHE_STATUS" >> $GITHUB_ENV
156-
157141
- name: Install cocoapods
158142
uses: ./.github/actions/install-cocoapods
159143
with:

modules/@shopify/checkout-sheet-kit/ios/AcceleratedCheckoutButtons+Extensions.swift

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,8 @@ extension PayWithApplePayButtonLabel {
3737
return map[string] ?? .plain
3838
}
3939

40-
init?(fromString string: String?) {
41-
guard let string,
42-
let label = Self.map[string]
43-
else {
44-
return nil
45-
}
46-
self = label
40+
public static func == (lhs: PayWithApplePayButtonLabel, rhs: PayWithApplePayButtonLabel) -> Bool {
41+
return String(describing: lhs) == String(describing: rhs)
4742
}
4843

4944
private static let map: [String: PayWithApplePayButtonLabel] = [

modules/@shopify/checkout-sheet-kit/ios/AcceleratedCheckoutButtons.swift

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,14 @@ class AcceleratedCheckoutConfiguration {
5656

5757
@objc(RCTAcceleratedCheckoutButtonsManager)
5858
class RCTAcceleratedCheckoutButtonsManager: RCTViewManager {
59+
/// Internal property used in tests to simulate legacy devices
60+
internal var supported: Bool = true
61+
5962
override func view() -> UIView! {
60-
if #available(iOS 16.0, *) {
61-
return RCTAcceleratedCheckoutButtonsView()
63+
if supported {
64+
if #available(iOS 16.0, *) {
65+
return RCTAcceleratedCheckoutButtonsView()
66+
}
6267
}
6368

6469
// Return an empty view for iOS < 16.0 (silent fallback)

sample/ios/ReactNative.xcodeproj/project.pbxproj

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
13B07FC11A68108700A75B9A /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 13B07FB71A68108700A75B9A /* main.m */; };
1414
6A1F48E72B16900600BA591C /* ShopifyCheckoutSheetKitTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6A1F48E62B16900600BA591C /* ShopifyCheckoutSheetKitTests.swift */; };
1515
6A86196D2BF36EB900E5EE1A /* CheckoutDidFailTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6A86196C2BF36EB900E5EE1A /* CheckoutDidFailTests.swift */; };
16+
6AEEAAB22C00010100E5EE1B /* AcceleratedCheckouts_SupportedTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6AEEAAB02C00010100E5EE1B /* AcceleratedCheckouts_SupportedTests.swift */; };
17+
6AEEAAB32C00010100E5EE1B /* AcceleratedCheckouts_UnsupportedTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6AEEAAB12C00010100E5EE1B /* AcceleratedCheckouts_UnsupportedTests.swift */; };
1618
6AFAD2D22BA9DEF8001F9644 /* Localizable.xcstrings in Resources */ = {isa = PBXBuildFile; fileRef = 6AFAD2D12BA9DEF8001F9644 /* Localizable.xcstrings */; };
1719
81AB9BB82411601600AC10FF /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 81AB9BB72411601600AC10FF /* LaunchScreen.storyboard */; };
1820
9403907249B4B6D988902B48 /* PrivacyInfo.xcprivacy in Resources */ = {isa = PBXBuildFile; fileRef = 1939D329B2C035D1A15E316B /* PrivacyInfo.xcprivacy */; };
@@ -47,6 +49,8 @@
4749
6A8D64CF2AF25C1200FE4E4A /* ReactNative.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; name = ReactNative.entitlements; path = ReactNative/ReactNative.entitlements; sourceTree = "<group>"; };
4850
6AABC1942B17417E008240EB /* OpenSSL.xcframework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcframework; name = OpenSSL.xcframework; path = "Pods/OpenSSL-Universal/Frameworks/OpenSSL.xcframework"; sourceTree = "<group>"; };
4951
6AAEC3572B067AD500C7099B /* Entypo.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; name = Entypo.ttf; path = "../node_modules/react-native-vector-icons/Fonts/Entypo.ttf"; sourceTree = "<group>"; };
52+
6AEEAAB02C00010100E5EE1B /* AcceleratedCheckouts_SupportedTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AcceleratedCheckouts_SupportedTests.swift; sourceTree = "<group>"; };
53+
6AEEAAB12C00010100E5EE1B /* AcceleratedCheckouts_UnsupportedTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AcceleratedCheckouts_UnsupportedTests.swift; sourceTree = "<group>"; };
5054
6AF2B3762B0BCA6600C6CE4F /* ReactNative-Bridging-Header.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "ReactNative-Bridging-Header.h"; sourceTree = "<group>"; };
5155
6AFAD2D12BA9DEF8001F9644 /* Localizable.xcstrings */ = {isa = PBXFileReference; lastKnownFileType = text.json.xcstrings; name = Localizable.xcstrings; path = ReactNative/Localizable.xcstrings; sourceTree = "<group>"; };
5256
6AFC2CB62B0D5814003B5A63 /* libShopifyCheckoutSheetKit.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; path = libShopifyCheckoutSheetKit.a; sourceTree = BUILT_PRODUCTS_DIR; };
@@ -82,6 +86,8 @@
8286
00E356F01AD99517003FC87E /* Supporting Files */,
8387
6A1F48E62B16900600BA591C /* ShopifyCheckoutSheetKitTests.swift */,
8488
6A86196C2BF36EB900E5EE1A /* CheckoutDidFailTests.swift */,
89+
6AEEAAB02C00010100E5EE1B /* AcceleratedCheckouts_SupportedTests.swift */,
90+
6AEEAAB12C00010100E5EE1B /* AcceleratedCheckouts_UnsupportedTests.swift */,
8591
);
8692
path = ReactNativeTests;
8793
sourceTree = "<group>";
@@ -415,6 +421,8 @@
415421
files = (
416422
6A1F48E72B16900600BA591C /* ShopifyCheckoutSheetKitTests.swift in Sources */,
417423
6A86196D2BF36EB900E5EE1A /* CheckoutDidFailTests.swift in Sources */,
424+
6AEEAAB22C00010100E5EE1B /* AcceleratedCheckouts_SupportedTests.swift in Sources */,
425+
6AEEAAB32C00010100E5EE1B /* AcceleratedCheckouts_UnsupportedTests.swift in Sources */,
418426
);
419427
runOnlyForDeploymentPostprocessing = 0;
420428
};

0 commit comments

Comments
 (0)