@react-native-harness/platform-android 1.4.0 → 1.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (60) hide show
  1. package/package.json +4 -4
  2. package/dist/__tests__/adb-id.test.d.ts +0 -2
  3. package/dist/__tests__/adb-id.test.d.ts.map +0 -1
  4. package/dist/__tests__/adb-id.test.js +0 -41
  5. package/dist/__tests__/adb-wait.test.d.ts +0 -2
  6. package/dist/__tests__/adb-wait.test.d.ts.map +0 -1
  7. package/dist/__tests__/adb-wait.test.js +0 -69
  8. package/dist/__tests__/adb.test.d.ts +0 -2
  9. package/dist/__tests__/adb.test.d.ts.map +0 -1
  10. package/dist/__tests__/adb.test.js +0 -552
  11. package/dist/__tests__/app-monitor.test.d.ts +0 -2
  12. package/dist/__tests__/app-monitor.test.d.ts.map +0 -1
  13. package/dist/__tests__/app-monitor.test.js +0 -257
  14. package/dist/__tests__/app-session.test.d.ts +0 -2
  15. package/dist/__tests__/app-session.test.d.ts.map +0 -1
  16. package/dist/__tests__/app-session.test.js +0 -57
  17. package/dist/__tests__/avd-config.test.d.ts +0 -2
  18. package/dist/__tests__/avd-config.test.d.ts.map +0 -1
  19. package/dist/__tests__/avd-config.test.js +0 -232
  20. package/dist/__tests__/ci-action.test.d.ts +0 -2
  21. package/dist/__tests__/ci-action.test.d.ts.map +0 -1
  22. package/dist/__tests__/ci-action.test.js +0 -46
  23. package/dist/__tests__/crash-diagnostics.test.d.ts +0 -2
  24. package/dist/__tests__/crash-diagnostics.test.d.ts.map +0 -1
  25. package/dist/__tests__/crash-diagnostics.test.js +0 -119
  26. package/dist/__tests__/crash-parser.test.d.ts +0 -2
  27. package/dist/__tests__/crash-parser.test.d.ts.map +0 -1
  28. package/dist/__tests__/crash-parser.test.js +0 -45
  29. package/dist/__tests__/crash-reporter.test.d.ts +0 -2
  30. package/dist/__tests__/crash-reporter.test.d.ts.map +0 -1
  31. package/dist/__tests__/crash-reporter.test.js +0 -150
  32. package/dist/__tests__/emulator-startup.test.d.ts +0 -2
  33. package/dist/__tests__/emulator-startup.test.d.ts.map +0 -1
  34. package/dist/__tests__/emulator-startup.test.js +0 -47
  35. package/dist/__tests__/environment.test.d.ts +0 -2
  36. package/dist/__tests__/environment.test.d.ts.map +0 -1
  37. package/dist/__tests__/environment.test.js +0 -117
  38. package/dist/__tests__/instance.test.d.ts +0 -2
  39. package/dist/__tests__/instance.test.d.ts.map +0 -1
  40. package/dist/__tests__/instance.test.js +0 -599
  41. package/dist/__tests__/shared-prefs.test.d.ts +0 -2
  42. package/dist/__tests__/shared-prefs.test.d.ts.map +0 -1
  43. package/dist/__tests__/shared-prefs.test.js +0 -87
  44. package/dist/__tests__/targets.test.d.ts +0 -2
  45. package/dist/__tests__/targets.test.d.ts.map +0 -1
  46. package/dist/__tests__/targets.test.js +0 -49
  47. package/dist/tsconfig.lib.tsbuildinfo +0 -1
  48. package/src/__tests__/adb-id.test.ts +0 -51
  49. package/src/__tests__/adb-wait.test.ts +0 -95
  50. package/src/__tests__/app-session.test.ts +0 -76
  51. package/src/__tests__/avd-config.test.ts +0 -276
  52. package/src/__tests__/ci-action.test.ts +0 -81
  53. package/src/__tests__/crash-diagnostics.test.ts +0 -144
  54. package/src/__tests__/crash-parser.test.ts +0 -52
  55. package/src/__tests__/crash-reporter.test.ts +0 -167
  56. package/src/__tests__/emulator-startup.test.ts +0 -82
  57. package/src/__tests__/instance.test.ts +0 -844
  58. package/src/__tests__/shared-prefs.test.ts +0 -144
  59. package/src/__tests__/targets.test.ts +0 -53
  60. package/tsconfig.tsbuildinfo +0 -1
