-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
Update blob-util to 2.0.2 #7795
Update blob-util to 2.0.2 #7795
Conversation
Thanks for taking the time to open a PR!
|
firefox-5 is flaky failure. But firefox-8 is a bit weird. It failed exactly 63 tests but the test failed because of 62 !== 63. |
I think this may need to be considered a breaking change, mostly because of the following in the changes:
We use the promise version of |
@chrisbreiding this is a breaking change and pulled against the 5.0 release branch, so ok to merge in. But yes, I would like a more descriptive explanation for what needs to change for user facing documentation, since I'm writing a migration guide. Also that example updated in a docs PR. |
@jennifer-shehane I guess the list of changed functions is good enough, right? |
@sainthkh Sure, if you want to get something started or comment in here, I can work on more complete documentation of the change. |
The return type of the 4 APIs is changed from
2 more APIs are added:
There're 2 ways to fix the example in the documentation. Bare version: // programmatically upload the logo
cy.fixture('images/logo.png').as('logo')
cy.get('input[type=file]').then(function($input) {
// convert the logo base64 string to a blob
const blob = Cypress.Blob.base64StringToBlob(this.logo, 'image/png')
// pass the blob to the fileupload jQuery plugin
// used in your application's code
// which initiates a programmatic upload
$input.fileupload('add', { files: blob })
}) Promise-wrapped version: // programmatically upload the logo
cy.fixture('images/logo.png').as('logo')
cy.get('input[type=file]').then(function($input) {
// convert the logo base64 string to a blob
new Promise((resolve) => {
const blob = Cypress.Blob.base64StringToBlob(this.logo, 'image/png')
resolve(blob)
}).then((blob) => {
// pass the blob to the fileupload jQuery plugin
// used in your application's code
// which initiates a programmatic upload
$input.fileupload('add', { files: blob })
})
}) I personally prefer the first version because it's simpler. We don't have to change the second example, because |
Opened a PR for docs here: cypress-io/cypress-documentation#2938 |
If we really want to be nice to our users... we should override the I imagine not many users actually use these functions (unless it is used internally in a 3rd party plugin somewhere), so that may be overkill. |
@brian-mann Everyone that tests a file upload uses this method, so I would expect that to be a lot of people actually - and some of the plugins made for file upload. |
To implement Brian's idea, we need to add |
@sainthkh if you have the time then I don't see why not. |
@brian-mann I tried it and it isn't simple. Because webpack makes the members of |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice! Just some suggestions on the wording of this message.
The tests in this PR are incorrect. The |
it('arrayBufferToBlob', () => { | ||
cy.on('fail', (err) => { | ||
expect(err.message).to.include('no longer returns a `Promise`') | ||
}) | ||
|
||
Cypress.Blob.arrayBufferToBlob('1234').then((blob) => { | ||
// it should fail. | ||
}) | ||
}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A (done)
callback parameter must be yielded to guarantee that the cy.on('fail', ...)
hits accordingly otherwise the test can pass if the error handle is not invoked.
it('arrayBufferToBlob', (done) => {
cy.on('fail', (err) => {
expect(err.message).to.include('no longer returns a `Promise`')
done()
})
Cypress.Blob.arrayBufferToBlob('1234').then((blob) => {
// it should fail.
})
})
I will update the tests in this branch directly, but noting the changes here. |
User facing changelog
Breaking changes
Cypress.Blob
methodsarrayBufferToBlob
,base64StringToBlob
,binaryStringToBlob
, anddataURLToBlob
have changed fromPromise<Blob>
toBlob
.Dependency Updates
blob-utils
from1.3.3
to2.0.2
.Additional details
How has the user experience changed?
Before
After
PR Tasks
cypress-documentation
? Updates for blob from 5.0 cypress-documentation#2938type definitions
?