Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get tests up to ~20% #252

Merged
merged 13 commits into from
Oct 29, 2024
Merged

Conversation

rebeccaalpert
Copy link
Member

@rebeccaalpert rebeccaalpert commented Oct 18, 2024

First round of testing - goal is to set up Jest and get coverage to ~20%.

Found several bugs and fixed them, so this is definitely useful already:

  • Message with attachment always had a close button, even if there was no close function
  • Welcome prompt should have required title rather than message since just having a message results in rendering issues (title is fine)
  • Removed unnecessary CSS on hidden jump links (they are removed from the DOM, so no need for classes)
  • Access to strings for i18n in MessageLoading, AI label in Message
File % Stmts % Branch % Funcs % Lines Uncovered Line #s
All files 25.59 27.03 18.64 25.5
AssistantMessageEntry 0 0 0 0
AssistantMessageEntry.tsx 0 0 0 0 1-44
AttachMenu 0 0 0 0
AttachMenu.tsx 0 0 0 0 4-81
AttachmentEdit 0 0 0 0
AttachmentEdit.tsx 0 0 0 0 4-63
Chatbot 62.5 12.5 33.33 60
Chatbot.tsx 62.5 12.5 33.33 60 32-46
ChatbotAlert 0 0 0 0
ChatbotAlert.tsx 0 0 0 0 1-32
ChatbotContent 0 0 0 0
ChatbotContent.tsx 0 0 0 0 4-23
ChatbotConversationHistoryNav 0 0 0 0
ChatbotConversationHistoryDropdown.tsx 0 0 0 0 4-62
ChatbotConversationHistoryNav.tsx 0 0 0 0 4-217
ChatbotFooter 0 0 0 0
ChatbotFooter.tsx 0 0 0 0 11-33
ChatbotFootnote.tsx 0 0 0 0 5-135
ChatbotHeader 0 0 0 0
ChatbotHeader.tsx 0 0 0 0 1-22
ChatbotHeaderActions.tsx 0 0 0 0 1-15
ChatbotHeaderMain.tsx 0 100 0 0 1-15
ChatbotHeaderMenu.tsx 0 0 0 0 1-40
ChatbotHeaderOptionsDropdown.tsx 0 0 0 0 1-73
ChatbotHeaderSelectorDropdown.tsx 0 0 0 0 1-68
ChatbotHeaderTitle.tsx 0 0 0 0 1-57
ChatbotPopover 0 0 0 0
ChatbotPopover.tsx 0 0 0 0 4-15
ChatbotToggle 0 0 0 0
ChatbotToggle.tsx 0 0 0 0 5-77
ChatbotWelcomePrompt 100 100 100 100
ChatbotWelcomePrompt.tsx 100 100 100 100
CodeModal 0 0 0 0
CodeModal.tsx 0 0 0 0 4-154
FileDetails 100 100 100 100
FileDetails.tsx 100 100 100 100
FileDetailsLabel 100 100 100 100
FileDetailsLabel.tsx 100 100 100 100
FileDropZone 73.33 62.5 20 73.33
FileDropZone.tsx 73.33 62.5 20 73.33 30,43-47
LoadingMessage 100 100 100 100
LoadingMessage.tsx 100 100 100 100
Message 100 100 100 100
Message.tsx 100 100 100 100
MessageLoading.tsx 100 100 100 100
Message/CodeBlockMessage 28.57 0 0 32
CodeBlockMessage.tsx 28.57 0 0 32 15-66
Message/TextMessage 100 100 100 100
TextMessage.tsx 100 100 100 100
MessageBar 0 0 0 0
AttachButton.tsx 0 0 0 0 4-74
MessageBar.tsx 0 0 0 0 1-161
MicrophoneButton.tsx 0 0 0 0 4-111
SendButton.tsx 0 0 0 0 4-51
MessageBox 16.27 22.22 12.5 16.27
JumpButton.tsx 100 100 100 100
MessageBox.tsx 0 0 0 0 4-98
PreviewAttachment 0 0 0 0
PreviewAttachment.tsx 0 0 0 0 4-67
ResponseActions 100 87.8 100 100
ResponseActionButton.tsx 100 84.37 100 100 34-37,43
ResponseActions.tsx 100 90 100 100 48,59,70,81,92
SourceDetailsMenuItem 0 0 0 0
SourceDetailsMenuItem.tsx 0 0 0 0 1-36
SourcesCard 100 92.59 100 100
SourcesCard.tsx 100 92.59 100 100 99,126
SystemMessageEntry 0 100 0 0
SystemMessageEntry.tsx 0 100 0 0 1-17
UserMessageEntry 0 0 0 0
UserMessageEntry.tsx 0 0 0 0 1-27
VirtualAssistant 100 89.47 100 100
VirtualAssistant.tsx 100 89.47 100 100 48,61
VirtualAssistantAction 0 0 0 0
VirtualAssistantAction.tsx 0 0 0 0 1-12

