mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-05-17 08:34:54 -04:00
Fix file input field accepting a filename only once (#1547)
This commit is contained in:
parent
9118c8310b
commit
3591c90f9f
11 changed files with 130 additions and 37 deletions
|
@ -5,7 +5,6 @@
|
|||
*/
|
||||
|
||||
describe('History', () => {
|
||||
|
||||
describe('History Mode', () => {
|
||||
beforeEach(() => {
|
||||
cy.visit('/history')
|
||||
|
@ -125,4 +124,55 @@ describe('History', () => {
|
|||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe('Import', () => {
|
||||
beforeEach(() => {
|
||||
cy.clearLocalStorage('history')
|
||||
cy.intercept('GET', '/mock-backend/api/private/me/history', {
|
||||
body: []
|
||||
})
|
||||
cy.visit('/history')
|
||||
cy.logout()
|
||||
})
|
||||
|
||||
it('works with valid file', () => {
|
||||
cy.get('[data-cypress-id="import-history-file-button"]').click()
|
||||
cy.get('[data-cypress-id="import-history-file-input"]').attachFile({
|
||||
filePath: 'history.json',
|
||||
mimeType: 'application/json'
|
||||
})
|
||||
cy.get('[data-cypress-id="history-entry-title"]')
|
||||
.should('have.length', 1)
|
||||
.contains('cy-Test')
|
||||
})
|
||||
|
||||
it('fails on invalid file', () => {
|
||||
cy.get('[data-cypress-id="import-history-file-button"]').click()
|
||||
cy.get('[data-cypress-id="import-history-file-input"]').attachFile({
|
||||
filePath: 'history.json.license',
|
||||
mimeType: 'text/plain'
|
||||
})
|
||||
cy.get('[data-cypress-id="notification-toast"]').should('be.visible')
|
||||
})
|
||||
|
||||
it('works when selecting two files with the same name', () => {
|
||||
cy.get('[data-cypress-id="import-history-file-button"]').click()
|
||||
cy.get('[data-cypress-id="import-history-file-input"]').attachFile({
|
||||
filePath: 'history.json',
|
||||
mimeType: 'application/json'
|
||||
})
|
||||
cy.get('[data-cypress-id="history-entry-title"]')
|
||||
.should('have.length', 1)
|
||||
.contains('cy-Test')
|
||||
cy.get('[data-cypress-id="import-history-file-button"]').click()
|
||||
cy.get('[data-cypress-id="import-history-file-input"]').attachFile({
|
||||
filePath: 'history-2.json',
|
||||
fileName: 'history.json',
|
||||
mimeType: 'application/json'
|
||||
})
|
||||
cy.get('[data-cypress-id="history-entry-title"]')
|
||||
.should('have.length', 2)
|
||||
.contains('cy-Test2')
|
||||
})
|
||||
})
|
||||
})
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue