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

Addon Test: Add interactions functionality #29232

Merged
merged 10 commits into from
Oct 1, 2024

Conversation

yannbf
Copy link
Member

@yannbf yannbf commented Sep 27, 2024

Closes #29215

What I did

This PR brings the addon-interactions panel and functionality into addon test. It's mostly a copy-paste, including e2e tests and unit tests!

Checklist for Contributors

Testing

The changes in this PR are covered in the following automated tests:

  • stories
  • unit tests
  • integration tests
  • end-to-end tests

Manual testing

This section is mandatory for all contributions. If you believe no manual test is necessary, please state so explicitly. Thanks!

Documentation

  • Add or update documentation reflecting your changes
  • If you are deprecating/removing a feature, make sure to update
    MIGRATION.MD

Checklist for Maintainers

  • When this PR is ready for testing, make sure to add ci:normal, ci:merged or ci:daily GH label to it to run a specific set of sandboxes. The particular set of sandboxes can be found in code/lib/cli/src/sandbox-templates.ts

  • Make sure this PR contains one of the labels below:

    Available labels
    • bug: Internal changes that fixes incorrect behavior.
    • maintenance: User-facing maintenance tasks.
    • dependencies: Upgrading (sometimes downgrading) dependencies.
    • build: Internal-facing build tooling & test updates. Will not show up in release changelog.
    • cleanup: Minor cleanup style change. Will not show up in release changelog.
    • documentation: Documentation only changes. Will not show up in release changelog.
    • feature request: Introducing a new feature.
    • BREAKING CHANGE: Changes that break compatibility in some way with current major version.
    • other: Changes that don't fit in the above categories.

🦋 Canary release

This PR does not have a canary release associated. You can request a canary release of this pull request by mentioning the @storybookjs/core team here.

core team members can create a canary release here or locally with gh workflow run --repo storybookjs/storybook canary-release-pr.yml --field pr=<PR_NUMBER>

name before after diff z %
createSize 0 B 0 B 0 B - -
generateSize 0 B 77.7 MB 77.7 MB - 100%
initSize 0 B 152 MB 152 MB - 100%
diffSize 0 B 74.4 MB 74.4 MB - 100%
buildSize 0 B 7.27 MB 7.27 MB - 100%
buildSbAddonsSize 0 B 1.87 MB 1.87 MB - 100%
buildSbCommonSize 0 B 195 kB 195 kB - 100%
buildSbManagerSize 0 B 1.92 MB 1.92 MB - 100%
buildSbPreviewSize 0 B 312 kB 312 kB - 100%
buildStaticSize 0 B 0 B 0 B - -
buildPrebuildSize 0 B 4.3 MB 4.3 MB - 100%
buildPreviewSize 0 B 2.97 MB 2.97 MB - 100%
testBuildSize 0 B 0 B 0 B - -
testBuildSbAddonsSize 0 B 0 B 0 B - -
testBuildSbCommonSize 0 B 0 B 0 B - -
testBuildSbManagerSize 0 B 0 B 0 B - -
testBuildSbPreviewSize 0 B 0 B 0 B - -
testBuildStaticSize 0 B 0 B 0 B - -
testBuildPrebuildSize 0 B 0 B 0 B - -
testBuildPreviewSize 0 B 0 B 0 B - -
name before after diff z %
createTime 0ms 6s 6s - 100%
generateTime 0ms 19.7s 19.7s - 100%
initTime 0ms 14s 14s - 100%
buildTime 0ms 8.7s 8.7s - 100%
testBuildTime 0ms 0ms 0ms - -
devPreviewResponsive 0ms 6.7s 6.7s - 100%
devManagerResponsive 0ms 4.2s 4.2s - 100%
devManagerHeaderVisible 0ms 667ms 667ms - 100%
devManagerIndexVisible 0ms 707ms 707ms - 100%
devStoryVisibleUncached 0ms 844ms 844ms - 100%
devStoryVisible 0ms 706ms 706ms - 100%
devAutodocsVisible 0ms 630ms 630ms - 100%
devMDXVisible 0ms 610ms 610ms - 100%
buildManagerHeaderVisible 0ms 667ms 667ms - 100%
buildManagerIndexVisible 0ms 739ms 739ms - 100%
buildStoryVisible 0ms 740ms 740ms - 100%
buildAutodocsVisible 0ms 544ms 544ms - 100%
buildMDXVisible 0ms 520ms 520ms - 100%

