Repository navigation
fix: render error pages and mail without @arkstack/view installed - #29
Merged
Merged
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Apps that don't install
@arkstack/viewcrashed withglobalThis.view is not a functionwhenever an HTML error page was rendered, becauserenderError()in@arkstack/commoncalled theview()global unconditionally.MailNotificationhad the same problem when no.html()template was set.@arkstack/common: newErrorPageclass. It renders~arkstack/common.errorthroughview()when the global is registered, and falls back to a built-in (escaped) HTML document otherwise.renderError()keeps its signature and delegates to it, so the express/h3/fastify error handlers need no changes.@arkstack/notifications:MailNotification.renderHtml()uses the html template, then the view, then a built-in layout matchingmail.edge. A custom.view(...)without@arkstack/viewinstalled throws a clear error instead of theTypeError.This mirrors how
@arkstack/inertiaalready falls back tobuiltInTemplate()when the view layer is missing.Tests
packages/common/tests/error-page.test.ts: fallback page, stack omission, and rendering through the view global.packages/notifications/tests/notification.test.ts: built-in mail layout without the view global, and the error for a custom view.Six existing notification mail tests fail locally both before and after this change (
Package views directory not found, because the sandbox has no builtnode_modules/@arkstack/notifications/resources/views); they're unrelated to this diff.