-
Notifications
You must be signed in to change notification settings - Fork 3
YPE-1565: Show error when YouVersionProvider has no appKey #264
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
6cd9b71
YPE-1565: fix(ui): show error when YouVersionProvider has no appKey
cameronapak 243cf88
fix(ui): remove redundant aria-live on alert role
cameronapak 084a7e6
Consolidate missing app key error messages
cameronapak 5948dbf
test(ui): align missing-app-key tests with consolidated error copy
cameronapak a3df96e
Merge branch 'main' into YPE-1565-missing-app-key-error
camrun91 41e3473
Merge branch 'main' into YPE-1565-missing-app-key-error
cameronapak 8773650
Merge branch 'main' into YPE-1565-missing-app-key-error
cameronapak e5a3f03
Merge branch 'main' into YPE-1565-missing-app-key-error
cameronapak 2ddd583
refactor(hooks): move appKey guard to wrapper to keep hook order stable
cameronapak 3574f99
Merge branch 'main' into YPE-1565-missing-app-key-error
cameronapak 434e9fe
refactor(ui): log missing-appKey guidance from an effect
cameronapak File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| --- | ||
| '@youversion/platform-react-hooks': minor | ||
| '@youversion/platform-react-ui': minor | ||
| --- | ||
|
|
||
| Surface a clear error when `YouVersionProvider` is given a missing or empty `appKey` instead of rendering a blank page. The UI provider now renders a styled "Missing app key" message, and the hooks provider throws a descriptive error for hooks-only consumers. |
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
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,60 @@ | ||
| import type { Meta, StoryObj } from '@storybook/react-vite'; | ||
| import { within, expect, waitFor } from 'storybook/test'; | ||
| import { MissingAppKey } from './missing-app-key'; | ||
|
|
||
| const meta = { | ||
| title: 'Components/MissingAppKey', | ||
| component: MissingAppKey, | ||
| parameters: { | ||
| layout: 'fullscreen', | ||
| }, | ||
| render: (args) => ( | ||
| <div className="yv:w-full yv:max-w-md"> | ||
| <MissingAppKey {...args} /> | ||
| </div> | ||
| ), | ||
| tags: ['autodocs'], | ||
| argTypes: { | ||
| theme: { | ||
| control: 'inline-radio', | ||
| options: ['light', 'dark'], | ||
| description: 'Color theme for the message', | ||
| }, | ||
| }, | ||
| } satisfies Meta<typeof MissingAppKey>; | ||
|
|
||
| export default meta; | ||
|
|
||
| type Story = StoryObj<typeof meta>; | ||
|
|
||
| export const Light: Story = { | ||
| args: { | ||
| theme: 'light', | ||
| }, | ||
| }; | ||
|
|
||
| export const Dark: Story = { | ||
| args: { | ||
| theme: 'dark', | ||
| }, | ||
| parameters: { | ||
| backgrounds: { default: 'dark' }, | ||
| }, | ||
| }; | ||
|
|
||
| export const RendersMessage: Story = { | ||
| args: { | ||
| theme: 'light', | ||
| }, | ||
| tags: ['integration'], | ||
| play: async ({ canvasElement }) => { | ||
| const canvas = within(canvasElement); | ||
|
|
||
| await waitFor(async () => { | ||
| await expect(canvas.getByRole('alert')).toBeInTheDocument(); | ||
| }); | ||
|
|
||
| await expect(canvas.getByText('Error')).toBeInTheDocument(); | ||
| await expect(canvas.getByText(/app key/)).toBeInTheDocument(); | ||
| }, | ||
| }; |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| 'use client'; | ||
|
|
||
| import React from 'react'; | ||
| import { useTranslation } from 'react-i18next'; | ||
| import i18n from '@/i18n'; | ||
| import { ExclamationCircle } from '@/components/icons/exclamation-circle'; | ||
|
|
||
| /** | ||
| * Styled panel shown by {@link YouVersionProvider} when no (or an empty) | ||
| * `appKey` is supplied. Replaces the provider's children so a misconfigured app | ||
| * surfaces an actionable message instead of a blank page. | ||
| */ | ||
| export function MissingAppKey({ | ||
| theme = 'light', | ||
| }: { | ||
| theme?: 'light' | 'dark'; | ||
| }): React.ReactElement { | ||
| const { t } = useTranslation(undefined, { i18n }); | ||
|
|
||
| return ( | ||
| <div | ||
| data-yv-sdk | ||
| data-yv-theme={theme} | ||
| role="alert" | ||
| className="yv:flex yv:items-start yv:gap-2.5 yv:p-4 yv:bg-background yv:text-foreground" | ||
| > | ||
| <ExclamationCircle className="yv:size-5 yv:shrink-0 yv:text-foreground" aria-hidden="true" /> | ||
| <div className="yv:flex yv:flex-col yv:gap-1"> | ||
| <p className="yv:m-0 yv:text-sm yv:font-semibold yv:leading-tight">{t('errorHeading')}</p> | ||
| <p className="yv:m-0 yv:text-[13px] yv:font-medium yv:leading-snug yv:text-muted-foreground"> | ||
| {t('invalidAppKeyError')} | ||
| </p> | ||
| </div> | ||
| </div> | ||
| ); | ||
| } |
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.