Skip to content

Commit

Permalink
Update schema
Browse files Browse the repository at this point in the history
  • Loading branch information
compulim committed Mar 21, 2024
1 parent 0a22c36 commit aca0ab1
Show file tree
Hide file tree
Showing 8 changed files with 51 additions and 49 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 6 additions & 6 deletions __tests__/html/linkDefinition/badge.html
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
citation: [
{
'@type': 'Claim',
'@id': 'https://example.com/1/',
appearance: {
'@type': 'DigitalDocument',
url: 'https://example.com/1/',
Expand All @@ -49,11 +48,11 @@
termCode: 'orange'
}
}
}
},
position: 1
},
{
'@type': 'Claim',
'@id': '_:3',
appearance: {
'@type': 'DigitalDocument',
text: 'Incididunt amet dolore anim commodo fugiat occaecat elit nulla do consequat. Quis incididunt occaecat labore adipisicing. Cillum sunt velit consequat irure ipsum ullamco sint ea aute. Sunt et eu ut enim aliqua cupidatat non adipisicing dolore commodo dolor magna enim. Commodo reprehenderit excepteur ad nostrud ex id aliquip deserunt eiusmod. Esse non labore nulla voluptate.',
Expand All @@ -67,15 +66,16 @@
termCode: 'Yellow'
}
}
}
},
position: 3
},
{
'@type': 'Claim',
'@id': '_:4',
appearance: {
'@type': 'DigitalDocument',
text: 'Ea nisi nostrud duis dolore aliqua sit reprehenderit minim est nisi id est sit. Amet mollit ex fugiat sint aliquip Lorem eiusmod incididunt nulla laboris labore nulla. In id exercitation ut non non Lorem consequat cupidatat deserunt do aliqua exercitation. Minim commodo aliquip dolore exercitation officia commodo sint aute aute. Fugiat laborum proident cupidatat quis eiusmod excepteur voluptate commodo. Ullamco minim duis id deserunt laboris ullamco cupidatat dolor est sint ut. Anim pariatur non ea do occaecat dolor sint ad.'
}
},
position: 4
}
],
type: 'https://schema.org/Message',
Expand Down
54 changes: 25 additions & 29 deletions __tests__/html/linkDefinition/reference.html
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,14 @@
});

await directLine.emulateIncomingActivity({
additionalType: ['AIGeneratedContent'],
entities: [
{
'@context': 'https://schema.org',
'@id': '',
'@type': 'Message',
citation: [
{
'@id':
'https://learn.microsoft.com/en-us/entra/identity/app-proxy/conceptual-deployment-plan#application-discovery',
'@type': 'Claim',
appearance: {
'@type': 'DigitalDocument',
Expand All @@ -55,11 +54,10 @@
'@type': 'Project',
slogan: 'Surfaced with Azure OpenAI',
url: 'https://learn.microsoft.com/en-us/azure/ai-services/openai/overview'
}
},
position: 1
},
{
'@id':
'https://support.microsoft.com/en-us/windows/use-a-proxy-server-in-windows-03096c53-0554-4ffe-b6ab-8b1deee8dae1#ID0EFD=Windows_11',
'@type': 'Claim',
appearance: {
'@type': 'DigitalDocument',
Expand All @@ -69,10 +67,10 @@
'@type': 'Project',
slogan: 'Surfaced with Azure OpenAI',
url: 'https://learn.microsoft.com/en-us/azure/ai-services/openai/overview'
}
},
position: 2
},
{
'@id': 'https://learn.microsoft.com/en-us/entra/identity-platform/refresh-tokens',
'@type': 'Claim',
appearance: {
'@type': 'DigitalDocument',
Expand All @@ -98,10 +96,10 @@
'@type': 'Project',
slogan: 'Surfaced with Azure OpenAI',
url: 'https://learn.microsoft.com/en-us/azure/ai-services/openai/overview'
}
},
position: 3
}
],
keywords: ['ai-generated-content'],
type: 'https://schema.org/Message',
usageInfo: { '@id': '_:s1' }
}
Expand All @@ -112,55 +110,53 @@