Greptile Summary

This PR introduces the interactions functionality from addon-interactions into addon-test, focusing on integrating the Interactions panel and related components.

  • Added new Panel component in src/Panel.tsx to handle rendering and state management of interactions
  • Introduced InteractionsPanel component in src/components/InteractionsPanel.tsx for displaying test results and exceptions
  • Updated src/manager.tsx to include the new Component Tests panel with dynamic title showing interaction count and exceptions
  • Added utility functions in src/utils.ts for error handling and ANSI to HTML conversion
  • Introduced test stories in stories/basics.stories.ts demonstrating various interaction testing scenarios

Copy link

nx-cloud bot commented Sep 27, 2024

☁️ Nx Cloud Report

CI is running/has finished running commands for commit 3c49ac3. As they complete they will appear below. Click to see the status, the terminal output, and the build insights.

📂 See all runs for this CI Pipeline Execution


✅ Successfully ran 1 target

Sent with 💌 from NxCloud.

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

30 file(s) reviewed, 33 comment(s)
Edit PR Review Bot Settings

Comment on lines +123 to +124
([end]: any) => setScrollTarget(end.isIntersecting ? undefined : end.target),
{ root: global.document.querySelector('#panel-tab-content') }
Copy link
Contributor

Choose a reason for hiding this comment

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

style: Type assertion to 'any' here may be unsafe. Consider using a more specific type or adding a type guard.


const storyFilePath = useParameter('fileName', '');
const [fileName] = storyFilePath.toString().split('/').slice(-1);
const scrollToTarget = () => scrollTarget?.scrollIntoView({ behavior: 'smooth', block: 'end' });
Copy link
Contributor

Choose a reason for hiding this comment

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

style: Consider memoizing this function to prevent unnecessary re-creation on each render.

Comment on lines +234 to +237
const hasException =
!!caughtException ||
!!unhandledErrors ||
interactions.some((v) => v.status === CallStates.ERROR);
Copy link
Contributor

Choose a reason for hiding this comment

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

style: This logic for determining hasException is duplicated in the state. Consider refactoring to use a single source of truth.

Comment on lines +52 to +53
Interaction tests allow you to verify the functional aspects of UIs. Write a play function
for your story and you&apos;ll see it run here.
Copy link
Contributor

Choose a reason for hiding this comment

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

style: consider wrapping long lines for better readability

title: 'Interaction',
component: Interaction,
args: {
callsById: new Map(getCalls(CallStates.DONE).map((call) => [call.id, call])),
Copy link
Contributor

Choose a reason for hiding this comment

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

style: Consider using a more descriptive variable name instead of 'call' for clarity

);
}

addons.register(ADDON_ID, (api) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

style: The 'api' parameter is unused. Consider removing it if not needed

ancestors: ['story--id [6] waitFor'],
path: ['expect'],
method: 'stringMatching',
args: [{ __regexp__: { flags: 'gi', source: '([A-Z])w+' } }],
Copy link
Contributor

Choose a reason for hiding this comment

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

syntax: The regular expression '([A-Z])w+' might be incorrect. Did you mean '([A-Z])\w+'?

/** Interaction Testing Theme PLACEHOLDER until SB is updated <3 */
interface Colors {
pure?: {
gray?: any;
Copy link
Contributor

Choose a reason for hiding this comment

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

style: Consider using a more specific type than 'any' for better type safety

colors,
};

export default theme;
Copy link
Contributor

Choose a reason for hiding this comment

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

style: Remove this empty line at the end of the file

Comment on lines +5 to +7
export function isTestAssertionError(error: unknown) {
return isChaiError(error) || isJestError(error);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

style: Consider adding a more specific return type (e.g., boolean) for clarity

@yannbf yannbf added ci:daily Run the CI jobs that normally run in the daily job. and removed ci:normal labels Sep 27, 2024
@yannbf yannbf added ci:normal and removed ci:daily Run the CI jobs that normally run in the daily job. labels Sep 30, 2024
@yannbf yannbf merged commit 43a5c82 into unified-ui-testing Oct 1, 2024
4 of 7 checks passed
@yannbf yannbf deleted the yann/introduce-test-panel branch October 1, 2024 10:20
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.

2 participants