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

Get web view's URL at runtime #24

Merged
merged 10 commits into from
Mar 1, 2024
15 changes: 7 additions & 8 deletions .github/workflows/run_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,23 @@ concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

on:
on:
push:
branches:
- main
pull_request:

env:
XCODEBUILD_DESTINATION_IOS: 'platform=iOS Simulator,name=iPhone 14 Pro'

jobs:
build-and-test:
runs-on: macos-latest
runs-on: macos-13
steps:
- name: Checkout repository
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Select Xcode
run: sudo xcode-select -switch /Applications/Xcode_14.2.app && /usr/bin/xcodebuild -version
uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: latest-stable

- name: Run Tests
run: xcodebuild test -project Strada.xcodeproj -scheme Strada -destination "${{ env.XCODEBUILD_DESTINATION_IOS }}" -resultBundlePath TestResults
run: xcodebuild test -scheme Strada -destination "name=iPhone 15 Pro" | xcpretty && exit ${PIPESTATUS[0]}
2 changes: 1 addition & 1 deletion Source/BridgeDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ public final class BridgeDelegate: BridgingDelegate {
@discardableResult
public func bridgeDidReceiveMessage(_ message: Message) -> Bool {
guard destinationIsActive,
location == message.metadata?.url else {
webView?.url?.absoluteString ?? location == message.metadata?.url else {
logger.warning("bridgeDidIgnoreMessage: \(String(describing: message))")
joemasilotti marked this conversation as resolved.
Show resolved Hide resolved
return false
}
Expand Down
13 changes: 11 additions & 2 deletions Tests/MessageTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ class MessageTests: XCTestCase {

// MARK: Custom encoding

func test_encodingWithCustomEncoder() {
func test_encodingWithCustomEncoder() throws {
let encoder = JSONEncoder()
encoder.keyEncodingStrategy = .convertToSnakeCase
Strada.config.jsonEncoder = encoder
Expand All @@ -204,6 +204,15 @@ class MessageTests: XCTestCase {

let newMessage = message.replacing(data: messageData)

XCTAssertEqual(message, newMessage)
XCTAssertEqual(message.id, newMessage.id)
XCTAssertEqual(message.event, newMessage.event)
XCTAssertEqual(message.metadata, newMessage.metadata)

// JSON as a string might have keys in a different order. Parse values to ensure equality.
let newMessageData = try XCTUnwrap(message.jsonData.jsonObject() as? [String: String])
XCTAssertEqual(newMessageData.keys.count, 3)
XCTAssertEqual(newMessageData["title"], "Page-title")
XCTAssertEqual(newMessageData["subtitle"], "Page-subtitle")
XCTAssertEqual(newMessageData["action_name"], "go")
joemasilotti marked this conversation as resolved.
Show resolved Hide resolved
}
}
Loading