@patternfly-build
Copy link

patternfly-build commented Oct 18, 2024

@rebeccaalpert rebeccaalpert changed the title Draft: chore(SourcesCard): Add tests chore(SourcesCard): Add tests Oct 18, 2024
Wrong prompt prop was also optional - caused rendering issues without it.
Also removed unnecessary class now that it's removed from DOM when isHidden is used.
@rebeccaalpert rebeccaalpert linked an issue Oct 19, 2024 that may be closed by this pull request
@rebeccaalpert rebeccaalpert changed the title chore(SourcesCard): Add tests Draft: Get tests up to ~20% Oct 19, 2024
@@ -17,14 +17,15 @@ module.exports = {
'!<rootDir>/packages/**/index.js',
'!<rootDir>/packages/**/*{c|C}ontext*.js',
'!<rootDir>/packages/components/src/Components/Table/*',
'<rootDir>/packages/**/src/**/*.tsx'
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is what I changed; rest is formatter.

@rebeccaalpert rebeccaalpert force-pushed the sources-tests branch 2 times, most recently from 0748421 to 4b940f7 Compare October 21, 2024 17:23
@rebeccaalpert rebeccaalpert changed the title Draft: Get tests up to ~20% Get tests up to ~20% Oct 21, 2024
transformIgnorePatterns: [
'node_modules/(?!@patternfly|@data-driven-forms)',

'node_modules/(?!@patternfly|@data-driven-forms|react-syntax-highlighter|remark-gfm|react-markdown|remark-parse|devlop|hast-util-to-jsx-runtime|comma-separated-tokens|estree-util-is-identifier-name|hast-util-whitespace|property-information|space-separated-tokens|unist-util-position|vfile-message|unist-util-stringify-position|html-url-attributes|mdast-util-from-markdown|mdast-util-to-string|micromark|decode-named-character-reference|remark-rehype|mdast-util-to-hast|trim-lines|unist-util-visit|unist-util-is|unified|bail|is-plain-obj|trough|vfile|mdast-util-gfm|ccount|mdast-util-find-and-replace|escape-string-regexp|markdown-table|mdast-util-to-markdown|zwitch|longest-streak|mdast-util-phrasing)'
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is what I changed.

},
'^.+\\.tsx?$': ['ts-jest', { tsconfig: './packages/module/tsconfig.json' }],
// Ensure ES modules are transformed
'^.+\\.js$': 'babel-jest'
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is what I changed.

Make data-testid configurable in user-composable components and rework tests to go without on generated components.
@rebeccaalpert
Copy link
Member Author

rebeccaalpert commented Oct 22, 2024

Adjusted the test ids @nicolethoen! Thanks for the feedback there.

@nicolethoen nicolethoen merged commit 0f35f6a into patternfly:main Oct 29, 2024
7 checks passed
Copy link

🎉 This PR is included in version 2.1.0-prerelease.4 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

v6 chatbot - Get testing coverage up to 20%
3 participants