Skip to content

Commit 376528f

Browse files
committed
fix: resolve CI failures — Tag.category not in SDK, async test assertions
RiveLog.Tag doesn't have a .category property in the installed SDK version (6.18.0) — use a local switch to map tag cases to strings. Also wrap deprecation assertions in waitFor to handle async Nitro callback delivery on Android.
1 parent af01bd0 commit 376528f

File tree

2 files changed

+44
-18
lines changed

2 files changed

+44
-18
lines changed

example/__tests__/rivelog.harness.tsx

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { describe, it, expect, cleanup } from 'react-native-harness';
1+
import { describe, it, expect, waitFor, cleanup } from 'react-native-harness';
22
import { RiveFileFactory, RiveLog } from '@rive-app/react-native';
33

44
const BOUNCING_BALL = require('../assets/rive/bouncing_ball.riv');
@@ -16,11 +16,16 @@ describe('RiveLog', () => {
1616

1717
file.defaultArtboardViewModel();
1818

19-
const deprecation = logs.find((l) => l.tag === 'Deprecation');
20-
expect(deprecation).toBeDefined();
21-
expect(deprecation!.level).toBe('warn');
22-
expect(deprecation!.message).toContain('defaultArtboardViewModel');
23-
expect(deprecation!.message).toContain('defaultArtboardViewModelAsync');
19+
await waitFor(
20+
() => {
21+
const deprecation = logs.find((l) => l.tag === 'Deprecation');
22+
expect(deprecation).toBeDefined();
23+
expect(deprecation!.level).toBe('warn');
24+
expect(deprecation!.message).toContain('defaultArtboardViewModel');
25+
expect(deprecation!.message).toContain('defaultArtboardViewModelAsync');
26+
},
27+
{ timeout: 2000 }
28+
);
2429

2530
RiveLog.resetHandler();
2631
cleanup();
@@ -39,10 +44,15 @@ describe('RiveLog', () => {
3944
file.artboardNames;
4045
file.artboardNames;
4146

42-
const deprecations = logs.filter(
43-
(l) => l.tag === 'Deprecation' && l.message.includes('artboardNames')
47+
await waitFor(
48+
() => {
49+
const deprecations = logs.filter(
50+
(l) => l.tag === 'Deprecation' && l.message.includes('artboardNames')
51+
);
52+
expect(deprecations.length).toBe(1);
53+
},
54+
{ timeout: 2000 }
4455
);
45-
expect(deprecations.length).toBe(1);
4656

4757
RiveLog.resetHandler();
4858
cleanup();
@@ -70,7 +80,6 @@ describe('RiveLog', () => {
7080

7181
file.viewModelByName('nonexistent');
7282

73-
// If we got here without throwing, the default handler works.
7483
expect(true).toBe(true);
7584

7685
cleanup();

ios/new/RiveRuntimeLogger.swift

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,56 @@
11
@_spi(RiveExperimental) import RiveRuntime
22

3+
private func tagName(_ tag: RiveRuntime.RiveLog.Tag) -> String {
4+
switch tag {
5+
case .rive: return "Rive"
6+
case .worker: return "Worker"
7+
case .file: return "File"
8+
case .artboard: return "Artboard"
9+
case .stateMachine: return "StateMachine"
10+
case .viewModelInstance: return "ViewModelInstance"
11+
case .image: return "Image"
12+
case .font: return "Font"
13+
case .audio: return "Audio"
14+
case .view: return "RiveUIView"
15+
case .custom(let name): return name
16+
@unknown default: return "Unknown"
17+
}
18+
}
19+
320
/// Implements the Rive iOS SDK's `RiveLog.Logger` protocol and forwards all
421
/// C++ runtime logs through our bridge-level `RiveLog` utility, giving JS
522
/// visibility into file, artboard, state machine, and view model diagnostics.
623
final class RiveRuntimeLogger: RiveRuntime.RiveLog.Logger, @unchecked Sendable {
724
func notice(tag: RiveRuntime.RiveLog.Tag, _ message: @escaping () -> String) {
8-
RiveLog.i(tag.category, message())
25+
RiveLog.i(tagName(tag), message())
926
}
1027

1128
func debug(tag: RiveRuntime.RiveLog.Tag, _ message: @escaping () -> String) {
12-
RiveLog.d(tag.category, message())
29+
RiveLog.d(tagName(tag), message())
1330
}
1431

1532
func trace(tag: RiveRuntime.RiveLog.Tag, _ message: @escaping () -> String) {
16-
RiveLog.d(tag.category, message())
33+
RiveLog.d(tagName(tag), message())
1734
}
1835

1936
func info(tag: RiveRuntime.RiveLog.Tag, _ message: @escaping () -> String) {
20-
RiveLog.i(tag.category, message())
37+
RiveLog.i(tagName(tag), message())
2138
}
2239

2340
func error(tag: RiveRuntime.RiveLog.Tag, error: (any Error)?, _ message: @escaping () -> String) {
2441
let suffix = error.map { " (\($0.localizedDescription))" } ?? ""
25-
RiveLog.e(tag.category, "\(message())\(suffix)")
42+
RiveLog.e(tagName(tag), "\(message())\(suffix)")
2643
}
2744

2845
func warning(tag: RiveRuntime.RiveLog.Tag, _ message: @escaping () -> String) {
29-
RiveLog.w(tag.category, message())
46+
RiveLog.w(tagName(tag), message())
3047
}
3148

3249
func fault(tag: RiveRuntime.RiveLog.Tag, _ message: @escaping () -> String) {
33-
RiveLog.e(tag.category, message())
50+
RiveLog.e(tagName(tag), message())
3451
}
3552

3653
func critical(tag: RiveRuntime.RiveLog.Tag, _ message: @escaping () -> String) {
37-
RiveLog.e(tag.category, message())
54+
RiveLog.e(tagName(tag), message())
3855
}
3956
}

0 commit comments

Comments
 (0)