chore: adding test for selectFile() in multi-domain (#19786)

This commit is contained in:
Matt Schile
2022-01-20 23:50:41 -07:00
committed by GitHub
parent 7ef104e9a8
commit c84ace4289
4 changed files with 29 additions and 3 deletions

View File

@@ -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

View File

@@ -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>

View File

@@ -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')
})
})
})
})
})

View File

@@ -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.')
})