-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #81 from fhlavac/inscope
feat(inscope): Inscope enhancements
- Loading branch information
Showing
33 changed files
with
776 additions
and
213 deletions.
There are no files selected for viewing
This file contains 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 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 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,58 @@ | ||
import React from 'react'; | ||
import Citations, { CitationsProps } from '../../packages/module/src/Citations'; | ||
|
||
const testCitations: CitationsProps['citations'] = [ | ||
{ | ||
id: 'citation-1', | ||
title: 'Understanding PatternFly Layouts', | ||
content: 'Content explaining the use of various layouts in PatternFly.', | ||
ouiaId: 'citation-1', | ||
}, | ||
{ | ||
id: 'citation-2', | ||
title: 'PatternFly Design Guidelines', | ||
content: 'Content about design guidelines.', | ||
ouiaId: 'citation-2', | ||
}, | ||
{ | ||
id: 'citation-3', | ||
title: 'Accessibility in PatternFly', | ||
content: 'Content about accessibility practices.', | ||
ouiaId: 'citation-3', | ||
}, | ||
]; | ||
|
||
describe('Citations', () => { | ||
it('renders expandable section with citations', () => { | ||
cy.mount(<Citations citations={testCitations} toggleText="Show Citations" ouiaId="test-citations" />); | ||
|
||
cy.get('[data-ouia-component-id="test-citations-expandable-section"]').should('have.length', 1); | ||
cy.get('[data-ouia-component-id="test-citations-accordion"]').should('not.be.visible'); | ||
}); | ||
|
||
it('expands and displays citations on toggle', () => { | ||
cy.mount(<Citations citations={testCitations} toggleText="Show Citations" ouiaId="test-citations" />); | ||
|
||
cy.get('[data-ouia-component-id="test-citations-expandable-section"] button').first().click(); | ||
cy.get('[data-ouia-component-id="test-citations-accordion"]').should('be.visible'); | ||
|
||
cy.get('[data-ouia-component-id="citation-1-toggle"]').should('have.length', 1); | ||
cy.get('[data-ouia-component-id="citation-2-toggle"]').should('have.length', 1); | ||
cy.get('[data-ouia-component-id="citation-3-toggle"]').should('have.length', 1); | ||
}); | ||
|
||
it('toggles citations within the accordion', () => { | ||
cy.mount(<Citations citations={testCitations} toggleText="Show Citations" ouiaId="test-citations" />); | ||
|
||
cy.get('[data-ouia-component-id="test-citations-expandable-section"] button').first().click(); | ||
|
||
cy.get('[data-ouia-component-id="citation-1-toggle"]').click(); | ||
cy.get('[data-ouia-component-id="citation-1-content"]').should('be.visible'); | ||
|
||
cy.get('[data-ouia-component-id="citation-2-toggle"]').click(); | ||
cy.get('[data-ouia-component-id="citation-1-content"]').should('be.visible'); | ||
cy.get('[data-ouia-component-id="citation-1-toggle"]').click(); | ||
cy.get('[data-ouia-component-id="citation-1-content"]').should('not.be.visible'); | ||
cy.get('[data-ouia-component-id="citation-2-content"]').should('be.visible'); | ||
}); | ||
}); |
This file contains 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 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 |
---|---|---|
@@ -1,34 +1,49 @@ | ||
import React from 'react'; | ||
import { CardHeader } from '@patternfly/react-core'; | ||
import VirtualAssistant from '../../packages/module/src/VirtualAssistant'; | ||
|
||
describe('VirtualAssistant', () => { | ||
describe('VirtualAssistant', () => { | ||
it('renders virtual assistant body', () => { | ||
cy.mount(<VirtualAssistant />); | ||
|
||
cy.get('[data-test-id="assistant-title"]').first().should('contain', 'Virtual Assistant'); | ||
cy.get('[data-ouia-component-id="VirtualAssistant-title"]').first().should('contain', 'Virtual Assistant'); | ||
cy.get('[data-test-id="assistant-text-input"]').first().should('have.attr', 'placeholder', 'Send a message...'); | ||
cy.get('[data-test-id="assistant-send-button"]').first().should('not.be.disabled'); | ||
}) | ||
}); | ||
|
||
it('renders a customized title and placeholder', () => { | ||
cy.mount(<VirtualAssistant title="PatternFly assistant" inputPlaceholder="You can ask anything in here." />); | ||
|
||
cy.get('[data-test-id="assistant-title"]').should('contain', 'PatternFly assistant'); | ||
cy.get('[data-ouia-component-id="VirtualAssistant-title"]').should('contain', 'PatternFly assistant'); | ||
cy.get('[data-test-id="assistant-text-input"]').should('have.attr', 'placeholder', 'You can ask anything in here.'); | ||
cy.get('[data-test-id="assistant-send-button"]').should('not.be.disabled'); | ||
}) | ||
}); | ||
|
||
it('listens to messages', () => { | ||
cy.mount(<VirtualAssistant onChangeMessage={cy.stub().as('change')} onSendMessage={cy.stub().as('send')} />); | ||
|
||
cy.get('[data-test-id="assistant-text-input"]').type('my message'); | ||
cy.get('[data-test-id="assistant-send-button"]').click(); | ||
cy.get('@change').should('have.been.called'); | ||
cy.get('@send').should('have.been.called'); | ||
}) | ||
}); | ||
|
||
it('renders header with disabled send button', () => { | ||
cy.mount(<VirtualAssistant isSendButtonDisabled />); | ||
|
||
cy.get('[data-test-id="assistant-send-button"]').should('be.disabled'); | ||
}) | ||
}) | ||
}); | ||
|
||
it('renders in full-page mode', () => { | ||
cy.mount(<VirtualAssistant isFullPage title="Full Page Assistant" />); | ||
|
||
cy.get('[data-ouia-component-id="VirtualAssistant-title"]').should('contain', 'Full Page Assistant'); | ||
cy.get('.fullPage').should('exist'); | ||
}); | ||
|
||
it('renders a custom header', () => { | ||
cy.mount(<VirtualAssistant header={<CardHeader data-ouia-component-id="custom-header">Custom Header</CardHeader>} />); | ||
|
||
cy.get('[data-ouia-component-id="custom-header"]').should('contain', 'Custom Header'); | ||
}); | ||
}); |
This file contains 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 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 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 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
35 changes: 35 additions & 0 deletions
35
...xtensions/virtual-assistant/examples/VirtualAssistant/AssistantMessageNoRadiusExample.tsx
This file contains 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 @@ | ||
import React from 'react'; | ||
import VirtualAssistant from '@patternfly/virtual-assistant/dist/dynamic/VirtualAssistant'; | ||
import AssistantMessageEntry from '@patternfly/virtual-assistant/dist/dynamic/AssistantMessageEntry'; | ||
|
||
const noRadiusTheme = { | ||
global: { | ||
borderRadiusBubble: '0' | ||
}, | ||
components: { | ||
VirtualAssistant: { | ||
card: { | ||
borderRadius: '0', | ||
}, | ||
textArea: { | ||
borderRadius: "0", | ||
} | ||
}, | ||
AssistantMessageEntry: { | ||
label: { | ||
borderRadius: '0' | ||
} | ||
} | ||
} | ||
} | ||
|
||
export const BasicExample: React.FunctionComponent = () => ( | ||
<VirtualAssistant theme={noRadiusTheme}> | ||
<AssistantMessageEntry | ||
// eslint-disable-next-line no-console | ||
options={[ { title: "Option #1", props: { onClick: () => {console.log('This is an example of onClick event')} } }, { title: "Option #2" }, { title: "Option #3" } ]} | ||
> | ||
How may I help you today? Do you have some question for me? | ||
</AssistantMessageEntry> | ||
</VirtualAssistant> | ||
); |
Oops, something went wrong.