@@ -1,144 +0,0 @@
1
- import { afterEach, describe, expect, it, vi } from 'vitest';
2
- import * as tools from '@react-native-harness/tools';
3
- import {
4
- applyHarnessDebugHttpHost,
5
- clearHarnessDebugHttpHost,
6
- } from '../shared-prefs.js';
7
-
8
- const bundleId = 'com.example.app';
9
- const adbId = 'emulator-5554';
10
-
11
- const getWrittenContent = (
12
- calls: ReadonlyArray<readonly unknown[]>
13
- ): string => {
14
- const writeCall = calls.find(([, , options]) => {
15
- if (!options || typeof options !== 'object' || !('stdin' in options)) {
16
- return false;
17
- }
18
-
19
- return Boolean(options.stdin);
20
- });
21
- const options = writeCall?.[2];
22
-
23
- if (!options || typeof options !== 'object' || !('stdin' in options)) {
24
- throw new Error('Expected write call options.');
25
- }
26
-
27
- const content = options.stdin;
28
-
29
- if (
30
- !content ||
31
- typeof content !== 'object' ||
32
- !('string' in content) ||
33
- typeof content.string !== 'string'
34
- ) {
35
- throw new Error('Expected write call with string stdin.');
36
- }
37
-
38
- return content.string;
39
- };
40
-
41
- const getWrittenContents = (
42
- calls: ReadonlyArray<readonly unknown[]>
43
- ): string[] =>
44
- calls
45
- .filter(([, , options]) => {
46
- if (!options || typeof options !== 'object' || !('stdin' in options)) {
47
- return false;
48
- }
49
-
50
- return Boolean(options.stdin);
51
- })
52
- .map((call) => getWrittenContent([call]));
53
-
54
- describe('Android shared preferences Metro host override', () => {
55
- afterEach(() => {
56
- vi.restoreAllMocks();
57
- });
58
-
59
- it('handles empty self-closing map files', async () => {
60
- const spawnSpy = vi
61
- .spyOn(tools, 'spawn')
62
- .mockResolvedValueOnce({
63
- stdout: '<?xml version="1.0" encoding="utf-8"?>\n<map />\n',
64
- } as Awaited<ReturnType<typeof tools.spawn>>)
65
- .mockResolvedValueOnce({} as Awaited<ReturnType<typeof tools.spawn>>);
66
-
67
- await applyHarnessDebugHttpHost(adbId, bundleId, 'localhost:9090');
68
-
69
- expect(getWrittenContent(spawnSpy.mock.calls)).toContain('<map>');
70
- expect(getWrittenContent(spawnSpy.mock.calls)).toContain('</map>');
71
- expect(getWrittenContent(spawnSpy.mock.calls)).toContain(
72
- '<string name="debug_http_host">localhost:9090</string>'
73
- );
74
- });
75
-
76
- it('restores the previous debug host on cleanup', async () => {
77
- const spawnSpy = vi
78
- .spyOn(tools, 'spawn')
79
- .mockResolvedValueOnce({
80
- stdout: [
81
- '<?xml version="1.0" encoding="utf-8"?>',
82
- '<map>',
83
- ' <string name="debug_http_host">10.0.2.2:8081</string>',
84
- '</map>',
85
- ].join('\n'),
86
- } as Awaited<ReturnType<typeof tools.spawn>>)
87
- .mockResolvedValueOnce({} as Awaited<ReturnType<typeof tools.spawn>>)
88
- .mockResolvedValueOnce({
89
- stdout: [
90
- '<?xml version="1.0" encoding="utf-8"?>',
91
- '<map>',
92
- ' <string name="debug_http_host">10.0.2.2:8081</string>',
93
- ' <!-- react-native-harness:debug_http_host:start -->',
94
- ' <string name="debug_http_host">localhost:9090</string>',
95
- ' <!-- react-native-harness:debug_http_host:end -->',
96
- '</map>',
97
- ].join('\n'),
98
- } as Awaited<ReturnType<typeof tools.spawn>>)
99
- .mockResolvedValueOnce({} as Awaited<ReturnType<typeof tools.spawn>>);
100
-
101
- await applyHarnessDebugHttpHost(adbId, bundleId, 'localhost:9090');
102
- await clearHarnessDebugHttpHost(adbId, bundleId);
103
-
104
- const writes = getWrittenContents(spawnSpy.mock.calls);
105
- const firstWrite = writes[0];
106
- const secondWrite = writes[1];
107
-
108
- expect(firstWrite).toEqual(
109
- expect.stringContaining(
110
- '<string name="harness_debug_http_host_backup">10.0.2.2:8081</string>'
111
- )
112
- );
113
- expect(firstWrite).toEqual(
114
- expect.stringContaining(
115
- '<string name="debug_http_host">localhost:9090</string>'
116
- )
117
- );
118
- expect(firstWrite).toEqual(
119
- expect.not.stringContaining(
120
- '<string name="debug_http_host">10.0.2.2:8081</string>'
121
- )
122
- );
123
- expect(secondWrite).toEqual(
124
- expect.stringContaining(
125
- '<string name="debug_http_host">10.0.2.2:8081</string>'
126
- )
127
- );
128
- expect(secondWrite).toEqual(
129
- expect.not.stringContaining(
130
- '<string name="harness_debug_http_host_backup">10.0.2.2:8081</string>'
131
- )
132
- );
133
- expect(secondWrite).toEqual(
134
- expect.not.stringContaining(
135
- '<!-- react-native-harness:debug_http_host:start -->'
136
- )
137
- );
138
- expect(secondWrite).toEqual(
139
- expect.not.stringContaining(
140
- '<string name="debug_http_host">localhost:9090</string>'
141
- )
142
- );
143
- });
144
- });
@@ -1,53 +0,0 @@
1
- import { beforeEach, describe, expect, it, vi } from 'vitest';
2
- import { getRunTargets } from '../targets.js';
3
- import * as adb from '../adb.js';
4
- import * as environment from '../environment.js';
5
-
6
- describe('Android target discovery', () => {
7
- beforeEach(() => {
8
- vi.restoreAllMocks();
9
- vi.unstubAllEnvs();
10
- });
11
-
12
- it('installs adb and emulator only for discovery', async () => {
13
- const ensureAndroidAdbAvailable = vi
14
- .spyOn(environment, 'ensureAndroidAdbAvailable')
15
- .mockResolvedValue('/tmp/android-sdk');
16
- const ensureAndroidEmulatorAvailable = vi
17
- .spyOn(environment, 'ensureAndroidEmulatorAvailable')
18
- .mockResolvedValue('/tmp/android-sdk');
19
- vi.spyOn(adb, 'getAvds').mockResolvedValue(['Pixel_8_API_35']);
20
- vi.spyOn(adb, 'getConnectedDevices').mockResolvedValue([
21
- {
22
- id: 'device-1',
23
- manufacturer: 'Google',
24
- model: 'Pixel 8',
25
- },
26
- ]);
27
-
28
- await expect(getRunTargets()).resolves.toEqual([
29
- {
30
- type: 'emulator',
31
- name: 'Pixel_8_API_35',
32
- platform: 'android',
33
- description: 'Android emulator',
34
- device: {
35
- name: 'Pixel_8_API_35',
36
- },
37
- },
38
- {
39
- type: 'physical',
40
- name: 'Google Pixel 8',
41
- platform: 'android',
42
- description: 'Physical device (device-1)',
43
- device: {
44
- manufacturer: 'Google',
45
- model: 'Pixel 8',
46
- },
47
- },
48
- ]);
49
-
50
- expect(ensureAndroidAdbAvailable).toHaveBeenCalledTimes(1);
51
- expect(ensureAndroidEmulatorAvailable).toHaveBeenCalledTimes(1);
52
- });
53
- });
@@ -1 +0,0 @@
1
- {"fileNames":[],"fileInfos":[],"root":[],"options":{"composite":true,"declarationMap":true,"emitDeclarationOnly":true,"importHelpers":true,"module":199,"noEmitOnError":true,"noFallthroughCasesInSwitch":true,"noImplicitOverride":true,"noImplicitReturns":true,"noUnusedLocals":true,"skipLibCheck":true,"strict":true,"target":9},"version":"5.9.3"}