Skip to content

Conversation

@AlexAndBear
Copy link
Contributor

Description

Related Issue

How Has This Been Tested?

  • test environment:
  • test case 1:
  • test case 2:
  • ...

Types of changes

  • Bugfix
  • Enhancement (a change that doesn't break existing code or deployments)
  • Breaking change (a modification that affects current functionality)
  • Technical debt (addressing code that needs refactoring or improvements)
  • Tests (adding or improving tests)
  • Documentation (updates or additions to documentation)
  • Maintenance (like dependency updates or tooling adjustments)

Copy link
Contributor

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 adds comprehensive unit tests for context menu drop functionality and refactors the related components to support the new drop-menu API.

  • Snapshots for ContextActionMenu and ActionMenuDropItem updated to include nested drop menus.
  • Tests migrated from shallowMount to mount and prop renamed to menuSectionDrop.
  • Component code refactored: prop renames, ID and class adjustments, and removal of unused imports.

Reviewed Changes

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

Show a summary per file
File Description
packages/web-pkg/tests/unit/components/ContextActions/ContextActionMenu.spec.ts Switched to mount, updated test cases and snapshots to cover drop menus.
packages/web-pkg/tests/unit/components/ContextActions/ActionMenuDropItem.spec.ts New tests for drop-item rendering and empty-state behavior.
packages/web-pkg/src/composables/actions/files/useFileActionsNavigate.ts Changed the user-facing label from “Open folder” to “Open”.
packages/web-pkg/src/components/ContextActions/ContextActionMenu.vue Prop for drop component renamed to menu-section-drop.
packages/web-pkg/src/components/ContextActions/ActionMenuItem.vue Removed unused useGettext import.
packages/web-pkg/src/components/ContextActions/ActionMenuDropItem.vue Renamed props to menuSectionDrop, updated HTML ID generation logic, empty-state class, and iteration keys.
Comments suppressed due to low confidence (3)

packages/web-pkg/tests/unit/components/ContextActions/ContextActionMenu.spec.ts:17

  • The new empty-state behavior (renderOnEmpty) is tested in ActionMenuDropItem but not in ContextActionMenu. Consider adding a test case in this spec to verify that empty-drop sections render the empty message correctly.
it('renders the menu with drop menu items', async () => {

packages/web-pkg/src/components/ContextActions/ActionMenuDropItem.vue:4

  • Generating HTML IDs from the dynamic label can lead to invalid or unstable IDs (e.g., spaces, translated text). Consider using a stable property such as section.name or a sanitized slug for the ID.
:id="`oc-files-context-actions-${menuSectionDrop.label}-toggle`"

packages/web-pkg/src/composables/actions/files/useFileActionsNavigate.ts:43

  • [nitpick] Changing the label from 'Open folder' to 'Open' may affect user expectations and translation keys. Ensure all translation resources are updated and any documentation or UI guidelines reflect this change.
label: () => $gettext('Open'),

@AlexAndBear AlexAndBear force-pushed the issues/773-unit-tests branch from 298fddd to 50e09d7 Compare June 12, 2025 22:32
@AlexAndBear
Copy link
Contributor Author

AlexAndBear commented Jun 12, 2025

@JammingBen this also fixed:

  • "open with..." drop opens randomly by default not 😡
  • drop disappears when moving mouse out of the drop
  • don't close Open with... drop, when the toggle button is clicked
  • Move check if nested drop toggle button is clicked to oc-drop, and don't close the drop, if so @JammingBen this is nice, as this was the onliest implementation in the former PR, I despised

@AlexAndBear AlexAndBear reopened this Jun 12, 2025
@AlexAndBear AlexAndBear force-pushed the issues/773-unit-tests branch from c02e7ba to 06d29ec Compare June 13, 2025 00:18
export type MenuSectionDrop = {
label: string
name: string
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this is for e2e tests

@AlexAndBear AlexAndBear requested a review from kulmann June 13, 2025 00:24
@AlexAndBear AlexAndBear force-pushed the issues/773-unit-tests branch from 401f451 to d1faf45 Compare June 13, 2025 00:48
return isTouchDevice() ? 'click' : 'mouseenter focus'
}
return mode
return (
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Reverted to original

@AlexAndBear AlexAndBear force-pushed the issues/773-unit-tests branch from 72d7f25 to 74bb39b Compare June 13, 2025 01:05
@AlexAndBear AlexAndBear force-pushed the issues/773-unit-tests branch from 74bb39b to fbc3b47 Compare June 13, 2025 01:28
Copy link
Contributor

@JammingBen JammingBen left a comment

Choose a reason for hiding this comment

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

🏅

@AlexAndBear AlexAndBear merged commit f10bbe3 into main Jun 13, 2025
18 checks passed
@AlexAndBear AlexAndBear deleted the issues/773-unit-tests branch June 13, 2025 08:26
@openclouders openclouders mentioned this pull request Jun 12, 2025
1 task
openclouders pushed a commit that referenced this pull request Jun 13, 2025
* test: add unit tests for context menu drop

* simplify check if click event is on nestedToggleEvent

* don't close nested drop when click on toggle item
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.

3 participants