-
Notifications
You must be signed in to change notification settings - Fork 2
IS-11346: render page symbols for HAAPI steps #210
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
Open
aleixsuau
wants to merge
17
commits into
integration/IS-5161/login-web-app
Choose a base branch
from
feature/IS-5161/IS-11346-display-page-symbols
base: integration/IS-5161/login-web-app
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
1432273
IS-11346: render page symbols for HAAPI steps
aleixsuau a038fc1
IS-11346: prettier
aleixsuau b2dd1d0
IS-11346: refcator to use exec
aleixsuau f442182
IS-11346: add AppConfigContext to previewer
aleixsuau 683f709
IS-11346: render page symbols for HAAPI steps
aleixsuau f0f560e
IS-11346: prettier
aleixsuau 7a7f23c
IS-11346: refcator to use exec
aleixsuau eca8653
IS-11346: add AppConfigContext to previewer
aleixsuau 9a8a0ad
Merge branch 'feature/IS-5161/IS-11346-display-page-symbols' of githu…
aleixsuau 87f95aa
IS-5161 IS-11346 wrap page symbol in figure and use CSS variables for…
9b857f7
IS-11346: render page symbols for HAAPI steps
aleixsuau 08a16ce
IS-11346: prettier
aleixsuau 0fbeaae
IS-11346: refcator to use exec
aleixsuau 1d2df7d
IS-11346: add AppConfigContext to previewer
aleixsuau b16b5b6
IS-5161 IS-11346 wrap page symbol in figure and use CSS variables for…
fb5cc93
IS-11346: fix tests
aleixsuau 1d5dfca
IS-11346: fix tests
aleixsuau 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
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
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 |
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,121 @@ | ||
| /* | ||
| * Copyright (C) 2026 Curity AB. All rights reserved. | ||
| * | ||
| * The contents of this file are the property of Curity AB. | ||
| * You may not copy or use this file, in either source code | ||
| * or executable form, except in compliance with terms | ||
| * set by Curity AB. | ||
| * | ||
| * For further information, please contact Curity AB. | ||
| */ | ||
|
|
||
| import { describe, expect, it } from 'vitest'; | ||
| import { render } from '@testing-library/react'; | ||
| import { PageSymbol } from './PageSymbol'; | ||
| import { AppConfigContext } from '../feature/app-config/AppConfigContext'; | ||
| import type { BootstrapConfiguration, PageSymbols } from '../../haapi-stepper/data-access/bootstrap-configuration'; | ||
|
|
||
| const buildConfig = (pageSymbols?: PageSymbols): BootstrapConfiguration => ({ | ||
| initialUrl: 'https://example/start', | ||
| haapi: {} as BootstrapConfiguration['haapi'], | ||
| theme: { | ||
| logo: { path: '/assets/logo.svg', isInsideWell: false }, | ||
| pageSymbols, | ||
| }, | ||
| }); | ||
|
|
||
| const renderPageSymbol = (viewName: string | undefined, pageSymbols?: PageSymbols) => | ||
| render( | ||
| <AppConfigContext value={buildConfig(pageSymbols)}> | ||
| <PageSymbol viewName={viewName} /> | ||
| </AppConfigContext> | ||
| ); | ||
|
|
||
| describe('PageSymbol', () => { | ||
| const pageSymbols: PageSymbols = { | ||
| views: { | ||
| 'authenticator/html-form/create-account/post': '/symbols/create-account.svg', | ||
| 'authentication-action/email-verifier/confirm': '/symbols/email-verifier-confirm.svg', | ||
| 'consentor/scope-consent/review': '/symbols/scope-consent-review.svg', | ||
| }, | ||
| plugins: { | ||
| 'html-form': '/symbols/html-form.svg', | ||
| 'email-verifier': '/symbols/email-verifier.svg', | ||
| 'scope-consent': '/symbols/scope-consent.svg', | ||
| }, | ||
| default: '/symbols/default.svg', | ||
| }; | ||
|
|
||
| it.each([ | ||
| ['authenticator', 'authenticator/html-form/create-account/post', '/symbols/create-account.svg'], | ||
| ['authentication-action', 'authentication-action/email-verifier/confirm', '/symbols/email-verifier-confirm.svg'], | ||
| ['consentor', 'consentor/scope-consent/review', '/symbols/scope-consent-review.svg'], | ||
| ])( | ||
| 'renders the exact `views` entry for the %s category even when a plugin or default would also match', | ||
| (_, viewName, expected) => { | ||
| renderPageSymbol(viewName, pageSymbols); | ||
| expect(document.querySelector<HTMLImageElement>('img.haapi-stepper-page-symbol')).toHaveAttribute( | ||
| 'src', | ||
| expected | ||
| ); | ||
| } | ||
| ); | ||
|
|
||
| it.each([ | ||
| ['authenticator', 'authenticator/html-form/index', '/symbols/html-form.svg'], | ||
| ['authentication-action', 'authentication-action/email-verifier/verify', '/symbols/email-verifier.svg'], | ||
| ['consentor', 'consentor/scope-consent/consent', '/symbols/scope-consent.svg'], | ||
| ])( | ||
| 'falls back to the plugin-type entry for the %s category when no `views` entry matches', | ||
| (_, viewName, expected) => { | ||
| renderPageSymbol(viewName, pageSymbols); | ||
| expect(document.querySelector<HTMLImageElement>('img.haapi-stepper-page-symbol')).toHaveAttribute( | ||
| 'src', | ||
| expected | ||
| ); | ||
| } | ||
| ); | ||
|
|
||
| it('falls back to `default` when neither `views` nor `plugins` matches', () => { | ||
| renderPageSymbol('authenticator/unknown-plugin/index', pageSymbols); | ||
| expect(document.querySelector<HTMLImageElement>('img.haapi-stepper-page-symbol')).toHaveAttribute( | ||
| 'src', | ||
| '/symbols/default.svg' | ||
| ); | ||
| }); | ||
|
|
||
| it('falls back to `default` when the viewName is outside the three plugin categories', () => { | ||
| renderPageSymbol('views/select-authenticator/index', pageSymbols); | ||
| expect(document.querySelector<HTMLImageElement>('img.haapi-stepper-page-symbol')).toHaveAttribute( | ||
| 'src', | ||
| '/symbols/default.svg' | ||
| ); | ||
| }); | ||
|
|
||
| it('renders nothing when nothing resolves and no `default` is configured', () => { | ||
| renderPageSymbol('authenticator/unknown-plugin/index', { | ||
| plugins: { 'html-form': '/symbols/html-form.svg' }, | ||
| }); | ||
| expect(document.querySelector<HTMLImageElement>('img.haapi-stepper-page-symbol')).toBeNull(); | ||
| }); | ||
|
|
||
| it('renders nothing when pageSymbols is absent', () => { | ||
| renderPageSymbol('authenticator/html-form/index', undefined); | ||
| expect(document.querySelector<HTMLImageElement>('img.haapi-stepper-page-symbol')).toBeNull(); | ||
| }); | ||
|
|
||
| it('renders nothing when pageSymbols is empty', () => { | ||
| renderPageSymbol('authenticator/html-form/index', {}); | ||
| expect(document.querySelector<HTMLImageElement>('img.haapi-stepper-page-symbol')).toBeNull(); | ||
| }); | ||
|
|
||
| it('renders nothing when viewName is undefined', () => { | ||
| renderPageSymbol(undefined, pageSymbols); | ||
| expect(document.querySelector<HTMLImageElement>('img.haapi-stepper-page-symbol')).toBeNull(); | ||
| }); | ||
|
|
||
| it('renders nothing when viewName is an empty string', () => { | ||
| renderPageSymbol('', pageSymbols); | ||
| expect(document.querySelector<HTMLImageElement>('img.haapi-stepper-page-symbol')).toBeNull(); | ||
| }); | ||
| }); |
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,35 @@ | ||
| /* | ||
| * Copyright (C) 2026 Curity AB. All rights reserved. | ||
| * | ||
| * The contents of this file are the property of Curity AB. | ||
| * You may not copy or use this file, in either source code | ||
| * or executable form, except in compliance with terms | ||
| * set by Curity AB. | ||
| * | ||
| * For further information, please contact Curity AB. | ||
| */ | ||
|
|
||
| import { useAppConfig } from '../feature/app-config/AppConfigHook'; | ||
| import { resolvePageSymbol } from '../util/resolve-page-symbol'; | ||
|
|
||
| interface PageSymbolProps { | ||
| viewName: string | undefined; | ||
| } | ||
|
|
||
| /** | ||
| * Renders the page symbol icon associated with the current step's HAAPI `viewName`. | ||
| * | ||
| * The mapping comes from `theme.pageSymbols` in the bootstrap configuration and is resolved by | ||
| * {@link resolvePageSymbol}. When `theme.pageSymbols` is absent, when `viewName` is absent, or when | ||
| * no entry resolves, this component renders nothing. | ||
| */ | ||
| export const PageSymbol = ({ viewName }: PageSymbolProps) => { | ||
| const { theme } = useAppConfig(); | ||
| const src = resolvePageSymbol(viewName, theme.pageSymbols); | ||
|
|
||
| if (!src) { | ||
| return null; | ||
| } | ||
|
|
||
| return <img className="haapi-stepper-page-symbol" src={src} alt="" role="presentation" />; | ||
| }; |
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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will need to be moved after that other PR improving handling of bootstrap configuration is merged,