diff --git a/cypress/component/ConversationAlert.cy.tsx b/cypress/component/ConversationAlert.cy.tsx new file mode 100644 index 00000000..f4ab6d41 --- /dev/null +++ b/cypress/component/ConversationAlert.cy.tsx @@ -0,0 +1,11 @@ +import React from 'react'; +import ConversationAlert from '../../packages/module/src/ConversationAlert'; + +describe('ConversationAlert', () => { + it('renders assistant conversation alert', () => { + cy.mount(); + + cy.get('.pf-v5-c-alert__title').first().should('contain', 'You can start a new conversation at any time by typing below.'); + cy.get('.pf-v5-c-alert__icon').first().should('exist'); + }) +}) \ No newline at end of file diff --git a/cypress/component/LoadingMessage.cy.tsx b/cypress/component/LoadingMessage.cy.tsx new file mode 100644 index 00000000..a2f28c4e --- /dev/null +++ b/cypress/component/LoadingMessage.cy.tsx @@ -0,0 +1,20 @@ +import React from 'react'; +import LoadingMessage from '../../packages/module/src/LoadingMessage'; +import GrinIcon from '@patternfly/react-icons/dist/js/icons/grin-icon'; + +describe('LoadingMessage', () => { + it('renders default loading message', () => { + cy.mount(); + + cy.get('[data-test-id="assistant-loading-icon"]').should('have.length', 1); + cy.get('[data-test-id="assistant-loading-dots"]').should('have.length', 1); + }) + + it('renders custom loading message', () => { + cy.mount(); + + cy.get('[data-test-id="assistant-loading-icon"]').should('have.length', 1); + cy.get('[data-test-id="assistant-loading-dots"]').should('have.length', 1); + }) +}) + diff --git a/cypress/component/SystemMessageEntry.cy.tsx b/cypress/component/SystemMessageEntry.cy.tsx new file mode 100644 index 00000000..35051d93 --- /dev/null +++ b/cypress/component/SystemMessageEntry.cy.tsx @@ -0,0 +1,10 @@ +import React from 'react'; +import SystemMessageEntry from '@patternfly/virtual-assistant/src/SystemMessageEntry'; + +describe('SystemMessageEntry', () => { + it('renders assistant system message entry', () => { + cy.mount(Some text); + + cy.get('[data-test-id="assistant-system-message-entry"]').first().should('contain', 'Some text'); + }) +}) \ No newline at end of file diff --git a/cypress/component/VirtualAssistant.cy.tsx b/cypress/component/VirtualAssistant.cy.tsx new file mode 100644 index 00000000..0ec9221f --- /dev/null +++ b/cypress/component/VirtualAssistant.cy.tsx @@ -0,0 +1,34 @@ +import React from 'react'; +import VirtualAssistant from '../../packages/module/src/VirtualAssistant'; + +describe('VirtualAssistant', () => { + it('renders virtual assistant body', () => { + cy.mount(); + + cy.get('[data-test-id="assistant-title"]').first().should('contain', 'Virtual Assistant'); + cy.get('[data-test-id="assistant-text-input"]').first().should('have.attr', 'placeholder', 'Type a message...'); + cy.get('[data-test-id="assistant-send-button"]').first().should('not.be.disabled'); + }) + + it('renders a customized title and placeholder', () => { + cy.mount(); + + cy.get('[data-test-id="assistant-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(); + + 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(); + cy.get('[data-test-id="assistant-send-button"]').should('be.disabled'); + }) +}) \ No newline at end of file diff --git a/cypress/component/VirtualAssistantAction.cy.tsx b/cypress/component/VirtualAssistantAction.cy.tsx new file mode 100644 index 00000000..5422a1f7 --- /dev/null +++ b/cypress/component/VirtualAssistantAction.cy.tsx @@ -0,0 +1,14 @@ +import React from 'react'; +import VirtualAssistantAction from '@patternfly/virtual-assistant/src/VirtualAssistantAction'; +import { AngleDownIcon } from '@patternfly/react-icons'; + +describe('VirtualAssistantAction', () => { + it('renders assistant action', () => { + cy.mount( + + ); + cy.get('[aria-label="Minimize virtual assistant"]').click(); + cy.get('@action').should('have.been.called'); + cy.get('.pf-v5-svg').should('exist'); + }) +}) \ No newline at end of file diff --git a/packages/module/src/LoadingMessage/LoadingMessage.tsx b/packages/module/src/LoadingMessage/LoadingMessage.tsx index dfede7ea..e4e5455e 100644 --- a/packages/module/src/LoadingMessage/LoadingMessage.tsx +++ b/packages/module/src/LoadingMessage/LoadingMessage.tsx @@ -68,12 +68,12 @@ export const LoadingMessage: React.FunctionComponent = ({ i return ( - + -
+
diff --git a/packages/module/src/SystemMessageEntry/SystemMessageEntry.tsx b/packages/module/src/SystemMessageEntry/SystemMessageEntry.tsx index 36c66b21..b0e0c413 100644 --- a/packages/module/src/SystemMessageEntry/SystemMessageEntry.tsx +++ b/packages/module/src/SystemMessageEntry/SystemMessageEntry.tsx @@ -3,7 +3,7 @@ import { Text, TextContent, TextVariants } from '@patternfly/react-core'; import { createUseStyles } from 'react-jss'; export interface SystemMessageEntryProps { - /** Message rendered within the system message entry */ + /** Message rendered within the system message entry */ children: React.ReactNode; } @@ -18,7 +18,7 @@ export const SystemMessageEntry: React.FunctionComponent - + {props.children}