also looking at this
test(ios): preserve native shortcuts through bundle initialization
#423
3 files
+91
-0
Review threads live on the whole diff, not on one commit, so none are shown here - a thread's line means something in the branch's final form, and painting it into an intermediate step would put it on code it is not about.
| @@ -646,6 +646,19 @@ describe('Craft iOS builder', () => { | ||
| 646 | 646 | expect(source).toContain('guard width > 0, abs(width - reportedViewportWidth) >= 0.5 else { return }') |
| 647 | 647 | }) |
| 648 | 648 | |
| 649 | it('keeps the shortcuts module present on a native screen, answering unsupported', () => { | |
| 650 | // Added in 17e09f4d and deleted 28 minutes later by a merge from main | |
| 651 | // (b1f32471) that nothing caught, because nothing asserted on it. The | |
| 652 | // module has to exist even though a JavaScriptCore screen cannot register | |
| 653 | // quick actions: without it `craft.shortcuts` is undefined and STX falls | |
| 654 | // through to an undefined namespace instead of answering `unsupported`. | |
| 655 | const source = readFileSync(join(import.meta.dir, '..', 'templates', 'CraftNativeScreen.swift'), 'utf8') | |
| 656 | expect(source).toContain("keep('shortcuts', {") | |
| 657 | expect(source).toContain('set: function() { return Promise.resolve(false); }') | |
| 658 | expect(source).toContain('clear: function() { return Promise.resolve(false); }') | |
| 659 | expect(source).toContain('onShortcut: function() { return function() {}; }') | |
| 660 | }) | |
| 661 | ||
| 649 | 662 | it('advertises mounted-view focus and measurement in native screens', () => { |
| 650 | 663 | const source = readFileSync(join(import.meta.dir, '..', 'templates', 'CraftNativeScreen.swift'), 'utf8') |
| 651 | 664 | const actions = readFileSync(join(import.meta.dir, '..', 'templates', 'CraftNativeActions.swift'), 'utf8') |
| @@ -7017,6 +7017,15 @@ final class CraftNativeScreenController: UIViewController, UIScrollViewDelegate, | ||
| 7017 | 7017 | keep('navigation', { |
| 7018 | 7018 | setOptions: function(options) { craftNativeSetOptions(JSON.stringify(options || {})); } |
| 7019 | 7019 | }); |
| 7020 | // Dynamic home-screen quick actions belong to the app shell, | |
| 7021 | // not an individual JavaScriptCore screen. Keep the typed | |
| 7022 | // module present so STX can answer `unsupported` honestly | |
| 7023 | // instead of falling through to an undefined namespace. | |
| 7024 | keep('shortcuts', { | |
| 7025 | set: function() { return Promise.resolve(false); }, | |
| 7026 | clear: function() { return Promise.resolve(false); }, | |
| 7027 | onShortcut: function() { return function() {}; } | |
| 7028 | }); | |
| 7020 | 7029 | })(); |
| 7021 | 7030 | """) |
| 7022 | 7031 | } |