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

feat: cy.selectFile() #19332

Merged
merged 17 commits into from Dec 22, 2021
Merged

feat: cy.selectFile() #19332

merged 17 commits into from Dec 22, 2021

Conversation

BlueWinds
Copy link
Contributor

@BlueWinds BlueWinds commented Dec 10, 2021

User facing changelog

Adds native support for .selectFile(), allowing interaction with file input elements as well as simulating a user drag-dropping files over the document.

cy.get('input[type="file"]').selectFile('cypress/fixtures/myfixture.json');

The API is similar to cypress-file-upload, and we have provided a migration guide for previous users of that plugin.

For full details, see the .selectFile() documentation.

Additional details

The documentation and migration guide contain extensive information about all the options and features of this new command.

PR Tasks

@cypress-bot
Copy link
Contributor

cypress-bot bot commented Dec 10, 2021

Thanks for taking the time to open a PR!

@BlueWinds BlueWinds marked this pull request as draft December 10, 2021 17:38
@BlueWinds
Copy link
Contributor Author

Moving to draft temporarily while I get the tests passing. Documentation / code wise, I don't expect much to change here, just have to fix a couple things that came up from merging in 10.0-release.

@cypress
Copy link

cypress bot commented Dec 10, 2021



Test summary

18419 0 218 0Flakiness 3


Run details

Project cypress
Status Passed
Commit 4e3559c
Started Dec 20, 2021 9:40 PM
Ended Dec 20, 2021 9:52 PM
Duration 11:56 💡
OS Linux Debian - 10.10
Browser Multiple

View run in Cypress Dashboard ➡️


Flakiness

commands/net_stubbing_spec.ts Flakiness
1 network stubbing > waiting and aliasing > can timeout waiting on a single request using "alias.request"
2 network stubbing > waiting and aliasing > can timeout waiting on a single request using "alias.request"
cypress/proxy-logging-spec.ts Flakiness
1 Proxy Logging > request logging > xhr log has response body/status code

This comment has been generated by cypress-bot as a result of this project's GitHub integration settings. You can manage this integration in this project's settings in the Cypress Dashboard

@BlueWinds BlueWinds marked this pull request as ready for review December 14, 2021 19:52
@BlueWinds
Copy link
Contributor Author

Ok, tests fixed (only remaining failure is flake in the 10.0-release branch, nothing to do with this PR).

AtofStryker
AtofStryker previously approved these changes Dec 14, 2021
Copy link
Contributor

@AtofStryker AtofStryker left a comment

Choose a reason for hiding this comment

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

Integration tests look to cover multiple use cases as well as most error states. Docs looks ready to go and the system test on 3rd party integrations looks really nice. I also found the code fairly easy to follow and a lot of the provided comments really helped shed clarity on some areas. Great work 🎉 !

packages/driver/src/cy/commands/actions/index.ts Outdated Show resolved Hide resolved
system-tests/package.json Outdated Show resolved Hide resolved
packages/driver/src/cy/commands/actions/attachFile.ts Outdated Show resolved Hide resolved
AtofStryker
AtofStryker previously approved these changes Dec 15, 2021
Copy link
Contributor

@AtofStryker AtofStryker left a comment

Choose a reason for hiding this comment

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

Looks good! Guessing the net_stubbing_spec is currently a little flaky. I had some issues getting the tests to pass consistently locally, but if I am wrong about that lmk! Changes here look unrelated.

@BlueWinds BlueWinds changed the title feat: cy.attachFile() feat: cy.selectFile() Dec 17, 2021
cli/types/cypress.d.ts Outdated Show resolved Hide resolved
cli/types/cypress.d.ts Outdated Show resolved Hide resolved
* Attach a file to the given <input> element, or drag and drop a file over any subject.
*
* @param {FileReference} files - The file(s) to attach or drag onto this element.
* @see https://on.cypress.io/selectFile
Copy link
Member

Choose a reason for hiding this comment

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

Has this on link been created on Services? I think this is also meant to be all lowercaps to reroute correctly.

Suggested change
* @see https://on.cypress.io/selectFile
* @see https://on.cypress.io/selectfile

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It hasn't been added yet - I'll open a PR to do that, thanks for the reminder.

I'm lowercasing the link for consistency, but worth noting that URLs are almost universally case insensitive on all modern systems. This isn't given in any spec, and it's not universally true, but in most cases it is.

https://docs.cypReSS.io/api/cOmMaNdS/wItHiN

(let's never actually do this, just an interesting note)

Copy link
Contributor Author

@BlueWinds BlueWinds Dec 20, 2021

Choose a reason for hiding this comment

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

@BlueWinds
Copy link
Contributor Author

Only test failure is unrelated, an issue with circleci and pulling dockerhub images. I think we're about ready to merge into 10.0-release, so that I can start on the backport into develop?

@BlueWinds BlueWinds merged commit 6d10a7f into 10.0-release Dec 22, 2021
@BlueWinds BlueWinds deleted the feat/attach-file branch December 22, 2021 17:03
BlueWinds pushed a commit that referenced this pull request Jan 3, 2022
* feat: cy.attachFile with passed-in contents (#18825)
* feat: attachFile string shorthands (#19045)
* feat: Add drag-n-drop support (#19213)
* Remove cypress-file-upload
jennifer-shehane pushed a commit that referenced this pull request Jan 14, 2022
@cypress-bot
Copy link
Contributor

cypress-bot bot commented Jun 1, 2022

Released in 10.0.0.

This comment thread has been locked. If you are still experiencing this issue after upgrading to
Cypress v10.0.0, please open a new issue.

@cypress-bot cypress-bot bot locked as resolved and limited conversation to collaborators Jun 1, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants