Skip to content

Conversation

@qxprakash
Copy link
Collaborator

Tests added as discussed in slack_discussion

directory structure mocked :

root/ 
├── first/
│   ├── second/
│   │   ├── third/
│   │   │   ├── nested-target.pdf
│   │   │   └── new-file.pdf
│   │   ├── deep-file.txt
│   │   ├── target.pdf
│   │   └── workspace.pdf
│   └── intermediate.doc
├── workspace/
│   └── project/
│       └── code.js
└── readme.md

Some of the mocked responses in CompanionHandler.ts aren’t used in the tests, but I’ve kept them to preserve the legitimacy of the above directory structure.

@changeset-bot
Copy link

changeset-bot bot commented Oct 16, 2025

⚠️ No Changeset found

Latest commit: d486396

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@qxprakash qxprakash requested review from Murderlon and mifi October 16, 2025 13:52
@qxprakash
Copy link
Collaborator Author

yarn typecheck doesn't fail on local

Copy link
Contributor

@mifi mifi left a comment

Choose a reason for hiding this comment

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

we should avoid sprinkling arbitrary setTimeout values around the tests


afterEach(async () => {
if (uppy) {
// Small delay to allow Preact cleanup hooks to complete
Copy link
Contributor

Choose a reason for hiding this comment

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

which hooks are you talking about here? adding delays to tests is generally a bad idea because we want tests to be a fast as possible, and delays cause race conditions and flaky tests. we should try to find another way like listening to the hooks complete event.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I don’t remember the exact reason I added it, but it was definitely after some error that got resolved once I introduced a delay. However, I agree with your point , removed it now.

await userEvent.type(searchInput, 'target')

// Wait for debounce (500ms) + network response
await new Promise((resolve) => setTimeout(resolve, 600))
Copy link
Contributor

Choose a reason for hiding this comment

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

again, we should probably disable debouncing for tests. 600ms is a long time to wait for each tests, as it adds up. AFAIK vitest browser mode and playwright already waits for UI/network to settle when looking for things. you can see goldenRetriever.browser.test.ts how i use a special Symbol to make a non-public API that allows changing the debounce timeout

Copy link
Collaborator Author

@qxprakash qxprakash Nov 2, 2025

Choose a reason for hiding this comment

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

added.

Copy link
Collaborator Author

@qxprakash qxprakash left a comment

Choose a reason for hiding this comment

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

this took more time than I expected , tbh I didn't want to rush it as I wanted to get a bit more comfortable with vitest.


await expect
.element(
page.getByRole('checkbox', { name: 'deep-file.txt', exact: true }),
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

In Normal mode (ListItem.tsx), folders are rendered as buttons, whereas files are rendered as checkboxes with a corresponding <label>.
In Search mode (SearchListItem.tsx), both files and folders are rendered as buttons.

Because of this, in Normal mode, when checking whether a file exists, I need to use:

await expect.element(page.getByRole('button', { name:'nested-target.pdf', exact: true }))

whereas, in Search mode, I need to scope the query to the checkbox role instead when searching for a file

Copy link
Contributor

Choose a reason for hiding this comment

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

maybe add exactly that as a comment :)

Comment on lines 340 to 351
if (this.opts.supportsSearch) {
// Test hook: allow tests to disable debounce by setting a special Symbol on the class
const ctor = this.constructor as unknown as Record<symbol, unknown>
const testDebounceMs = ctor[Symbol.for('uppy test: searchDebounceMs')] as
| number
| undefined
if (testDebounceMs === 0) {
void this.#search()
} else {
this.#searchDebounced()
}
}
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

AI was used in this part, so please give it special attention.

Copy link
Member

Choose a reason for hiding this comment

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

Do we really need this? This is quite specific code just for tests, which I'm not a fan enough. Can we work our way around this?

Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe it can instead be done like how i did in golden rettiever tests

@qxprakash qxprakash requested a review from mifi November 2, 2025 22:35
Copy link
Contributor

@mifi mifi left a comment

Choose a reason for hiding this comment

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

looks great now. you're a vitest e2e master now!

once the type tests are green then this lgtm

afterEach(async () => {
if (!uppy) return

// this is done to prevent the edgecase when all plugins are removed before dashboard is unmounted from UI
Copy link
Contributor

Choose a reason for hiding this comment

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

This sounds like a bug we should fix in the uppy code(instead of working around it in the tests). If it's a crash that users can also hit when calling destroy(). but we can do that in a different issue

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

yes will reproduce this and open a separate issue.


await expect
.element(
page.getByRole('checkbox', { name: 'deep-file.txt', exact: true }),
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe add exactly that as a comment :)

Copy link
Member

@Murderlon Murderlon left a comment

Choose a reason for hiding this comment

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

One last comment, then good to go

Comment on lines 340 to 351
if (this.opts.supportsSearch) {
// Test hook: allow tests to disable debounce by setting a special Symbol on the class
const ctor = this.constructor as unknown as Record<symbol, unknown>
const testDebounceMs = ctor[Symbol.for('uppy test: searchDebounceMs')] as
| number
| undefined
if (testDebounceMs === 0) {
void this.#search()
} else {
this.#searchDebounced()
}
}
Copy link
Member

Choose a reason for hiding this comment

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

Do we really need this? This is quite specific code just for tests, which I'm not a fan enough. Can we work our way around this?

@qxprakash qxprakash requested review from Murderlon and mifi November 4, 2025 18:16
Copy link
Contributor

@mifi mifi left a comment

Choose a reason for hiding this comment

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

I think we need to fix the type test, or else we will have it on main after merge, right?

@qxprakash
Copy link
Collaborator Author

yarn typecheck is passing on local

@mifi
Copy link
Contributor

mifi commented Nov 6, 2025

yarn typecheck is passing on local

but we still need to fix it here on CI, no?

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants