Update to cypress 9 and fix firefox upload crash (#1653)

Signed-off-by: Tilman Vatteroth <git@tilmanvatteroth.de>
Co-authored-by: Renovate Bot <bot@renovateapp.com>
This commit is contained in:
Tilman Vatteroth 2021-12-11 21:17:23 +01:00 committed by GitHub
parent d4251519e2
commit 03725f5512
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 80 additions and 58 deletions

View file

@ -0,0 +1 @@
Invalid json

View file

@ -0,0 +1,3 @@
SPDX-FileCopyrightText: 2021 The HedgeDoc developers (see AUTHORS file)
SPDX-License-Identifier: CC0-1.0

View file

@ -40,8 +40,11 @@ describe('File upload', () => {
) )
}) })
it('via button', () => { it('via button', () => {
cy.getById('editor-toolbar-upload-image-button').click() cy.getById('editor-toolbar-upload-image-button').should('be.visible')
cy.getById('editor-toolbar-upload-image-input').attachFile({ filePath: 'demo.png', mimeType: 'image/png' }) cy.getById('editor-toolbar-upload-image-input').attachFixture({
filePath: 'demo.png',
mimeType: 'image/png'
})
cy.get('.CodeMirror-activeline').contains(`![](${imageUrl})`) cy.get('.CodeMirror-activeline').contains(`![](${imageUrl})`)
}) })
@ -83,9 +86,10 @@ describe('File upload', () => {
statusCode: 400 statusCode: 400
} }
) )
cy.getById('editor-toolbar-upload-image-button').click() cy.getById('editor-toolbar-upload-image-button').should('be.visible')
cy.fixture('demo.png').then(() => { cy.getById('editor-toolbar-upload-image-input').attachFixture({
cy.getById('editor-toolbar-upload-image-input').attachFile({ filePath: 'demo.png', mimeType: 'image/png' }) filePath: 'demo.png',
mimeType: 'image/png'
}) })
cy.get('.CodeMirror-activeline').contains('![upload of demo.png failed]()') cy.get('.CodeMirror-activeline').contains('![upload of demo.png failed]()')
}) })

View file

@ -136,8 +136,8 @@ describe('History', () => {
}) })
it('works with valid file', () => { it('works with valid file', () => {
cy.getById('import-history-file-button').click() cy.getById('import-history-file-button').should('be.visible')
cy.getById('import-history-file-input').attachFile({ cy.getById('import-history-file-input').attachFixture({
filePath: 'history.json', filePath: 'history.json',
mimeType: 'application/json' mimeType: 'application/json'
}) })
@ -145,23 +145,23 @@ describe('History', () => {
}) })
it('fails on invalid file', () => { it('fails on invalid file', () => {
cy.getById('import-history-file-button').click() cy.getById('import-history-file-button').should('be.visible')
cy.getById('import-history-file-input').attachFile({ cy.getById('import-history-file-input').attachFixture({
filePath: 'history.json.license', filePath: 'invalid-history.txt',
mimeType: 'text/plain' mimeType: 'text/plain'
}) })
cy.getById('notification-toast').should('be.visible') cy.getById('notification-toast').should('be.visible')
}) })
it('works when selecting two files with the same name', () => { it('works when selecting two files with the same name', () => {
cy.getById('import-history-file-button').click() cy.getById('import-history-file-button').should('be.visible')
cy.getById('import-history-file-input').attachFile({ cy.getById('import-history-file-input').attachFixture({
filePath: 'history.json', filePath: 'history.json',
mimeType: 'application/json' mimeType: 'application/json'
}) })
cy.getById('history-entry-title').should('have.length', 1).contains('cy-Test') cy.getById('history-entry-title').should('have.length', 1).contains('cy-Test')
cy.getById('import-history-file-button').click() cy.getById('import-history-file-button').should('be.visible')
cy.getById('import-history-file-input').attachFile({ cy.getById('import-history-file-input').attachFixture({
filePath: 'history-2.json', filePath: 'history-2.json',
fileName: 'history.json', fileName: 'history.json',
mimeType: 'application/json' mimeType: 'application/json'

View file

@ -11,8 +11,8 @@ describe('Import markdown file', () => {
it('import on blank note', () => { it('import on blank note', () => {
cy.getById('menu-import').click() cy.getById('menu-import').click()
cy.getById('menu-import-markdown').click() cy.getById('menu-import-markdown-button').should('be.visible')
cy.getById('menu-import-markdown-input').attachFile({ cy.getById('menu-import-markdown-input').attachFixture({
filePath: 'import.md', filePath: 'import.md',
mimeType: 'text/markdown' mimeType: 'text/markdown'
}) })
@ -26,8 +26,8 @@ describe('Import markdown file', () => {
it('import on note with content', () => { it('import on note with content', () => {
cy.setCodemirrorContent('test\nabc') cy.setCodemirrorContent('test\nabc')
cy.getById('menu-import').click() cy.getById('menu-import').click()
cy.getById('menu-import-markdown').click() cy.getById('menu-import-markdown-button').should('be.visible')
cy.getById('menu-import-markdown-input').attachFile({ cy.getById('menu-import-markdown-input').attachFixture({
filePath: 'import.md', filePath: 'import.md',
mimeType: 'text/markdown' mimeType: 'text/markdown'
}) })

View file

@ -119,9 +119,9 @@
"codemirror": "5.64.0", "codemirror": "5.64.0",
"copy-webpack-plugin": "6.4.1", "copy-webpack-plugin": "6.4.1",
"cross-env": "7.0.3", "cross-env": "7.0.3",
"cypress": "7.7.0", "cypress": "9.1.1",
"cypress-commands": "1.1.0", "cypress-commands": "2.0.1",
"cypress-file-upload": "5.0.8", "cypress-file-upload": "6.0.0-beta.0",
"d3-graphviz": "3.2.0", "d3-graphviz": "3.2.0",
"diff": "5.0.0", "diff": "5.0.0",
"dompurify": "2.3.4", "dompurify": "2.3.4",
@ -199,8 +199,5 @@
"vega-lite": "5.2.0", "vega-lite": "5.2.0",
"webpack-bundle-analyzer": "4.5.0", "webpack-bundle-analyzer": "4.5.0",
"words-count": "2.0.2" "words-count": "2.0.2"
},
"resolutions": {
"cypress": "7.7.0"
} }
} }

View file

@ -43,7 +43,7 @@ export const ImportMarkdownSidebarEntry: React.FC = () => {
return ( return (
<Fragment> <Fragment>
<SidebarButton {...cypressId('menu-import-markdown')} icon={'file-text-o'} onClick={buttonClick}> <SidebarButton {...cypressId('menu-import-markdown-button')} icon={'file-text-o'} onClick={buttonClick}>
<Trans i18nKey={'editor.import.file'} /> <Trans i18nKey={'editor.import.file'} />
</SidebarButton> </SidebarButton>
<UploadInput <UploadInput

View file

@ -21,11 +21,12 @@ export interface UploadInputProps extends PropsWithDataCypressId {
export const UploadInput: React.FC<UploadInputProps> = ({ onLoad, acceptedFiles, onClickRef, ...props }) => { export const UploadInput: React.FC<UploadInputProps> = ({ onLoad, acceptedFiles, onClickRef, ...props }) => {
const fileInputReference = useRef<HTMLInputElement>(null) const fileInputReference = useRef<HTMLInputElement>(null)
const onClick = useCallback(() => { const onClick = useCallback(() => {
const fileInput = fileInputReference.current fileInputReference.current?.click()
if (!fileInput) { }, [])
return
} const onChange = useCallback<React.ChangeEventHandler<HTMLInputElement>>(
fileInput.addEventListener('change', () => { (event) => {
const fileInput = event.currentTarget
if (!fileInput.files || fileInput.files.length < 1) { if (!fileInput.files || fileInput.files.length < 1) {
return return
} }
@ -37,13 +38,22 @@ export const UploadInput: React.FC<UploadInputProps> = ({ onLoad, acceptedFiles,
.catch((error: Error) => { .catch((error: Error) => {
log.error('Error while uploading file', error) log.error('Error while uploading file', error)
}) })
}) },
fileInput.click() [onLoad]
}, [onLoad]) )
useEffect(() => { useEffect(() => {
onClickRef.current = onClick onClickRef.current = onClick
}) })
return <input {...cypressId(props)} type='file' ref={fileInputReference} className='d-none' accept={acceptedFiles} /> return (
<input
{...cypressId(props)}
onChange={onChange}
type='file'
ref={fileInputReference}
className='d-none'
accept={acceptedFiles}
/>
)
} }

View file

@ -1263,7 +1263,7 @@
resolved "https://registry.yarnpkg.com/@csstools/normalize.css/-/normalize.css-10.1.0.tgz#f0950bba18819512d42f7197e56c518aa491cf18" resolved "https://registry.yarnpkg.com/@csstools/normalize.css/-/normalize.css-10.1.0.tgz#f0950bba18819512d42f7197e56c518aa491cf18"
integrity sha512-ij4wRiunFfaJxjB0BdrYHIH8FxBJpOwNPhhAcunlmPdXudL1WQV1qoP9un6JsEBAgQH+7UXyyjh0g7jTxXK6tg== integrity sha512-ij4wRiunFfaJxjB0BdrYHIH8FxBJpOwNPhhAcunlmPdXudL1WQV1qoP9un6JsEBAgQH+7UXyyjh0g7jTxXK6tg==
"@cypress/request@^2.88.5": "@cypress/request@^2.88.10":
version "2.88.10" version "2.88.10"
resolved "https://registry.yarnpkg.com/@cypress/request/-/request-2.88.10.tgz#b66d76b07f860d3a4b8d7a0604d020c662752cce" resolved "https://registry.yarnpkg.com/@cypress/request/-/request-2.88.10.tgz#b66d76b07f860d3a4b8d7a0604d020c662752cce"
integrity sha512-Zp7F+R93N0yZyG34GutyTNr+okam7s/Fzc1+i3kcqOP8vk6OuajuE9qZJ6Rs+10/1JFtXFYMdyarnU1rZuJesg== integrity sha512-Zp7F+R93N0yZyG34GutyTNr+okam7s/Fzc1+i3kcqOP8vk6OuajuE9qZJ6Rs+10/1JFtXFYMdyarnU1rZuJesg==
@ -3779,7 +3779,7 @@ blob-util@^2.0.2:
resolved "https://registry.yarnpkg.com/blob-util/-/blob-util-2.0.2.tgz#3b4e3c281111bb7f11128518006cdc60b403a1eb" resolved "https://registry.yarnpkg.com/blob-util/-/blob-util-2.0.2.tgz#3b4e3c281111bb7f11128518006cdc60b403a1eb"
integrity sha512-T7JQa+zsXXEa6/8ZhHcQEW1UFfVM49Ts65uBkFL6fz2QmrElqmbajIDJvuA0tEhRe5eIjpV9ZF+0RfZR9voJFQ== integrity sha512-T7JQa+zsXXEa6/8ZhHcQEW1UFfVM49Ts65uBkFL6fz2QmrElqmbajIDJvuA0tEhRe5eIjpV9ZF+0RfZR9voJFQ==
bluebird@^3.5.5, bluebird@^3.7.1, bluebird@^3.7.2: bluebird@3.7.2, bluebird@^3.5.5, bluebird@^3.7.1:
version "3.7.2" version "3.7.2"
resolved "https://registry.yarnpkg.com/bluebird/-/bluebird-3.7.2.tgz#9f229c15be272454ffa973ace0dbee79a1b0c36f" resolved "https://registry.yarnpkg.com/bluebird/-/bluebird-3.7.2.tgz#9f229c15be272454ffa973ace0dbee79a1b0c36f"
integrity sha512-XpNj6GDQzdfW+r2Wnn7xiSAd7TM3jzkxGXBGTtWKuSXv1xUV+azxAm8jdWZN06QTQk+2N2XB9jRDkvbmQmcRtg== integrity sha512-XpNj6GDQzdfW+r2Wnn7xiSAd7TM3jzkxGXBGTtWKuSXv1xUV+azxAm8jdWZN06QTQk+2N2XB9jRDkvbmQmcRtg==
@ -5064,29 +5064,31 @@ cyclist@^1.0.1:
resolved "https://registry.yarnpkg.com/cyclist/-/cyclist-1.0.1.tgz#596e9698fd0c80e12038c2b82d6eb1b35b6224d9" resolved "https://registry.yarnpkg.com/cyclist/-/cyclist-1.0.1.tgz#596e9698fd0c80e12038c2b82d6eb1b35b6224d9"
integrity sha1-WW6WmP0MgOEgOMK4LW6xs1tiJNk= integrity sha1-WW6WmP0MgOEgOMK4LW6xs1tiJNk=
cypress-commands@1.1.0: cypress-commands@2.0.1:
version "1.1.0" version "2.0.1"
resolved "https://registry.yarnpkg.com/cypress-commands/-/cypress-commands-1.1.0.tgz#9248190168783deb8ab27ae7c722e3e01d172c97" resolved "https://registry.yarnpkg.com/cypress-commands/-/cypress-commands-2.0.1.tgz#35651fa4d932b0244724273dbcfaf8d9ecdf4fd7"
integrity sha512-Q8Jr25pHJQFXwln6Hp8O+Hgs8Z506Y2wA9F1Te2cTajjc5L9gtt9WPOcw1Ogh+OgyqaMHF+uq31vdfImRTio5Q== integrity sha512-I+bLR2sXk/+m8GufQLDBf+jOGhpWMiDTMAogTWZglpzQw9px6cqz8GmD+FfWivDy3enK8aIIK6Xt8/jhbll9bA==
cypress-file-upload@5.0.8:
version "5.0.8"
resolved "https://registry.yarnpkg.com/cypress-file-upload/-/cypress-file-upload-5.0.8.tgz#d8824cbeaab798e44be8009769f9a6c9daa1b4a1"
integrity sha512-+8VzNabRk3zG6x8f8BWArF/xA/W0VK4IZNx3MV0jFWrJS/qKn8eHfa5nU73P9fOQAgwHFJx7zjg4lwOnljMO8g==
cypress@7.7.0:
version "7.7.0"
resolved "https://registry.yarnpkg.com/cypress/-/cypress-7.7.0.tgz#0839ae28e5520536f9667d6c9ae81496b3836e64"
integrity sha512-uYBYXNoI5ym0UxROwhQXWTi8JbUEjpC6l/bzoGZNxoKGsLrC1SDPgIDJMgLX/MeEdPL0UInXLDUWN/rSyZUCjQ==
dependencies: dependencies:
"@cypress/request" "^2.88.5" path-browserify "^1.0.1"
cypress-file-upload@6.0.0-beta.0:
version "6.0.0-beta.0"
resolved "https://registry.yarnpkg.com/cypress-file-upload/-/cypress-file-upload-6.0.0-beta.0.tgz#77cb3a89cf719dd9124869fc5c76c094e1c84c27"
integrity sha512-6CDL3TKpLoPl0zme9twxQqfyI/SkzOjryy/Q49ijF4MD6ZXfoos1JZJY0wtWNqNJI9sy1YxH7OrlWVD0AlAigQ==
cypress@9.1.1:
version "9.1.1"
resolved "https://registry.yarnpkg.com/cypress/-/cypress-9.1.1.tgz#26720ca5a22077cd85f49745616b7a08152a298f"
integrity sha512-yWcYD8SEQ8F3okFbRPqSDj5V0xhrZBT5QRIH+P1J2vYvtEmZ4KGciHE7LCcZZLILOrs7pg4WNCqkj/XRvReQlQ==
dependencies:
"@cypress/request" "^2.88.10"
"@cypress/xvfb" "^1.2.4" "@cypress/xvfb" "^1.2.4"
"@types/node" "^14.14.31" "@types/node" "^14.14.31"
"@types/sinonjs__fake-timers" "^6.0.2" "@types/sinonjs__fake-timers" "^6.0.2"
"@types/sizzle" "^2.3.2" "@types/sizzle" "^2.3.2"
arch "^2.2.0" arch "^2.2.0"
blob-util "^2.0.2" blob-util "^2.0.2"
bluebird "^3.7.2" bluebird "3.7.2"
cachedir "^2.3.0" cachedir "^2.3.0"
chalk "^4.1.0" chalk "^4.1.0"
check-more-types "^2.24.0" check-more-types "^2.24.0"
@ -5113,7 +5115,7 @@ cypress@7.7.0:
minimist "^1.2.5" minimist "^1.2.5"
ospath "^1.2.2" ospath "^1.2.2"
pretty-bytes "^5.6.0" pretty-bytes "^5.6.0"
ramda "~0.27.1" proxy-from-env "1.0.0"
request-progress "^3.0.0" request-progress "^3.0.0"
supports-color "^8.1.1" supports-color "^8.1.1"
tmp "~0.2.1" tmp "~0.2.1"
@ -10749,6 +10751,11 @@ path-browserify@0.0.1:
resolved "https://registry.yarnpkg.com/path-browserify/-/path-browserify-0.0.1.tgz#e6c4ddd7ed3aa27c68a20cc4e50e1a4ee83bbc4a" resolved "https://registry.yarnpkg.com/path-browserify/-/path-browserify-0.0.1.tgz#e6c4ddd7ed3aa27c68a20cc4e50e1a4ee83bbc4a"
integrity sha512-BapA40NHICOS+USX9SN4tyhq+A2RrN/Ws5F0Z5aMHDp98Fl86lX8Oti8B7uN93L4Ifv4fHOEA+pQw87gmMO/lQ== integrity sha512-BapA40NHICOS+USX9SN4tyhq+A2RrN/Ws5F0Z5aMHDp98Fl86lX8Oti8B7uN93L4Ifv4fHOEA+pQw87gmMO/lQ==
path-browserify@^1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/path-browserify/-/path-browserify-1.0.1.tgz#d98454a9c3753d5790860f16f68867b9e46be1fd"
integrity sha512-b7uo2UCUOYZcnF/3ID0lulOJi/bafxa1xPe7ZPsammBSpjSWQkjNxlt635YGS2MiR9GjvuXCtz2emr3jbsz98g==
path-dirname@^1.0.0: path-dirname@^1.0.0:
version "1.0.2" version "1.0.2"
resolved "https://registry.yarnpkg.com/path-dirname/-/path-dirname-1.0.2.tgz#cc33d24d525e099a5388c0336c6e32b9160609e0" resolved "https://registry.yarnpkg.com/path-dirname/-/path-dirname-1.0.2.tgz#cc33d24d525e099a5388c0336c6e32b9160609e0"
@ -11717,6 +11724,11 @@ proxy-addr@~2.0.5:
forwarded "0.2.0" forwarded "0.2.0"
ipaddr.js "1.9.1" ipaddr.js "1.9.1"
proxy-from-env@1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/proxy-from-env/-/proxy-from-env-1.0.0.tgz#33c50398f70ea7eb96d21f7b817630a55791c7ee"
integrity sha1-M8UDmPcOp+uW0h97gXYwpVeRx+4=
prr@~1.0.1: prr@~1.0.1:
version "1.0.1" version "1.0.1"
resolved "https://registry.yarnpkg.com/prr/-/prr-1.0.1.tgz#d3fc114ba06995a45ec6893f484ceb1d78f5f476" resolved "https://registry.yarnpkg.com/prr/-/prr-1.0.1.tgz#d3fc114ba06995a45ec6893f484ceb1d78f5f476"
@ -11846,11 +11858,6 @@ raf@^3.4.1:
dependencies: dependencies:
performance-now "^2.1.0" performance-now "^2.1.0"
ramda@~0.27.1:
version "0.27.1"
resolved "https://registry.yarnpkg.com/ramda/-/ramda-0.27.1.tgz#66fc2df3ef873874ffc2da6aa8984658abacf5c9"
integrity sha512-PgIdVpn5y5Yns8vqb8FzBUEYn98V3xcPgawAkkgj0YJ0qDsnHCiNmZYfOGMgOvoB0eWFLpYbhxUR3mxfDIMvpw==
randombytes@^2.0.0, randombytes@^2.0.1, randombytes@^2.0.5, randombytes@^2.1.0: randombytes@^2.0.0, randombytes@^2.0.1, randombytes@^2.0.5, randombytes@^2.1.0:
version "2.1.0" version "2.1.0"
resolved "https://registry.yarnpkg.com/randombytes/-/randombytes-2.1.0.tgz#df6f84372f0270dc65cdf6291349ab7a473d4f2a" resolved "https://registry.yarnpkg.com/randombytes/-/randombytes-2.1.0.tgz#df6f84372f0270dc65cdf6291349ab7a473d4f2a"