Skip to content

Open PR and add tests if confident #93127

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

Closed

Conversation

armenzg
Copy link
Member

@armenzg armenzg commented Jun 9, 2025

The screenshot widget in Issue Details was updated to improve file detection.

  • In static/app/components/events/eventTagsAndScreenshot/screenshot/screenshotDataSection.tsx, the hardcoded SCREENSHOT_NAMES array was removed.
  • The logic was updated to flexibly identify screenshots by checking if an attachment's name includes "screenshot" and ends with .jpg or .png. This change addresses issue Issue detail screenshot preview: Improve screenshot file detection #92154, allowing files like crash_screenshot.png to be displayed.
  • A new test case was added to static/app/components/events/eventTagsAndScreenshot/index.spec.tsx to validate the updated detection logic, ensuring files with flexible naming patterns are correctly identified and navigable.
  • API mocks were added to the test to ensure proper functionality.
  • A new documentation file, screenshot_detection_improvement.md, was created to detail these changes.

…xible naming - Replace hardcoded screenshot names with flexible pattern matching that detects any file containing 'screenshot' and ending with .jpg/.png - Maintains backwards compatibility and adds test coverage - Fixes GitHub issue #92154
@armenzg armenzg requested a review from Copilot June 9, 2025 17:47
@github-actions github-actions bot added the Scope: Frontend Automatically applied to PRs that change frontend components label Jun 9, 2025
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR updates the screenshot widget in Issue Details to improve file detection by removing hardcoded filename exclusions and implementing a flexible check for screenshot file names. Additionally, it adds a new test case to validate the updated logic and introduces documentation to explain these changes.

  • Removed hardcoded SCREENSHOT_NAMES and implemented a flexible filename check.
  • Added test coverage for various screenshot naming patterns.
  • Provided documentation on improved screenshot detection.

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
static/app/components/events/eventTagsAndScreenshot/screenshot/screenshotDataSection.tsx Removed hardcoded names and updated logic to flexibly detect screenshots.
static/app/components/events/eventTagsAndScreenshot/index.spec.tsx Added new test cases to validate detection of screenshots with flexible naming.
screenshot_detection_improvement.md New documentation detailing the changes to screenshot detection.
Comments suppressed due to low confidence (1)

static/app/components/events/eventTagsAndScreenshot/screenshot/screenshotDataSection.tsx:52

  • [nitpick] Consider using a case-insensitive check for 'screenshot' (e.g., converting attachment.name to lowercase) to ensure that files with differently cased names are also detected.
attachments?.filter((attachment: EventAttachment) => attachment.name.includes('screenshot') && (attachment.name.endsWith('.jpg') || attachment.name.endsWith('.png'))) ?? [];

Copy link

codecov bot commented Jun 9, 2025

❌ 1 Tests Failed:

Tests completed Failed Passed Skipped
10526 1 10525 9
View the top 1 failed test(s) by shortest run time
EventTagsAndScreenshot renders screenshot and tags detects screenshots with flexible naming
Stack Traces | 0.078s run time
Error: expect(jest.fn()).toHaveBeenCalled()

Expected number of calls: >= 1
Received number of calls:    0
    at assertTagsView (.../events/eventTagsAndScreenshot/index.spec.tsx:139:33)
    at Object.<anonymous> (.../events/eventTagsAndScreenshot/index.spec.tsx:529:13)
    at Promise.then.completed (.../sentry/node_modules/.pnpm/[email protected][email protected]..../jest-circus/build/utils.js:298:28)
    at new Promise (<anonymous>)
    at callAsyncCircusFn (.../sentry/node_modules/.pnpm/[email protected][email protected]..../jest-circus/build/utils.js:231:10)
    at _callCircusTest (.../sentry/node_modules/.pnpm/[email protected][email protected]..../jest-circus/build/run.js:316:40)
    at _runTest (.../sentry/node_modules/.pnpm/[email protected][email protected]..../jest-circus/build/run.js:252:3)
    at _runTestsForDescribeBlock (.../sentry/node_modules/.pnpm/[email protected][email protected]..../jest-circus/build/run.js:126:9)
    at _runTestsForDescribeBlock (.../sentry/node_modules/.pnpm/[email protected][email protected]..../jest-circus/build/run.js:121:9)
    at _runTestsForDescribeBlock (.../sentry/node_modules/.pnpm/[email protected][email protected]..../jest-circus/build/run.js:121:9)
    at run (.../sentry/node_modules/.pnpm/[email protected][email protected]..../jest-circus/build/run.js:71:3)
    at runAndTransformResultsToJestFormat (.../sentry/node_modules/.pnpm/[email protected][email protected]..../build/legacy-code-todo-rewrite/jestAdapterInit.js:122:21)
    at jestAdapter (.../sentry/node_modules/.pnpm/[email protected][email protected]..../build/legacy-code-todo-rewrite/jestAdapter.js:79:19)
    at runTestInternal (.../sentry/node_modules/.pnpm/[email protected]..../jest-runner/build/runTest.js:367:16)
    at runTest (.../sentry/node_modules/.pnpm/[email protected]..../jest-runner/build/runTest.js:444:34)
    at Object.worker (.../sentry/node_modules/.pnpm/[email protected]..../jest-runner/build/testWorker.js:106:12)

To view more test analytics, go to the Test Analytics Dashboard
📋 Got 3 mins? Take this short survey to help us improve Test Analytics.

@armenzg armenzg closed this Jun 10, 2025
@github-actions github-actions bot locked and limited conversation to collaborators Jun 25, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Scope: Frontend Automatically applied to PRs that change frontend components
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants