@scottish-government/designsystem-react 0.6.0 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/@types/components/Accordion.d.ts +2 -2
- package/@types/components/ConfirmationMessage.d.ts +1 -1
- package/@types/components/NotificationPanel.d.ts +1 -1
- package/@types/components/SummaryCard.d.ts +1 -1
- package/@types/components/Tabs.d.ts +1 -1
- package/@types/sgds.d.ts +1 -1
- package/CHANGELOG.md +81 -0
- package/README.md +4 -0
- package/dist/common/AbstractNotificationBanner.jsx +63 -0
- package/dist/common/ConditionalWrapper.jsx +8 -0
- package/dist/common/FileIcon.jsx +51 -0
- package/dist/common/HintText.jsx +9 -0
- package/dist/common/Icon.jsx +57 -0
- package/dist/common/ScreenReaderText.jsx +9 -0
- package/dist/common/WrapperTag.jsx +11 -0
- package/dist/components/Accordion/Accordion.jsx +102 -0
- package/dist/components/AspectBox/AspectBox.jsx +79 -0
- package/dist/components/BackToTop/BackToTop.jsx +27 -0
- package/dist/components/Breadcrumbs/Breadcrumbs.jsx +28 -0
- package/dist/components/Button/Button.jsx +30 -0
- package/dist/components/Checkbox/Checkbox.jsx +62 -0
- package/dist/components/ConfirmationMessage/ConfirmationMessage.jsx +24 -0
- package/dist/components/ContentsNav/ContentsNav.jsx +33 -0
- package/dist/components/CookieBanner/CookieBanner.jsx +21 -0
- package/dist/components/DatePicker/DatePicker.jsx +54 -0
- package/dist/components/Details/Details.jsx +17 -0
- package/dist/components/ErrorMessage/ErrorMessage.jsx +12 -0
- package/dist/components/ErrorSummary/ErrorSummary.jsx +27 -0
- package/dist/components/FileDownload/FileDownload.jsx +50 -0
- package/dist/components/HideThisPage/HideThisPage.jsx +71 -0
- package/dist/components/InsetText/InsetText.jsx +14 -0
- package/dist/components/NotificationBanner/NotificationBanner.jsx +26 -0
- package/dist/components/NotificationPanel/NotificationPanel.jsx +21 -0
- package/dist/components/PageHeader/PageHeader.jsx +15 -0
- package/dist/components/PageMetadata/PageMetadata.jsx +26 -0
- package/dist/components/Pagination/Pagination.jsx +97 -0
- package/dist/components/PhaseBanner/PhaseBanner.jsx +23 -0
- package/dist/components/Question/Question.jsx +22 -0
- package/dist/components/RadioButton/RadioButton.jsx +43 -0
- package/dist/components/Select/Select.jsx +52 -0
- package/dist/components/SequentialNavigation/SequentialNavigation.jsx +31 -0
- package/dist/components/SideNavigation/SideNavigation.jsx +52 -0
- package/dist/components/SiteHeader/SiteHeader.jsx +68 -0
- package/dist/components/SiteNavigation/SiteNavigation.jsx +22 -0
- package/dist/components/SiteSearch/SiteSearch.jsx +55 -0
- package/dist/components/SkipLinks/SkipLinks.jsx +21 -0
- package/dist/components/SummaryCard/SummaryCard.jsx +67 -0
- package/dist/components/SummaryList/SummaryList.jsx +75 -0
- package/dist/components/Table/Table.jsx +24 -0
- package/dist/components/Tabs/Tabs.jsx +99 -0
- package/dist/components/Tag/Tag.jsx +13 -0
- package/dist/components/TaskList/TaskList.jsx +95 -0
- package/dist/components/TextInput/TextInput.jsx +58 -0
- package/dist/components/Textarea/Textarea.jsx +54 -0
- package/dist/components/WarningText/WarningText.jsx +16 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/common/{abstract-notification-banner.test.tsx → AbstractNotificationBanner.test.tsx} +11 -11
- package/src/common/{abstract-notification-banner.tsx → AbstractNotificationBanner.tsx} +2 -2
- package/src/common/{conditional-wrapper.test.tsx → ConditionalWrapper.test.tsx} +1 -1
- package/src/common/{file-icon.test.tsx → FileIcon.test.tsx} +10 -10
- package/src/common/{hint-text.test.tsx → HintText.test.tsx} +12 -12
- package/src/common/{icon.test.tsx → Icon.test.tsx} +16 -16
- package/src/common/{screen-reader-text.test.tsx → ScreenReaderText.test.tsx} +5 -5
- package/src/common/{wrapper-tag.test.tsx → WrapperTag.test.tsx} +5 -5
- package/src/components/{accordion/accordion.test.tsx → Accordion/Accordion.test.tsx} +35 -35
- package/src/components/{accordion/accordion.tsx → Accordion/Accordion.tsx} +5 -5
- package/src/components/{aspect-box/aspect-box.test.tsx → AspectBox/AspectBox.test.tsx} +2 -2
- package/src/components/{back-to-top/back-to-top.test.tsx → BackToTop/BackToTop.test.tsx} +1 -1
- package/src/components/{back-to-top/back-to-top.tsx → BackToTop/BackToTop.tsx} +1 -1
- package/src/components/{breadcrumbs/breadcrumbs.test.tsx → Breadcrumbs/Breadcrumbs.test.tsx} +7 -7
- package/src/components/{button/button.test.tsx → Button/Button.test.tsx} +1 -1
- package/src/components/{button/button.tsx → Button/Button.tsx} +3 -3
- package/src/components/{checkbox/checkbox.test.tsx → Checkbox/Checkbox.test.tsx} +16 -16
- package/src/components/{checkbox/checkbox.tsx → Checkbox/Checkbox.tsx} +1 -1
- package/src/components/{confirmation-message/confirmation-message.test.tsx → ConfirmationMessage/ConfirmationMessage.test.tsx} +12 -14
- package/src/components/{confirmation-message/confirmation-message.tsx → ConfirmationMessage/ConfirmationMessage.tsx} +4 -4
- package/src/components/{contents-nav/contents-nav.test.tsx → ContentsNav/ContentsNav.test.tsx} +21 -28
- package/src/components/{contents-nav/contents-nav.tsx → ContentsNav/ContentsNav.tsx} +1 -1
- package/src/components/{cookie-banner/cookie-banner.test.tsx → CookieBanner/CookieBanner.test.tsx} +3 -3
- package/src/components/{cookie-banner/cookie-banner.tsx → CookieBanner/CookieBanner.tsx} +1 -1
- package/src/components/{date-picker/date-picker.test.tsx → DatePicker/DatePicker.test.tsx} +76 -66
- package/src/components/{date-picker/date-picker.tsx → DatePicker/DatePicker.tsx} +2 -2
- package/src/components/{details/details.test.tsx → Details/Details.test.tsx} +10 -10
- package/src/components/{error-message/error-message.test.tsx → ErrorMessage/ErrorMessage.test.tsx} +10 -10
- package/src/components/{error-summary/error-summary.test.tsx → ErrorSummary/ErrorSummary.test.tsx} +13 -14
- package/src/components/{error-summary/error-summary.tsx → ErrorSummary/ErrorSummary.tsx} +1 -1
- package/src/components/{file-download/file-download.test.tsx → FileDownload/FileDownload.test.tsx} +21 -21
- package/src/components/{file-download/file-download.tsx → FileDownload/FileDownload.tsx} +1 -1
- package/src/components/{hide-this-page/hide-this-page.test.tsx → HideThisPage/HideThisPage.test.tsx} +4 -4
- package/src/components/{hide-this-page/hide-this-page.tsx → HideThisPage/HideThisPage.tsx} +3 -3
- package/src/components/{inset-text/inset-text.test.tsx → InsetText/InsetText.test.tsx} +1 -1
- package/src/components/{notification-banner/notification-banner.test.tsx → NotificationBanner/NotificationBanner.test.tsx} +4 -4
- package/src/components/{notification-banner/notification-banner.tsx → NotificationBanner/NotificationBanner.tsx} +1 -1
- package/src/components/{notification-panel/notification-panel.test.tsx → NotificationPanel/NotificationPanel.test.tsx} +24 -23
- package/src/components/{notification-panel/notification-panel.tsx → NotificationPanel/NotificationPanel.tsx} +3 -3
- package/src/components/{page-header/page-header.test.tsx → PageHeader/PageHeader.test.tsx} +9 -9
- package/src/components/{page-metadata/page-metadata.test.tsx → PageMetadata/PageMetadata.test.tsx} +9 -9
- package/src/components/{pagination/pagination.test.tsx → Pagination/Pagination.test.tsx} +56 -56
- package/src/components/{pagination/pagination.tsx → Pagination/Pagination.tsx} +1 -1
- package/src/components/{phase-banner/phase-banner.test.tsx → PhaseBanner/PhaseBanner.test.tsx} +9 -9
- package/src/components/{phase-banner/phase-banner.tsx → PhaseBanner/PhaseBanner.tsx} +1 -1
- package/src/components/{question/question.test.tsx → Question/Question.test.tsx} +10 -10
- package/src/components/{question/question.tsx → Question/Question.tsx} +3 -3
- package/src/components/{radio-button/radio-button.test.tsx → RadioButton/RadioButton.test.tsx} +23 -23
- package/src/components/{radio-button/radio-button.tsx → RadioButton/RadioButton.tsx} +1 -1
- package/src/components/{select/select.test.tsx → Select/Select.test.tsx} +67 -64
- package/src/components/{select/select.tsx → Select/Select.tsx} +2 -2
- package/src/components/{sequential-navigation/sequential-navigation.test.tsx → SequentialNavigation/SequentialNavigation.test.tsx} +18 -18
- package/src/components/{side-navigation/side-navigation.test.tsx → SideNavigation/SideNavigation.test.tsx} +8 -8
- package/src/components/{site-header/site-header.test.tsx → SiteHeader/SiteHeader.test.tsx} +25 -25
- package/src/components/{site-header/site-header.tsx → SiteHeader/SiteHeader.tsx} +4 -4
- package/src/components/{site-navigation/site-navigation.test.tsx → SiteNavigation/SiteNavigation.test.tsx} +8 -8
- package/src/components/{site-search/site-search.test.tsx → SiteSearch/SiteSearch.test.tsx} +16 -16
- package/src/components/{site-search/site-search.tsx → SiteSearch/SiteSearch.tsx} +1 -1
- package/src/components/{skip-links/skip-links.test.tsx → SkipLinks/SkipLinks.test.tsx} +15 -15
- package/src/components/{summary-card/summary-card.test.tsx → SummaryCard/SummaryCard.test.tsx} +28 -28
- package/src/components/{summary-card/summary-card.tsx → SummaryCard/SummaryCard.tsx} +4 -4
- package/src/components/{summary-list/summary-list.test.tsx → SummaryList/SummaryList.test.tsx} +55 -56
- package/src/components/{summary-list/summary-list.tsx → SummaryList/SummaryList.tsx} +2 -2
- package/src/components/{table/table.test.tsx → Table/Table.test.tsx} +4 -4
- package/src/components/{tabs/tabs.test.tsx → Tabs/Tabs.test.tsx} +22 -42
- package/src/components/{tabs/tabs.tsx → Tabs/Tabs.tsx} +3 -3
- package/src/components/{tag/tag.test.tsx → Tag/Tag.test.tsx} +10 -10
- package/src/components/{task-list/task-list.test.tsx → TaskList/TaskList.test.tsx} +109 -108
- package/src/components/{task-list/task-list.tsx → TaskList/TaskList.tsx} +4 -4
- package/src/components/{text-input/text-input.test.tsx → TextInput/TextInput.test.tsx} +92 -87
- package/src/components/{text-input/text-input.tsx → TextInput/TextInput.tsx} +4 -4
- package/src/components/{textarea/textarea.test.tsx → Textarea/Textarea.test.tsx} +71 -67
- package/src/components/{textarea/textarea.tsx → Textarea/Textarea.tsx} +3 -3
- package/src/components/{warning-text/warning-text.test.tsx → WarningText/WarningText.test.tsx} +1 -1
- /package/src/common/{conditional-wrapper.tsx → ConditionalWrapper.tsx} +0 -0
- /package/src/common/{file-icon.tsx → FileIcon.tsx} +0 -0
- /package/src/common/{hint-text.tsx → HintText.tsx} +0 -0
- /package/src/common/{icon.tsx → Icon.tsx} +0 -0
- /package/src/common/{screen-reader-text.tsx → ScreenReaderText.tsx} +0 -0
- /package/src/common/{wrapper-tag.tsx → WrapperTag.tsx} +0 -0
- /package/src/components/{aspect-box/aspect-box.tsx → AspectBox/AspectBox.tsx} +0 -0
- /package/src/components/{breadcrumbs/breadcrumbs.tsx → Breadcrumbs/Breadcrumbs.tsx} +0 -0
- /package/src/components/{details/details.tsx → Details/Details.tsx} +0 -0
- /package/src/components/{error-message/error-message.tsx → ErrorMessage/ErrorMessage.tsx} +0 -0
- /package/src/components/{inset-text/inset-text.tsx → InsetText/InsetText.tsx} +0 -0
- /package/src/components/{page-header/page-header.tsx → PageHeader/PageHeader.tsx} +0 -0
- /package/src/components/{page-metadata/page-metadata.tsx → PageMetadata/PageMetadata.tsx} +0 -0
- /package/src/components/{sequential-navigation/sequential-navigation.tsx → SequentialNavigation/SequentialNavigation.tsx} +0 -0
- /package/src/components/{side-navigation/side-navigation.tsx → SideNavigation/SideNavigation.tsx} +0 -0
- /package/src/components/{site-navigation/site-navigation.tsx → SiteNavigation/SiteNavigation.tsx} +0 -0
- /package/src/components/{skip-links/skip-links.tsx → SkipLinks/SkipLinks.tsx} +0 -0
- /package/src/components/{table/table.tsx → Table/Table.tsx} +0 -0
- /package/src/components/{tag/tag.tsx → Tag/Tag.tsx} +0 -0
- /package/src/components/{warning-text/warning-text.tsx → WarningText/WarningText.tsx} +0 -0
package/src/components/{error-message/error-message.test.tsx → ErrorMessage/ErrorMessage.test.tsx}
RENAMED
|
@@ -1,28 +1,28 @@
|
|
|
1
1
|
import { test, expect } from 'vitest';
|
|
2
2
|
import { render, screen } from '@testing-library/react';
|
|
3
|
-
import ErrorMessage from './
|
|
3
|
+
import ErrorMessage from './ErrorMessage';
|
|
4
4
|
|
|
5
|
-
const
|
|
6
|
-
const
|
|
5
|
+
const ERROR_TEXT = 'Error message';
|
|
6
|
+
const ERROR_ID = 'errormessage';
|
|
7
7
|
|
|
8
8
|
test('error message renders correctly', () => {
|
|
9
9
|
|
|
10
10
|
render(
|
|
11
|
-
<ErrorMessage text={
|
|
11
|
+
<ErrorMessage text={ERROR_TEXT} id={ERROR_ID}/>
|
|
12
12
|
);
|
|
13
13
|
|
|
14
14
|
const errorMessageElement = screen.getByRole('paragraph');
|
|
15
15
|
|
|
16
|
-
expect(errorMessageElement).toHaveAttribute('id',
|
|
16
|
+
expect(errorMessageElement).toHaveAttribute('id', ERROR_ID);
|
|
17
17
|
expect(errorMessageElement).toHaveClass('ds_question__error-message');
|
|
18
|
-
expect(errorMessageElement.textContent).toEqual(
|
|
18
|
+
expect(errorMessageElement.textContent).toEqual(ERROR_TEXT);
|
|
19
19
|
});
|
|
20
20
|
|
|
21
21
|
test('error message with HTML content', () => {
|
|
22
|
-
const
|
|
22
|
+
const ERROR_ID = 'errormessage';
|
|
23
23
|
|
|
24
24
|
render(
|
|
25
|
-
<ErrorMessage id={
|
|
25
|
+
<ErrorMessage id={ERROR_ID}>hello <a href="#foo">world</a></ErrorMessage>
|
|
26
26
|
);
|
|
27
27
|
|
|
28
28
|
const errorMessageElement = screen.getByRole('paragraph');
|
|
@@ -32,7 +32,7 @@ test('error message with HTML content', () => {
|
|
|
32
32
|
|
|
33
33
|
test('passing additional props', () => {
|
|
34
34
|
render(
|
|
35
|
-
<ErrorMessage data-test="foo" text={
|
|
35
|
+
<ErrorMessage data-test="foo" text={ERROR_TEXT} id={ERROR_ID}/>
|
|
36
36
|
)
|
|
37
37
|
|
|
38
38
|
const errorMessageElement = screen.getByRole('paragraph');
|
|
@@ -41,7 +41,7 @@ test('passing additional props', () => {
|
|
|
41
41
|
|
|
42
42
|
test('passing additional CSS classes', () => {
|
|
43
43
|
render(
|
|
44
|
-
<ErrorMessage className="foo" text={
|
|
44
|
+
<ErrorMessage className="foo" text={ERROR_TEXT} id={ERROR_ID}/>
|
|
45
45
|
)
|
|
46
46
|
|
|
47
47
|
const errorMessageElement = screen.getByRole('paragraph');
|
package/src/components/{error-summary/error-summary.test.tsx → ErrorSummary/ErrorSummary.test.tsx}
RENAMED
|
@@ -1,19 +1,18 @@
|
|
|
1
1
|
import { test, expect } from 'vitest';
|
|
2
2
|
import { render, screen, within } from '@testing-library/react';
|
|
3
|
-
import ErrorSummary from './
|
|
4
|
-
import { title } from 'process';
|
|
3
|
+
import ErrorSummary from './ErrorSummary';
|
|
5
4
|
|
|
6
|
-
const
|
|
5
|
+
const ERRORS = [
|
|
7
6
|
{ fragmentId: 'did-resolve', title: 'Did this resolve your issue?' },
|
|
8
7
|
{ fragmentId: 'what-topics', title: 'What topics are you interested in?' },
|
|
9
8
|
{ fragmentId: 'more-detail', title: 'Please provide more detail' }
|
|
10
9
|
];
|
|
11
10
|
|
|
12
11
|
test('error summary renders correctly', () => {
|
|
13
|
-
const
|
|
12
|
+
const TITLE_ID = 'error-summary-title';
|
|
14
13
|
|
|
15
14
|
render(
|
|
16
|
-
<ErrorSummary data-testid="errorsummary" errors={
|
|
15
|
+
<ErrorSummary data-testid="errorsummary" errors={ERRORS} />
|
|
17
16
|
);
|
|
18
17
|
|
|
19
18
|
const errorSummaryElement = screen.getByTestId('errorsummary');
|
|
@@ -28,30 +27,30 @@ test('error summary renders correctly', () => {
|
|
|
28
27
|
expect(errorSummaryElement.tagName).toEqual('DIV');
|
|
29
28
|
|
|
30
29
|
expect(errorSummaryTitle).toHaveClass('ds_error-summary__title');
|
|
31
|
-
expect(errorSummaryTitle).toHaveAttribute('id',
|
|
30
|
+
expect(errorSummaryTitle).toHaveAttribute('id', TITLE_ID);
|
|
32
31
|
expect(errorSummaryTitle.tagName).toEqual('H2');
|
|
33
32
|
expect(errorSummaryTitle.textContent).toEqual('There is a problem');
|
|
34
33
|
|
|
35
34
|
expect(errorSummaryList).toHaveClass('ds_error-summary__list');
|
|
36
35
|
expect(errorSummaryList.tagName).toEqual('UL');
|
|
37
36
|
|
|
38
|
-
expect(errorSummaryItems.length).toEqual(
|
|
37
|
+
expect(errorSummaryItems.length).toEqual(ERRORS.length);
|
|
39
38
|
|
|
40
|
-
expect(errorSummaryLink1).toHaveAttribute('href', `#${
|
|
41
|
-
expect(errorSummaryLink1.textContent).toEqual(
|
|
39
|
+
expect(errorSummaryLink1).toHaveAttribute('href', `#${ERRORS[0].fragmentId}`);
|
|
40
|
+
expect(errorSummaryLink1.textContent).toEqual(ERRORS[0].title);
|
|
42
41
|
});
|
|
43
42
|
|
|
44
43
|
test('error summary with custom title', () => {
|
|
45
|
-
const
|
|
44
|
+
const TITLE_TEXT = 'Foo';
|
|
46
45
|
|
|
47
46
|
render(
|
|
48
|
-
<ErrorSummary data-testid="errorsummary" errors={
|
|
47
|
+
<ErrorSummary data-testid="errorsummary" errors={ERRORS} title={TITLE_TEXT} />
|
|
49
48
|
);
|
|
50
49
|
|
|
51
50
|
const errorSummaryElement = screen.getByTestId('errorsummary');
|
|
52
51
|
const errorSummaryTitle = within(errorSummaryElement).getByRole('heading');
|
|
53
52
|
|
|
54
|
-
expect(errorSummaryTitle.textContent).toEqual(
|
|
53
|
+
expect(errorSummaryTitle.textContent).toEqual(TITLE_TEXT);
|
|
55
54
|
});
|
|
56
55
|
|
|
57
56
|
test('error summary with no errors (empty array) should not display', () => {
|
|
@@ -89,7 +88,7 @@ test('error sumary item with no link', () => {
|
|
|
89
88
|
|
|
90
89
|
test('passing additional props', () => {
|
|
91
90
|
render(
|
|
92
|
-
<ErrorSummary data-testid="errorsummary" errors={
|
|
91
|
+
<ErrorSummary data-testid="errorsummary" errors={ERRORS} data-test="foo" />
|
|
93
92
|
)
|
|
94
93
|
|
|
95
94
|
const errorSummaryElement = screen.getByTestId('errorsummary');
|
|
@@ -98,7 +97,7 @@ test('passing additional props', () => {
|
|
|
98
97
|
|
|
99
98
|
test('passing additional CSS classes', () => {
|
|
100
99
|
render(
|
|
101
|
-
<ErrorSummary data-testid="errorsummary" errors={
|
|
100
|
+
<ErrorSummary data-testid="errorsummary" errors={ERRORS} className="foo" />
|
|
102
101
|
)
|
|
103
102
|
|
|
104
103
|
const errorSummaryElement = screen.getByTestId('errorsummary');
|
package/src/components/{file-download/file-download.test.tsx → FileDownload/FileDownload.test.tsx}
RENAMED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { test, expect } from 'vitest';
|
|
2
2
|
import { screen, render } from '@testing-library/react';
|
|
3
|
-
import FileDownload from './
|
|
3
|
+
import FileDownload from './FileDownload';
|
|
4
4
|
|
|
5
|
-
const
|
|
6
|
-
const
|
|
5
|
+
const FILE_TITLE = 'Scotland\'s Artificial Intelligence Strategy - Trustworthy, Ethical and Inclusive';
|
|
6
|
+
const FILE_URL = 'my-file.file';
|
|
7
7
|
|
|
8
8
|
test('inset text renders correctly', () => {
|
|
9
9
|
render(
|
|
10
|
-
<FileDownload fileUrl={
|
|
10
|
+
<FileDownload fileUrl={FILE_URL} title={FILE_TITLE} data-testid="file-download" />
|
|
11
11
|
);
|
|
12
12
|
|
|
13
13
|
const fileDownload = screen.getByTestId('file-download');
|
|
@@ -26,7 +26,7 @@ test('inset text renders correctly', () => {
|
|
|
26
26
|
expect(thumbnailLink).toHaveClass('ds_file-download__thumbnail-link');
|
|
27
27
|
expect(thumbnailLink).toHaveAttribute('aria-hidden', 'true');
|
|
28
28
|
expect(thumbnailLink).toHaveAttribute('tabindex', '-1');
|
|
29
|
-
expect(thumbnailLink).toHaveAttribute('href',
|
|
29
|
+
expect(thumbnailLink).toHaveAttribute('href', FILE_URL);
|
|
30
30
|
expect(thumbnailLink?.tagName).toEqual('A');
|
|
31
31
|
|
|
32
32
|
expect(thumbnailContainer).toHaveClass('ds_file-download__thumbnail');
|
|
@@ -38,14 +38,14 @@ test('inset text renders correctly', () => {
|
|
|
38
38
|
expect(contentContainer?.parentElement).toEqual(fileDownload);
|
|
39
39
|
|
|
40
40
|
expect(fileLink).toHaveClass('ds_file-download__title');
|
|
41
|
-
expect(fileLink).toHaveAttribute('href',
|
|
41
|
+
expect(fileLink).toHaveAttribute('href', FILE_URL);
|
|
42
42
|
expect(fileLink?.tagName).toEqual('A');
|
|
43
|
-
expect(fileLink?.textContent).toEqual(
|
|
43
|
+
expect(fileLink?.textContent).toEqual(FILE_TITLE);
|
|
44
44
|
});
|
|
45
45
|
|
|
46
46
|
test('highlighted file download', () => {
|
|
47
47
|
render(
|
|
48
|
-
<FileDownload highlighted fileUrl={
|
|
48
|
+
<FileDownload highlighted fileUrl={FILE_URL} title={FILE_TITLE} data-testid="file-download" />
|
|
49
49
|
);
|
|
50
50
|
|
|
51
51
|
const fileDownload = screen.getByTestId('file-download');
|
|
@@ -58,25 +58,25 @@ test('highlighted file download', () => {
|
|
|
58
58
|
// });
|
|
59
59
|
|
|
60
60
|
test('file download with cover image', () => {
|
|
61
|
-
const
|
|
61
|
+
const COVER_URL = 'my-image.png';
|
|
62
62
|
|
|
63
63
|
render(
|
|
64
|
-
<FileDownload cover={
|
|
64
|
+
<FileDownload cover={COVER_URL} fileUrl={FILE_URL} title={FILE_TITLE} data-testid="file-download" />
|
|
65
65
|
);
|
|
66
66
|
|
|
67
67
|
const thumbnailImage = screen.getByRole('presentation', {hidden: true});
|
|
68
68
|
|
|
69
69
|
expect(thumbnailImage).toHaveClass('ds_file-download__thumbnail-image');
|
|
70
70
|
expect(thumbnailImage).toHaveAttribute('alt', '');
|
|
71
|
-
expect(thumbnailImage).toHaveAttribute('src',
|
|
71
|
+
expect(thumbnailImage).toHaveAttribute('src', COVER_URL);
|
|
72
72
|
expect(thumbnailImage.tagName).toEqual('IMG');
|
|
73
73
|
});
|
|
74
74
|
|
|
75
75
|
test('file download with file size', () => {
|
|
76
|
-
const
|
|
76
|
+
const FILE_SIZE = '1.2 MB';
|
|
77
77
|
|
|
78
78
|
render(
|
|
79
|
-
<FileDownload fileSize={
|
|
79
|
+
<FileDownload fileSize={FILE_SIZE} fileUrl={FILE_URL} title={FILE_TITLE} data-testid="file-download" />
|
|
80
80
|
);
|
|
81
81
|
|
|
82
82
|
const metadataKey = screen.getByRole('term');
|
|
@@ -98,15 +98,15 @@ test('file download with file size', () => {
|
|
|
98
98
|
expect(metadataKey.textContent).toEqual('File size');
|
|
99
99
|
|
|
100
100
|
expect(metadataValue).toHaveClass('ds_metadata__value');
|
|
101
|
-
expect(metadataValue.textContent).toEqual(
|
|
101
|
+
expect(metadataValue.textContent).toEqual(FILE_SIZE);
|
|
102
102
|
expect(metadataValue.previousElementSibling).toEqual(metadataKey);
|
|
103
103
|
});
|
|
104
104
|
|
|
105
105
|
test('file download with file type', () => {
|
|
106
|
-
const
|
|
106
|
+
const FILE_TYPE = '5 page PDF';
|
|
107
107
|
|
|
108
108
|
render(
|
|
109
|
-
<FileDownload fileType={
|
|
109
|
+
<FileDownload fileType={FILE_TYPE} fileUrl={FILE_URL} title={FILE_TITLE} data-testid="file-download" />
|
|
110
110
|
);
|
|
111
111
|
|
|
112
112
|
const metadataKey = screen.getByRole('term');
|
|
@@ -128,15 +128,15 @@ test('file download with file type', () => {
|
|
|
128
128
|
expect(metadataKey.textContent).toEqual('File type');
|
|
129
129
|
|
|
130
130
|
expect(metadataValue).toHaveClass('ds_metadata__value');
|
|
131
|
-
expect(metadataValue.textContent).toEqual(
|
|
131
|
+
expect(metadataValue.textContent).toEqual(FILE_TYPE + ',');
|
|
132
132
|
expect(metadataValue.previousElementSibling).toEqual(metadataKey);
|
|
133
133
|
});
|
|
134
134
|
|
|
135
135
|
test('association of metadata with file link', () => {
|
|
136
|
-
const
|
|
136
|
+
const FILE_SIZE = '1.2 MB';
|
|
137
137
|
|
|
138
138
|
render(
|
|
139
|
-
<FileDownload fileSize={
|
|
139
|
+
<FileDownload fileSize={FILE_SIZE} fileUrl={FILE_URL} title={FILE_TITLE} data-testid="file-download" />
|
|
140
140
|
);
|
|
141
141
|
|
|
142
142
|
const fileLink = screen.getByRole('link');
|
|
@@ -150,7 +150,7 @@ test('association of metadata with file link', () => {
|
|
|
150
150
|
|
|
151
151
|
test('passing additional props', () => {
|
|
152
152
|
render(
|
|
153
|
-
<FileDownload fileUrl={
|
|
153
|
+
<FileDownload fileUrl={FILE_URL} title={FILE_TITLE} data-testid="file-download" data-test="foo" />
|
|
154
154
|
);
|
|
155
155
|
|
|
156
156
|
const fileDownload = screen.getByTestId('file-download');
|
|
@@ -159,7 +159,7 @@ test('passing additional props', () => {
|
|
|
159
159
|
|
|
160
160
|
test('passing additional CSS classes', () => {
|
|
161
161
|
render(
|
|
162
|
-
<FileDownload fileUrl={
|
|
162
|
+
<FileDownload fileUrl={FILE_URL} title={FILE_TITLE} data-testid="file-download" className="foo" />
|
|
163
163
|
);
|
|
164
164
|
|
|
165
165
|
const fileDownload = screen.getByTestId('file-download');
|
package/src/components/{hide-this-page/hide-this-page.test.tsx → HideThisPage/HideThisPage.test.tsx}
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { test, expect } from 'vitest';
|
|
2
2
|
import { render, screen, within } from '@testing-library/react';
|
|
3
|
-
import HideThisPage from './
|
|
3
|
+
import HideThisPage from './HideThisPage';
|
|
4
4
|
|
|
5
5
|
test('hide this page renders correctly', () => {
|
|
6
6
|
render(
|
|
@@ -39,16 +39,16 @@ test('hide this page renders correctly', () => {
|
|
|
39
39
|
});
|
|
40
40
|
|
|
41
41
|
test('custom escape URL', () => {
|
|
42
|
-
const
|
|
42
|
+
const ESCAPE_URL = 'https://www.mygov.scot';
|
|
43
43
|
|
|
44
44
|
render(
|
|
45
|
-
<HideThisPage data-testid="htp" escapeUrl={
|
|
45
|
+
<HideThisPage data-testid="htp" escapeUrl={ESCAPE_URL} />
|
|
46
46
|
);
|
|
47
47
|
|
|
48
48
|
const hideThisPageElement = screen.getByTestId('htp');
|
|
49
49
|
const link = within(hideThisPageElement).getByRole('link');
|
|
50
50
|
|
|
51
|
-
expect(link).toHaveAttribute('href',
|
|
51
|
+
expect(link).toHaveAttribute('href', ESCAPE_URL);
|
|
52
52
|
})
|
|
53
53
|
|
|
54
54
|
test('passing additional props', () => {
|
|
@@ -13,10 +13,10 @@ const HideThisPage: React.FC<SGDS.Component.HideThisPage> = ({
|
|
|
13
13
|
if (ref.current) {
|
|
14
14
|
new DSHideThisPage().init();
|
|
15
15
|
|
|
16
|
-
const
|
|
17
|
-
if (!document.getElementById(
|
|
16
|
+
const HIDE_THIS_PAGE_DIV_ID = 'hide-this-page-instruction';
|
|
17
|
+
if (!document.getElementById(HIDE_THIS_PAGE_DIV_ID)) {
|
|
18
18
|
const htpDiv = document.createElement('div');
|
|
19
|
-
htpDiv.id =
|
|
19
|
+
htpDiv.id = HIDE_THIS_PAGE_DIV_ID;
|
|
20
20
|
htpDiv.classList.add('visually-hidden');
|
|
21
21
|
htpDiv.classList.add('ds_hide-page');
|
|
22
22
|
htpDiv.innerHTML = '<p>To leave the page quickly, press the escape key.</p>';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { test, expect } from 'vitest';
|
|
2
2
|
import { render } from '@testing-library/react';
|
|
3
|
-
import InsetText from './
|
|
3
|
+
import InsetText from './InsetText';
|
|
4
4
|
|
|
5
5
|
const text = `You may be able to apply for free school meals at the same
|
|
6
6
|
time as you apply for the clothing grant.`;
|
|
@@ -5,9 +5,9 @@
|
|
|
5
5
|
|
|
6
6
|
import { test, expect } from 'vitest';
|
|
7
7
|
import { render, screen, within } from '@testing-library/react';
|
|
8
|
-
import NotificationBanner from './
|
|
8
|
+
import NotificationBanner from './NotificationBanner';
|
|
9
9
|
|
|
10
|
-
const
|
|
10
|
+
const BANNER_TEXT = 'We need to tell you about something';
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
13
|
* NotificationBanner has the ds_reversed class
|
|
@@ -15,7 +15,7 @@ const text = 'We need to tell you about something';
|
|
|
15
15
|
test('notification banner renders correctly', () => {
|
|
16
16
|
render(
|
|
17
17
|
<NotificationBanner>
|
|
18
|
-
{
|
|
18
|
+
{BANNER_TEXT}
|
|
19
19
|
</NotificationBanner>
|
|
20
20
|
);
|
|
21
21
|
|
|
@@ -30,7 +30,7 @@ test('notification banner renders correctly', () => {
|
|
|
30
30
|
test('notification banner with icon', () => {
|
|
31
31
|
render(
|
|
32
32
|
<NotificationBanner icon>
|
|
33
|
-
{
|
|
33
|
+
{BANNER_TEXT}
|
|
34
34
|
</NotificationBanner>
|
|
35
35
|
);
|
|
36
36
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { useEffect, useRef } from 'react';
|
|
2
|
-
import AbstractNotificationBanner from '../../common/
|
|
2
|
+
import AbstractNotificationBanner from '../../common/AbstractNotificationBanner';
|
|
3
3
|
// @ts-ignore
|
|
4
4
|
import DSNotificationBanner from '@scottish-government/design-system/src/components/notification-banner/notification-banner';
|
|
5
5
|
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { test, expect } from 'vitest';
|
|
2
2
|
import { render, screen } from '@testing-library/react';
|
|
3
|
-
import NotificationPanel from './
|
|
3
|
+
import NotificationPanel from './NotificationPanel';
|
|
4
4
|
|
|
5
|
-
const
|
|
6
|
-
const
|
|
5
|
+
const HEADING_TEXT = 'Thank you';
|
|
6
|
+
const TEXT = 'Your Saltire Scholarship Application form has been successfully submitted.';
|
|
7
7
|
|
|
8
8
|
test('notification banner renders correctly', () => {
|
|
9
9
|
render(
|
|
10
|
-
<NotificationPanel title={
|
|
11
|
-
{
|
|
10
|
+
<NotificationPanel title={HEADING_TEXT}>
|
|
11
|
+
{TEXT}
|
|
12
12
|
</NotificationPanel>
|
|
13
13
|
);
|
|
14
14
|
|
|
@@ -18,56 +18,57 @@ test('notification banner renders correctly', () => {
|
|
|
18
18
|
|
|
19
19
|
expect(notificationPanel).toHaveClass('ds_notification-panel');
|
|
20
20
|
expect(notificationPanelHeading).toHaveClass('ds_notification-panel__title');
|
|
21
|
-
expect(notificationPanelHeading.textContent).toEqual(
|
|
21
|
+
expect(notificationPanelHeading.textContent).toEqual(HEADING_TEXT);
|
|
22
22
|
expect(notificationPanelHeading.tagName).toEqual('H1');
|
|
23
23
|
expect(notificationPanelContent).toHaveClass('ds_notification-panel__content');
|
|
24
|
-
expect(notificationPanelContent?.textContent).toEqual(
|
|
24
|
+
expect(notificationPanelContent?.textContent).toEqual(TEXT);
|
|
25
25
|
});
|
|
26
26
|
|
|
27
27
|
test('notification banner with custom heading level', () => {
|
|
28
|
-
const
|
|
28
|
+
const HEADING_LEVEL = 'h2';
|
|
29
29
|
|
|
30
30
|
render(
|
|
31
|
-
<NotificationPanel
|
|
32
|
-
{
|
|
31
|
+
<NotificationPanel headingLevel={HEADING_LEVEL} title={HEADING_TEXT}>
|
|
32
|
+
{TEXT}
|
|
33
33
|
</NotificationPanel>
|
|
34
34
|
);
|
|
35
35
|
|
|
36
36
|
const notificationPanelHeading = screen.getByRole('heading');
|
|
37
|
-
expect(notificationPanelHeading.tagName).toEqual(
|
|
37
|
+
expect(notificationPanelHeading.tagName).toEqual(HEADING_LEVEL.toUpperCase());
|
|
38
38
|
});
|
|
39
39
|
|
|
40
40
|
test('notification banner with aria-live', () => {
|
|
41
|
-
const
|
|
41
|
+
const ARIA_LIVE = 'polite';
|
|
42
42
|
|
|
43
43
|
render(
|
|
44
|
-
<NotificationPanel ariaLive={
|
|
45
|
-
{
|
|
44
|
+
<NotificationPanel ariaLive={ARIA_LIVE} title={HEADING_TEXT}>
|
|
45
|
+
{TEXT}
|
|
46
46
|
</NotificationPanel>
|
|
47
47
|
);
|
|
48
48
|
|
|
49
49
|
const notificationPanelHeading = screen.getByRole('heading');
|
|
50
50
|
const notificationPanel = notificationPanelHeading.parentElement;
|
|
51
51
|
|
|
52
|
-
expect(notificationPanel).toHaveAttribute('aria-live',
|
|
52
|
+
expect(notificationPanel).toHaveAttribute('aria-live', ARIA_LIVE);
|
|
53
53
|
});
|
|
54
54
|
|
|
55
55
|
test('notification banner with nonsense heading level reverts to H1', () => {
|
|
56
|
-
const
|
|
56
|
+
const HEADING_LEVEL = 'h2';
|
|
57
|
+
|
|
57
58
|
render(
|
|
58
|
-
<NotificationPanel
|
|
59
|
-
{
|
|
59
|
+
<NotificationPanel headingLevel={HEADING_LEVEL} title={HEADING_TEXT}>
|
|
60
|
+
{TEXT}
|
|
60
61
|
</NotificationPanel>
|
|
61
62
|
);
|
|
62
63
|
|
|
63
64
|
const notificationPanelHeading = screen.getByRole('heading');
|
|
64
|
-
expect(notificationPanelHeading.tagName).toEqual(
|
|
65
|
+
expect(notificationPanelHeading.tagName).toEqual(HEADING_LEVEL.toUpperCase());
|
|
65
66
|
});
|
|
66
67
|
|
|
67
68
|
test('passing additional props', () => {
|
|
68
69
|
render(
|
|
69
|
-
<NotificationPanel title={
|
|
70
|
-
{
|
|
70
|
+
<NotificationPanel title={HEADING_TEXT} data-test="foo">
|
|
71
|
+
{TEXT}
|
|
71
72
|
</NotificationPanel>
|
|
72
73
|
)
|
|
73
74
|
|
|
@@ -78,8 +79,8 @@ test('passing additional props', () => {
|
|
|
78
79
|
|
|
79
80
|
test('passing additional CSS classes', () => {
|
|
80
81
|
render(
|
|
81
|
-
<NotificationPanel title={
|
|
82
|
-
{
|
|
82
|
+
<NotificationPanel title={HEADING_TEXT} className="foo">
|
|
83
|
+
{TEXT}
|
|
83
84
|
</NotificationPanel>
|
|
84
85
|
)
|
|
85
86
|
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import WrapperTag from '../../common/
|
|
1
|
+
import WrapperTag from '../../common/WrapperTag';
|
|
2
2
|
|
|
3
3
|
const NotificationPanel: React.FC<SGDS.Component.NotificationPanel> = function ({
|
|
4
4
|
ariaLive,
|
|
5
5
|
children,
|
|
6
6
|
className,
|
|
7
|
-
|
|
7
|
+
headingLevel = 'h1',
|
|
8
8
|
title,
|
|
9
9
|
...props
|
|
10
10
|
}) {
|
|
@@ -19,7 +19,7 @@ const NotificationPanel: React.FC<SGDS.Component.NotificationPanel> = function (
|
|
|
19
19
|
>
|
|
20
20
|
<WrapperTag
|
|
21
21
|
className="ds_notification-panel__title"
|
|
22
|
-
tagName={
|
|
22
|
+
tagName={headingLevel}
|
|
23
23
|
>
|
|
24
24
|
{title}
|
|
25
25
|
</WrapperTag>
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { test, expect } from 'vitest';
|
|
2
2
|
import { render, screen, within } from '@testing-library/react';
|
|
3
|
-
import PageHeader from './
|
|
3
|
+
import PageHeader from './PageHeader';
|
|
4
4
|
|
|
5
|
-
const
|
|
6
|
-
const
|
|
5
|
+
const LABEL_TEXT = 'Guide';
|
|
6
|
+
const TITLE_TEXT = 'Apply for or renew a disabled parking permit';
|
|
7
7
|
|
|
8
8
|
test('notification banner renders correctly', () => {
|
|
9
9
|
render(
|
|
10
|
-
<PageHeader label={
|
|
10
|
+
<PageHeader label={LABEL_TEXT} title={TITLE_TEXT}/>
|
|
11
11
|
);
|
|
12
12
|
|
|
13
13
|
const header = screen.getByRole('banner');
|
|
@@ -18,17 +18,17 @@ test('notification banner renders correctly', () => {
|
|
|
18
18
|
expect(header.tagName).toEqual('HEADER');
|
|
19
19
|
|
|
20
20
|
expect(label).toHaveClass('ds_page-header__label', 'ds_content-label');
|
|
21
|
-
expect(label?.textContent).toEqual(
|
|
21
|
+
expect(label?.textContent).toEqual(LABEL_TEXT);
|
|
22
22
|
expect(label?.tagName).toEqual('SPAN');
|
|
23
23
|
|
|
24
24
|
expect(title).toHaveClass('ds_page-header__title');
|
|
25
|
-
expect(title.textContent).toEqual(
|
|
25
|
+
expect(title.textContent).toEqual(TITLE_TEXT);
|
|
26
26
|
expect(title.tagName).toEqual('H1');
|
|
27
27
|
});
|
|
28
28
|
|
|
29
29
|
test('header with no label', () => {
|
|
30
30
|
render(
|
|
31
|
-
<PageHeader title={
|
|
31
|
+
<PageHeader title={TITLE_TEXT}/>
|
|
32
32
|
);
|
|
33
33
|
|
|
34
34
|
const header = screen.getByRole('banner');
|
|
@@ -40,7 +40,7 @@ test('header with no label', () => {
|
|
|
40
40
|
|
|
41
41
|
test('passing additional props', () => {
|
|
42
42
|
render(
|
|
43
|
-
<PageHeader data-test="foo" label={
|
|
43
|
+
<PageHeader data-test="foo" label={LABEL_TEXT} title={TITLE_TEXT}/>
|
|
44
44
|
)
|
|
45
45
|
|
|
46
46
|
const header = screen.getByRole('banner');
|
|
@@ -49,7 +49,7 @@ test('passing additional props', () => {
|
|
|
49
49
|
|
|
50
50
|
test('passing additional CSS classes', () => {
|
|
51
51
|
render(
|
|
52
|
-
<PageHeader className="foo" label={
|
|
52
|
+
<PageHeader className="foo" label={LABEL_TEXT} title={TITLE_TEXT}/>
|
|
53
53
|
)
|
|
54
54
|
|
|
55
55
|
const header = screen.getByRole('banner');
|
package/src/components/{page-metadata/page-metadata.test.tsx → PageMetadata/PageMetadata.test.tsx}
RENAMED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { test, expect } from 'vitest';
|
|
2
2
|
import { render, screen } from '@testing-library/react';
|
|
3
|
-
import Metadata from './
|
|
3
|
+
import Metadata from './PageMetadata';
|
|
4
4
|
|
|
5
|
-
const
|
|
6
|
-
const
|
|
5
|
+
const NAME = 'Directorate';
|
|
6
|
+
const VALUE = 'Equality, Inclusion and Human Rights Directorate';
|
|
7
7
|
|
|
8
8
|
test('metadata renders correctly', () => {
|
|
9
9
|
render(
|
|
10
10
|
<Metadata>
|
|
11
|
-
<Metadata.Item name={
|
|
12
|
-
{
|
|
11
|
+
<Metadata.Item name={NAME}>
|
|
12
|
+
{VALUE}
|
|
13
13
|
</Metadata.Item>
|
|
14
14
|
</Metadata>
|
|
15
15
|
);
|
|
@@ -22,16 +22,16 @@ test('metadata renders correctly', () => {
|
|
|
22
22
|
expect(metadata).toBeInTheDocument();
|
|
23
23
|
expect(metadataItem).toBeInTheDocument();
|
|
24
24
|
expect(metadataItemKey).toHaveClass('ds_metadata__key');
|
|
25
|
-
expect(metadataItemKey.textContent).toEqual(
|
|
25
|
+
expect(metadataItemKey.textContent).toEqual(NAME);
|
|
26
26
|
expect(metadataItemValue).toHaveClass('ds_metadata__value');
|
|
27
|
-
expect(metadataItemValue.textContent).toEqual(
|
|
27
|
+
expect(metadataItemValue.textContent).toEqual(VALUE);
|
|
28
28
|
});
|
|
29
29
|
|
|
30
30
|
test('inline metadata', () => {
|
|
31
31
|
render(
|
|
32
32
|
<Metadata inline>
|
|
33
|
-
<Metadata.Item name={
|
|
34
|
-
{
|
|
33
|
+
<Metadata.Item name={NAME}>
|
|
34
|
+
{VALUE}
|
|
35
35
|
</Metadata.Item>
|
|
36
36
|
</Metadata>
|
|
37
37
|
);
|