-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add component tests for existing components
- Loading branch information
Showing
7 changed files
with
93 additions
and
4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import React from 'react'; | ||
import ConversationAlert from '../../packages/module/src/ConversationAlert'; | ||
|
||
describe('ConversationAlert', () => { | ||
it('renders assistant conversation alert', () => { | ||
cy.mount(<ConversationAlert title='You can start a new conversation at any time by typing below.'/>); | ||
|
||
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'); | ||
}) | ||
}) |
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,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(<LoadingMessage />); | ||
|
||
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(<LoadingMessage icon={GrinIcon} />); | ||
|
||
cy.get('[data-test-id="assistant-loading-icon"]').should('have.length', 1); | ||
cy.get('[data-test-id="assistant-loading-dots"]').should('have.length', 1); | ||
}) | ||
}) | ||
|
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,10 @@ | ||
import React from 'react'; | ||
import SystemMessageEntry from '@patternfly/virtual-assistant/src/SystemMessageEntry'; | ||
|
||
describe('SystemMessageEntry', () => { | ||
it('renders assistant system message entry', () => { | ||
cy.mount(<SystemMessageEntry>Some text</SystemMessageEntry>); | ||
|
||
cy.get('[data-test-id="assistant-system-message-entry"]').first().should('contain', 'Some text'); | ||
}) | ||
}) |
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,34 @@ | ||
import React from 'react'; | ||
import VirtualAssistant from '../../packages/module/src/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-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(<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-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'); | ||
}) | ||
}) |
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,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(<VirtualAssistantAction aria-label="Minimize virtual assistant" onClick={cy.stub().as('action')}> | ||
<AngleDownIcon/> | ||
</VirtualAssistantAction>); | ||
cy.get('[aria-label="Minimize virtual assistant"]').click(); | ||
cy.get('@action').should('have.been.called'); | ||
cy.get('.pf-v5-svg').should('exist'); | ||
}) | ||
}) |
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