mirror of
https://github.com/cypress-io/cypress.git
synced 2026-02-21 14:41:00 -06:00
chore: adding test for selectFile() in multi-domain (#19786)
This commit is contained in:
2
cli/types/cypress-eventemitter.d.ts
vendored
2
cli/types/cypress-eventemitter.d.ts
vendored
@@ -30,4 +30,4 @@ interface NodeEventEmitter {
|
||||
|
||||
// We use the Buffer class for dealing with binary data, especially around the
|
||||
// selectFile interface.
|
||||
type BufferType = import("buffer/").Buffer
|
||||
type BufferType = typeof import("buffer/").Buffer
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
<a data-cy="scrolling-link" href="http://www.foobar.com:3500/fixtures/scrolling.html">http://www.foobar.com:3500/fixtures/scrolling.html</a>
|
||||
<a data-cy="request-link" href="http://www.foobar.com:3500/fixtures/request.html">http://www.foobar.com:3500/fixtures/request.html</a>
|
||||
<a data-cy="shadow-dom-link" href="http://www.foobar.com:3500/fixtures/shadow-dom.html">http://www.foobar.com:3500/fixtures/shadow-dom.html</a>
|
||||
<a data-cy="files-form-link" href="http://www.foobar.com:3500/fixtures/files-form.html">http://www.foobar.com:3500/fixtures/files-form.html</a>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -138,8 +138,33 @@ context('multi-domain actions', { experimentalSessionSupport: true, experimental
|
||||
cy.switchToDomain('foobar.com', done, () => {
|
||||
const $btn = cy.$$('#button')
|
||||
|
||||
$btn.on('click', (e) => done())
|
||||
$btn.on('click', () => done())
|
||||
cy.get('#button').trigger('click')
|
||||
})
|
||||
})
|
||||
|
||||
it('.selectFile()', () => {
|
||||
cy.get('a[data-cy="files-form-link"]').click()
|
||||
|
||||
cy.switchToDomain('foobar.com', () => {
|
||||
cy.wrap(Cypress.Buffer.from('foo')).as('foo')
|
||||
|
||||
cy.get('#basic')
|
||||
.selectFile({ contents: '@foo', fileName: 'foo.txt' })
|
||||
.should(($input) => {
|
||||
const input = $input[0] as HTMLInputElement
|
||||
const file = input!.files![0]
|
||||
|
||||
expect(file.name).to.equal('foo.txt')
|
||||
|
||||
return file.arrayBuffer()
|
||||
.then((arrayBuffer) => {
|
||||
const decoder = new TextDecoder('utf8')
|
||||
const contents = decoder.decode(arrayBuffer)
|
||||
|
||||
expect(contents).to.equal('foo')
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
@@ -7,7 +7,7 @@ context('multi-domain misc', { experimentalSessionSupport: true, experimentalMul
|
||||
|
||||
it('verifies number of cy commands', () => {
|
||||
// @ts-ignore
|
||||
expect(Object.keys(cy.commandFns).length).to.equal(85,
|
||||
expect(Object.keys(cy.commandFns).length).to.equal(86,
|
||||
'The number of cy commands has changed. Please ensure any newly added commands are also tested in multi-domain.')
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user