await host.snapshot();

const [firstActivityElement] = pageElements.activities();
const activityElement = pageElements.activities()[2];

const linkDefinitions = firstActivityElement.querySelectorAll('.webchat__link-definitions__list-item');
const linkDefinitions = activityElement.querySelectorAll('.webchat__link-definitions__list-item');

expect(linkDefinitions).toHaveProperty('length', 5);
expect(linkDefinitions).toHaveProperty('length', 3);

expect(linkDefinitions[0].querySelector('.webchat__link-definitions__list-item-box').tagName).toBe('A');
expect(
linkDefinitions[0].querySelector('.webchat__link-definitions__list-item-text').getAttribute('title')
).toBe('Sint amet id officia dolor ex eiusmod ipsum ipsum magna fugiat');
).toBe('IT - Proxy Settings for external access');
expect(linkDefinitions[0].querySelector('.webchat__link-definitions__list-item-badge')).toHaveProperty(
'textContent',
'General'
);
expect(
linkDefinitions[0].querySelector('.webchat__link-definitions__list-item-badge').getAttribute('title')
).toBe(
'Sit veniam do irure velit est et quis ut Lorem reprehenderit commodo cillum occaecat\n\nNisi quis ut sint elit est nulla enim eiusmod. Deserunt commodo pariatur nostrud culpa aliquip esse pariatur exercitation nulla do proident. Est qui eiusmod aliquip deserunt labore consequat fugiat. Ullamco reprehenderit nostrud eiusmod nisi nulla esse id. Reprehenderit aliqua quis consectetur sit cupidatat fugiat Lorem ex labore. Eiusmod velit laborum quis tempor incididunt excepteur culpa esse nulla.'
);
).toBe('General');

expect(linkDefinitions[1].querySelector('.webchat__link-definitions__list-item-box').tagName).toBe('A');
expect(
linkDefinitions[1].querySelector('.webchat__link-definitions__list-item-text').getAttribute('title')
).toBe('Laboris cupidatat voluptate');
).toBe('Changing proxy settings - Windows 11');
expect(linkDefinitions[1].querySelector('.webchat__link-definitions__list-item-badge')).toBeNull();

expect(linkDefinitions[2].querySelector('.webchat__link-definitions__list-item-box').tagName).toBe('BUTTON');
expect(linkDefinitions[2].querySelector('.webchat__link-definitions__list-item-box').tagName).toBe('A');
expect(
linkDefinitions[2].querySelector('.webchat__link-definitions__list-item-text').getAttribute('title')
).toBe('Velit nulla culpa eu ea consectetur consectetur dolore velit');
).toBe('How to renew authentication token');
expect(
linkDefinitions[2].querySelector('.webchat__link-definitions__list-item-badge').getAttribute('title')
).toBe('Velit exercitation');

expect(linkDefinitions[3].querySelector('.webchat__link-definitions__list-item-box').tagName).toBe('BUTTON');
expect(
linkDefinitions[3].querySelector('.webchat__link-definitions__list-item-text').getAttribute('title')
).toBe('Adipisicing enim nulla');
expect(linkDefinitions[3].querySelector('.webchat__link-definitions__list-item-badge')).toBeNull();
).toBe(
'Confidential\\Any User (No Protection)\n\nData is classified as Confidential but is NOT PROTECTED to allow access by approved NDA business partners. If a higher level of protection is needed please change the sensitivity level of the cited content.'
);

expect(document.querySelector('.webchat__link-definitions__header-text')).toHaveProperty(
'textContent',
'5 references'
'3 references'
);

expect(document.querySelector('.webchat__link-definitions__message-sensitivity-label-text')).toHaveProperty(
'textContent',
'Sit veniam do irure velit est et quis ut Lorem reprehenderit commodo cillum occaecat'
'Confidential\\Any User (No Protection)'
);

