diff --git a/.changeset/launch-argument-name-spaces.md b/.changeset/launch-argument-name-spaces.md new file mode 100644 index 0000000000..b06f6a2ada --- /dev/null +++ b/.changeset/launch-argument-name-spaces.md @@ -0,0 +1,5 @@ +--- +'@e2e-dev/core': patch +--- + +Accept spaces inside a name in the object form of `app.launchArguments`, so a user-defaults key such as `'NSSplitView Subview Frames Main'` no longer fails with `INVALID_CONFIG`. A name with a control character, a space at either end, or any other whitespace is still refused. diff --git a/docs/reference/config.mdx b/docs/reference/config.mdx index 8fe7ce5a01..0c5b30c8b5 100644 --- a/docs/reference/config.mdx +++ b/docs/reference/config.mdx @@ -599,9 +599,11 @@ type LaunchArguments = readonly string[] | Readonly { expect(() => resolveApp({ launchArguments: null } as never)).toThrow(`${shape}, got null`); expect(() => resolveApp({ launchArguments: new Map([['AppleLocale', 'fr_FR']]) } as never)).toThrow(`${shape}, got a Map`); expect(() => resolveApp({ launchArguments: { '': 'x' } })).toThrow('target "web" app.launchArguments has an empty argument name'); - expect(() => resolveApp({ launchArguments: { 'Apple Locale': 'fr_FR' } })).toThrow( - 'target "web" app.launchArguments argument name "Apple Locale" must have no whitespace or control characters', - ); + expect(resolveApp({ bundleId: 'dev.shop.app', launchArguments: { 'NSSplitView Subview Frames Main': ['0, 0, 200, 600'] } }).launchArguments).toEqual({ + 'NSSplitView Subview Frames Main': ['0, 0, 200, 600'], + }); + for (const name of [' AppleLocale', 'AppleLocale ']) { + expect(() => resolveApp({ launchArguments: { [name]: 'fr_FR' } })).toThrow( + `target "web" app.launchArguments argument name ${JSON.stringify(name)} must not start or end with a space`, + ); + } + for (const name of ['Apple\tLocale', 'Apple\u00a0Locale', 'Apple\u2028Locale']) { + expect(() => resolveApp({ launchArguments: { [name]: 'fr_FR' } })).toThrow( + `target "web" app.launchArguments argument name ${JSON.stringify(name)} must have no control characters and no whitespace other than a space`, + ); + } expect(() => resolveApp({ launchArguments: { '-AppleLocale': 'fr_FR' } })).toThrow( 'target "web" app.launchArguments argument name "-AppleLocale" starts with a dash; remove the dash, the engine adds it', ); - expect(() => resolveApp({ launchArguments: { 'a\u0000b': 'x' } })).toThrow('argument name "a\\u0000b" must have no whitespace or control characters'); + expect(() => resolveApp({ launchArguments: { 'a\u0000b': 'x' } })).toThrow('argument name "a\\u0000b" must have no control characters and no whitespace other than a space'); expect(() => resolveApp({ launchArguments: { env: 'a\u0000' } })).toThrow('target "web" app.launchArguments.env holds a NUL character'); expect(() => resolveApp({ launchArguments: { tags: ['a', 'b\u0000'] } })).toThrow('target "web" app.launchArguments.tags holds a NUL character'); expect(() => resolveApp({ launchArguments: ['-a', 'b\u0000'] })).toThrow('target "web" app.launchArguments item 1 holds a NUL character'); diff --git a/packages/mobile/tests/unit/launch-arguments.test.ts b/packages/mobile/tests/unit/launch-arguments.test.ts index 229ca15bc4..8999e9724b 100644 --- a/packages/mobile/tests/unit/launch-arguments.test.ts +++ b/packages/mobile/tests/unit/launch-arguments.test.ts @@ -74,6 +74,12 @@ describe('launchArgumentList', () => { ]); expect(launchArgumentList('android', { tags: ['a', 'b c', 'd'] })).toEqual(['--esa', 'tags', 'a,b c,d']); }); + + // Characterization: the list never split names; the config check is what now lets a spaced name through. + it('passes a name with spaces through as one argument', () => { + expect(launchArgumentList('ios', { 'NSSplitView Subview Frames Main': ['0, 0, 200, 600'] })).toEqual(['-NSSplitView Subview Frames Main', '("0, 0, 200, 600")']); + expect(launchArgumentList('android', { 'mock server': 'http://localhost:9001' })).toEqual(['--es', 'mock server', 'http://localhost:9001']); + }); }); describe('assertLaunchArgumentsFor', () => {