Skip to content

Commit

Permalink
Merge branch 'main' into chatbot/sessions-list
Browse files Browse the repository at this point in the history
  • Loading branch information
christian-calabrese authored Oct 2, 2024
2 parents 278be98 + 86ffbd6 commit 01f27c2
Show file tree
Hide file tree
Showing 96 changed files with 2,313 additions and 286 deletions.
5 changes: 5 additions & 0 deletions .changeset/brown-boats-pretend.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"nextjs-website": patch
---

Set font size to be 16px on bold and italic sections
5 changes: 5 additions & 0 deletions .changeset/clean-clocks-care.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"nextjs-website": minor
---

Add links to headings created with CKEditor in the in-page menu of Tutorial pages
5 changes: 5 additions & 0 deletions .changeset/funny-pans-joke.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"strapi-cms": minor
---

Add product to ApiData
5 changes: 5 additions & 0 deletions .changeset/giant-icons-kick.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"nextjs-website": patch
---

Add padding and margin to mobile version in ecosystem cards
6 changes: 6 additions & 0 deletions .changeset/happy-stingrays-argue.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"nextjs-website": minor
"storybook-app": minor
---

Add chatbot history list component
5 changes: 5 additions & 0 deletions .changeset/late-trainers-try.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"strapi-cms": patch
---

Require all entries with a slug field to have it unique
5 changes: 5 additions & 0 deletions .changeset/light-months-act.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"nextjs-website": patch
---

Add margin bottom to block content images
5 changes: 5 additions & 0 deletions .changeset/modern-chicken-check.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"nextjs-website": patch
---

Add wordwrap break word to links
5 changes: 5 additions & 0 deletions .changeset/old-plums-joke.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"nextjs-website": patch
---

Fix product layout path for Api page
6 changes: 6 additions & 0 deletions .changeset/quick-buckets-change.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"nextjs-website": minor
"storybook-app": minor
---

Add chatobot layout component
5 changes: 5 additions & 0 deletions .changeset/quiet-bears-admire.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"nextjs-website": minor
---

Add structured data to alla pages
5 changes: 5 additions & 0 deletions .changeset/silent-bobcats-happen.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"nextjs-website": minor
---

Guest chatbot message
6 changes: 6 additions & 0 deletions .changeset/stale-shrimps-lie.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"nextjs-website": minor
"storybook-app": minor
---

Add chatbot chat history detail layout
5 changes: 5 additions & 0 deletions .changeset/tame-spoons-love.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"nextjs-website": patch
---

Remove input text and history button if user not logged in
5 changes: 5 additions & 0 deletions .changeset/three-walls-kick.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"nextjs-website": patch
---

Fix ecosystem and card grid for correct card box shadows
5 changes: 5 additions & 0 deletions .changeset/tidy-trains-shake.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"strapi-cms": patch
---

Remove unique validator from api rest detail component because of strapi bug https://github.com/strapi/strapi/issues/12541
5 changes: 5 additions & 0 deletions .changeset/twenty-laws-juggle.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"nextjs-website": patch
---

Add api title to breadcrumbs
2 changes: 1 addition & 1 deletion apps/nextjs-website/jest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const jestConfig: JestConfigWithTsJest = {
setupFilesAfterEnv: ['<rootDir>/jest-setup.ts'],
testMatch: ['**/__tests__/**/*test.+(ts|tsx)'],
moduleFileExtensions: ['ts', 'js', 'tsx'],
testEnvironment: 'jsdom',
testEnvironment: '@bufbuild/jest-environment-jsdom',
transform: {
// See the discussion https://github.com/vercel/next.js/issues/8663
'^.+\\.(ts|tsx)$': ['ts-jest', { tsconfig: 'tsconfig.jest.json' }],
Expand Down
2 changes: 2 additions & 0 deletions apps/nextjs-website/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
"io-ts": "^2.2.20",
"io-ts-types": "^0.5.19",
"isomorphic-dompurify": "^2.3.0",
"jsdom": "^25.0.0",
"mermaid": "^10.9.0",
"monocle-ts": "^2.3.13",
"newtype-ts": "^0.3.5",
Expand All @@ -50,6 +51,7 @@
"swr": "^2.2.4"
},
"devDependencies": {
"@bufbuild/jest-environment-jsdom": "^0.1.1",
"@testing-library/jest-dom": "^6.4.2",
"@testing-library/react": "^14.1.2",
"@types/jest": "^29.5.1",
Expand Down
11 changes: 11 additions & 0 deletions apps/nextjs-website/public/icons/chatbotChatUserBorder.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
43 changes: 43 additions & 0 deletions apps/nextjs-website/src/__tests__/helpers/anchor.helpers.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import { generateIdFromString } from '@/helpers/anchor.helpers';

describe('generateIdFromString', () => {
it('should return an empty string when id is undefined', () => {
const result = generateIdFromString(undefined);
expect(result).toBe('');
});

it('should trim, lowercase, and replace spaces with hyphens', () => {
const result = generateIdFromString(' Test String ');
expect(result).toBe('test-string');
});

it('should remove accents and special characters @#', () => {
const result = generateIdFromString('Éxámplé String!@#!@#$%^&*()_+');
expect(result).toBe('example-string!!$%^&*()_');
});

it('should not modify an already normalized string', () => {
const result = generateIdFromString('simple-string');
expect(result).toBe('simple-string');
});

it('should handle numbers correctly', () => {
const result = generateIdFromString('12345 test');
expect(result).toBe('12345-test');
});

it('should remove invalid characters but keep punctuation', () => {
const result = generateIdFromString('This is valid?!');
expect(result).toBe('this-is-valid?!');
});

it('should handle strings with multiple spaces', () => {
const result = generateIdFromString('Test multiple spaces');
expect(result).toBe('test-multiple-spaces');
});

it('should handle strings with only spaces', () => {
const result = generateIdFromString(' ');
expect(result).toBe('');
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import { parseCkEditorContent } from '@/helpers/parseCkEditorContent.helpers';

describe('parseCkEditorContent', () => {
it('should correctly parse content and generate menu items', () => {
const content = `<h1>titolo h1</h1><h2>Éxámplé String!@#!@#$%^&amp;*()_+</h2><h3>titolo h3</h3><h4>titolo h4</h4><p><strong>titolo h5</strong></p><p><i>titolo h6</i></p><h2>Un esempio: la TARI</h2><p>Nella tabella che segue trovi un esempio sbagliato, con un numero inutilmente elevato di servizi relativi alla TARI:</p><figure class="table"><table><thead><tr><th><strong>SERVIZIO</strong></th><th><strong>MESSAGGIO</strong></th></tr></thead><tbody><tr><td>❌ TRIBUTI - TARI - Notifica sollecito</td><td>Notifica sollecito TARI</td></tr><tr><td>❌ TRIBUTI - TARI - Notifica provvedimento ordinario</td><td>Notifica provvedimento ordinario TARI</td></tr><tr><td>❌ TRIBUTI - TARI - Notifica provvedimento sanzionatorio</td><td>Notifica provvedimento sanzionatorio TARI</td></tr></tbody></table></figure><p>In realtà, <strong>l’unico servizio è la TARI</strong>, e <strong>da questo unico servizio dovrai inviare tutti i messaggi relativi al suo ciclo di vita</strong>, come ad esempio:</p><ul><li>inviare un messaggio informativo che ricorda ai destinatari che è il momento di fare la dichiarazione di occupazione, nel caso in cui debbano farla;</li><li>inviare uno o più messaggi sullo stato della richiesta di occupazione;<ul><li>inviare un messaggio con l'avviso di pagamento;</li></ul></li><li>inviare promemoria in prossimità della scadenza di un pagamento. daFAFDV</li></ul><blockquote><p>quote dei quote</p></blockquote>`;

const result = parseCkEditorContent(content);

// Test the parsedContent
expect(result.parsedContent).toContain('titolo h1'); // Check if a h1 heading is present
expect(result.parsedContent).toContain('Éxámplé String!@#!@#$%^&amp;*()_+'); // Check if a h2 heading is present
expect(result.parsedContent).toContain(
`id="ckeditor-example-string!!$%^&amp;*()_"`
); // Check if IDs are added correctly around a h2 heading
expect(result.parsedContent).toContain(
`<div class="menuAnchor" id="ckeditor-example-string!!$%^&amp;*()_"><h2>Éxámplé String!@#!@#$%^&amp;*()_+</h2></div>`
); // Check if IDs are added correctly around a h2 heading

// Test the menuItems array
expect(result.menuItems).toEqual([
{
title: 'Éxámplé String!@#!@#$%^&*()_+',
href: '#ckeditor-example-string!!$%^&*()_',
level: 2,
},
{ title: 'titolo h3', href: '#ckeditor-titolo-h3', level: 3 },
{
title: 'Un esempio: la TARI',
href: '#ckeditor-un-esempio:-la-tari',
level: 2,
},
]);
});

it('should return an empty menuItems array if there are no headings', () => {
const content = `<p>Some content without headings</p>`;

const result = parseCkEditorContent(content);

expect(result.parsedContent).toContain(
'<p>Some content without headings</p>'
);
expect(result.menuItems).toEqual([]); // Expecting no menu items
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,15 @@ import {
import { ApiDataParams } from '@/lib/types/apiDataParams';
import PageNotFound from '@/app/not-found';
import { SEO } from '@/lib/types/seo';
import { generateStructuredDataScripts } from '@/helpers/generateStructuredDataScripts.helpers';
import {
breadcrumbItemByProduct,
convertApiToStructuredDataSoftwareApplication,
productToBreadcrumb,
} from '@/helpers/structuredData.helpers';

export type ApiPageProps = {
readonly title?: string;
readonly product?: Product;
readonly apiDataSlug: string;
readonly specURLsName?: string;
Expand Down Expand Up @@ -51,13 +58,33 @@ export const generateMetadata = async (
const ApiDataPage = async ({ params }: ApiDataParams) => {
const apiDataProps = await getApiData(params.apiDataSlug);
const product = await getProduct(params.productSlug);

const structuredData = generateStructuredDataScripts({
breadcrumbsItems: [
productToBreadcrumb(product),
{
name: apiDataProps?.seo?.metaTitle,
item: breadcrumbItemByProduct(product, [
'api',
`${apiDataProps?.apiDataSlug}`,
]),
},
],
seo: apiDataProps?.seo,
things: [convertApiToStructuredDataSoftwareApplication(apiDataProps)],
});

const path = product?.path + '/api/' + params.apiDataSlug;

if (apiDataProps && product) {
return (
<ProductLayout
product={product}
path={product.path.concat('/api')}
path={path}
paths={[{ name: apiDataProps.title || '', path: path }]}
bannerLinks={product.bannerLinks || apiDataProps.bannerLinks}
showBreadcrumbs
structuredData={structuredData}
>
<ApiSection
apiSlug={params.apiDataSlug}
Expand Down
33 changes: 24 additions & 9 deletions apps/nextjs-website/src/app/[productSlug]/api/page.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
import ProductLayout from '@/components/organisms/ProductLayout/ProductLayout';
import ApiDataListTemplate from '@/components/templates/ApiDataListTemplate/ApiDataListTemplate';
import { baseUrl } from '@/config';
import { generateStructuredDataScripts } from '@/helpers/generateStructuredDataScripts.helpers';
import {
breadcrumbItemByProduct,
productToBreadcrumb,
} from '@/helpers/structuredData.helpers';
import {
makeMetadata,
makeMetadataFromStrapi,
Expand Down Expand Up @@ -40,17 +45,27 @@ const ApiDataListPage = async ({ params }: { params: Params }) => {
const apiDataListPageProps = await getApiDataListPages(params.productSlug);
const product = await getProduct(params.productSlug);

const structuredData = generateStructuredDataScripts({
breadcrumbsItems: [
productToBreadcrumb(product),
{
name: apiDataListPageProps?.seo?.metaTitle,
item: breadcrumbItemByProduct(product, ['api']),
},
],
seo: apiDataListPageProps?.seo,
});

if (apiDataListPageProps && product) {
return (
<>
<ProductLayout
product={product}
path={product.path.concat('/api')}
showBreadcrumbs
>
<ApiDataListTemplate {...apiDataListPageProps} />
</ProductLayout>
</>
<ProductLayout
product={product}
path={product.path.concat('/api')}
showBreadcrumbs
structuredData={structuredData}
>
<ApiDataListTemplate {...apiDataListPageProps} />
</ProductLayout>
);
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@ import {
import GitBookTemplate from '@/components/templates/GitBookTemplate/GitBookTemplate';
import { productPageToBreadcrumbs } from '@/helpers/breadcrumbs.helpers';
import { getGuidesProps } from '@/lib/cmsApi';
import { generateStructuredDataScripts } from '@/helpers/generateStructuredDataScripts.helpers';
import {
breadcrumbItemByProduct,
convertSeoToStructuredDataArticle,
productToBreadcrumb,
} from '@/helpers/structuredData.helpers';

type Params = {
productSlug: string;
Expand Down Expand Up @@ -76,7 +82,7 @@ const Page = async ({ params }: { params: Params }) => {
params?.productGuidePage ?? ['']
);

const { product, page, guide, version, versions, source, bannerLinks } =
const { product, page, guide, version, versions, source, bannerLinks, seo } =
guideProps;
const props: ProductGuidePageProps = {
...page,
Expand All @@ -96,11 +102,27 @@ const Page = async ({ params }: { params: Params }) => {
},
};

const structuredData = generateStructuredDataScripts({
breadcrumbsItems: [
productToBreadcrumb(product),
{
name: seo?.metaTitle,
item: breadcrumbItemByProduct(product, [
'guides',
...(params?.productGuidePage || []),
]),
},
],
seo: seo,
things: [convertSeoToStructuredDataArticle(seo)],
});

return (
<ProductLayout
product={props.product}
path={props.path}
bannerLinks={props.bannerLinks}
structuredData={structuredData}
>
<GitBookTemplate
menuName={props.guide.name}
Expand Down
Loading

0 comments on commit 01f27c2

Please sign in to comment.