expect(document.querySelector('.webchat__link-definitions__message-sensitivity-label')).toHaveProperty(
'title',
'Sit veniam do irure velit est et quis ut Lorem reprehenderit commodo cillum occaecat\n\nNisi quis ut sint elit est nulla enim eiusmod. Deserunt commodo pariatur nostrud culpa aliquip esse pariatur exercitation nulla do proident. Est qui eiusmod aliquip deserunt labore consequat fugiat. Ullamco reprehenderit nostrud eiusmod nisi nulla esse id. Reprehenderit aliqua quis consectetur sit cupidatat fugiat Lorem ex labore. Eiusmod velit laborum quis tempor incididunt excepteur culpa esse nulla.'
'Confidential\\Any User (No Protection)\n\nData is classified as Confidential but is NOT PROTECTED to allow access by approved NDA business partners. If a higher level of protection is needed please change the sensitivity level of the cited content.'
);

expect(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ const MarkdownTextContent = memo(({ activity, markdown }: Props) => {
markdownDefinitions.map<Entry>(markdownDefinition => {
const messageCitation = messageThing?.citation
?.map(parseClaim)
.find(({ '@id': id }) => id === markdownDefinition.url);
.find(({ position }) => '' + position === markdownDefinition.identifier);

if (messageCitation) {
return {
Expand Down
8 changes: 8 additions & 0 deletions packages/core/src/types/external/OrgSchema/Claim.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,12 @@ describe('Claim', () => {
slogan: 'Empower every person and every organization on the planet to achieve more.'
}
}));

describe('should parse position', () => {
test('as a number', () =>
expect(parseClaim({ '@type': 'Claim', position: 1 })).toEqual({ '@type': 'Claim', position: 1 }));

test('as a string', () =>
expect(parseClaim({ '@type': 'Claim', position: 'First' })).toEqual({ '@type': 'Claim', position: 'First' }));
});
});
10 changes: 9 additions & 1 deletion packages/core/src/types/external/OrgSchema/Claim.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { lazy, parse, type ObjectEntries } from 'valibot';
import { lazy, number, parse, string, union, type ObjectEntries } from 'valibot';

import { creativeWork, type CreativeWork } from './CreativeWork';
import { project, type Project } from './Project';
Expand Down Expand Up @@ -27,12 +27,20 @@ export type Claim = CreativeWork & {
* @see https://schema.org/claimInterpreter.
*/
claimInterpreter?: Project | undefined;

/**
* The position of an item in a series or sequence of items.
*
* @see https://schema.org/position.
*/
position?: number | string;
};

export const claim = <TEntries extends ObjectEntries>(entries?: TEntries | undefined) =>
creativeWork({
appearance: orgSchemaProperty(lazy(() => creativeWork())),
claimInterpreter: orgSchemaProperty(lazy(() => project())),
position: orgSchemaProperty(union([number(), string()])),

...entries
});
Expand Down
14 changes: 2 additions & 12 deletions packages/core/src/utils/getOrgSchemaMessage.spec.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,5 @@
import type { WebChatActivity } from '../types/WebChatActivity';
import getOrgSchemaMessage from './getOrgSchemaMessage';

const activityTemplate: WebChatActivity = {
channelData: { 'webchat:sequence-id': 0 },
from: { id: 'bot', role: 'bot' },
id: 'a-00001',
text: 'Hello, World!',
timestamp: '2024-03-01T12:34:56.000Z',
type: 'message'
};

test('should get message', () => {
const expected = {
'@context': 'https://schema.org',
Expand All @@ -18,7 +8,7 @@ test('should get message', () => {
type: 'https://schema.org/Message'
};

expect(getOrgSchemaMessage({ ...activityTemplate, entities: [expected] })).toEqual(expected);
expect(getOrgSchemaMessage([expected])).toEqual(expected);
});

test('should not get message without @id of empty string', () => {
Expand All @@ -28,5 +18,5 @@ test('should not get message without @id of empty string', () => {
type: 'https://schema.org/Message'
};

expect(getOrgSchemaMessage({ ...activityTemplate, entities: [expected] })).toBeUndefined();
expect(getOrgSchemaMessage([expected])).toBeUndefined();
});

0 comments on commit aca0ab1

Please sign in to comment.