mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-05-15 07:34:42 -04:00
Cypress-IDs and prettier for tests (#1634)
* Add cy.getById method and run prettier Signed-off-by: Erik Michelson <github@erik.michelson.eu>
This commit is contained in:
parent
8a8bacc0aa
commit
d725b65140
53 changed files with 758 additions and 1203 deletions
|
@ -11,12 +11,12 @@ describe('History', () => {
|
|||
})
|
||||
|
||||
it('Cards', () => {
|
||||
cy.get('div.card').should('be.visible')
|
||||
cy.getById('history-card').should('be.visible')
|
||||
})
|
||||
|
||||
it('Table', () => {
|
||||
cy.get('[data-cypress-id="history-mode-table"]').click()
|
||||
cy.get('[data-cypress-id="history-table"]').should('be.visible')
|
||||
cy.getById('history-mode-table').click()
|
||||
cy.getById('history-table').should('be.visible')
|
||||
})
|
||||
})
|
||||
|
||||
|
@ -39,13 +39,13 @@ describe('History', () => {
|
|||
})
|
||||
|
||||
it('in table view', () => {
|
||||
cy.get('[data-cypress-id="history-mode-table"]').click()
|
||||
cy.get('[data-cypress-id="history-table"]').should('be.visible')
|
||||
cy.get('[data-cypress-id="history-entry-title"]').contains('Features')
|
||||
cy.getById('history-mode-table').click()
|
||||
cy.getById('history-table').should('be.visible')
|
||||
cy.getById('history-entry-title').contains('Features')
|
||||
})
|
||||
|
||||
it('in cards view', () => {
|
||||
cy.get('[data-cypress-id="history-entry-title"]').contains('Features')
|
||||
cy.getById('history-entry-title').contains('Features')
|
||||
})
|
||||
})
|
||||
describe('is untitled when not empty', () => {
|
||||
|
@ -66,13 +66,13 @@ describe('History', () => {
|
|||
})
|
||||
|
||||
it('in table view', () => {
|
||||
cy.get('[data-cypress-id="history-mode-table"]').click()
|
||||
cy.get('[data-cypress-id="history-table"]').should('be.visible')
|
||||
cy.get('[data-cypress-id="history-entry-title"]').contains('Untitled')
|
||||
cy.getById('history-mode-table').click()
|
||||
cy.getById('history-table').should('be.visible')
|
||||
cy.getById('history-entry-title').contains('Untitled')
|
||||
})
|
||||
|
||||
it('in cards view', () => {
|
||||
cy.get('[data-cypress-id="history-entry-title"]').contains('Untitled')
|
||||
cy.getById('history-entry-title').contains('Untitled')
|
||||
})
|
||||
})
|
||||
})
|
||||
|
@ -90,15 +90,15 @@ describe('History', () => {
|
|||
})
|
||||
|
||||
it('Cards', () => {
|
||||
cy.get('div.card').should('be.visible')
|
||||
cy.get('.history-pin.btn').first().as('pin-button')
|
||||
cy.getById('history-card').should('be.visible')
|
||||
cy.getById('history-entry-pin-button').first().as('pin-button')
|
||||
cy.get('@pin-button').should('have.class', 'pinned').click()
|
||||
cy.get('@pin-button').should('not.have.class', 'pinned')
|
||||
})
|
||||
|
||||
it('Table', () => {
|
||||
cy.get('i.fa-table').click()
|
||||
cy.get('.history-pin.btn').first().as('pin-button')
|
||||
cy.getById('history-mode-table').click()
|
||||
cy.getById('history-entry-pin-button').first().as('pin-button')
|
||||
cy.get('@pin-button').should('have.class', 'pinned').click()
|
||||
cy.get('@pin-button').should('not.have.class', 'pinned')
|
||||
})
|
||||
|
@ -112,15 +112,15 @@ describe('History', () => {
|
|||
})
|
||||
|
||||
it('Cards', () => {
|
||||
cy.get('div.card').should('be.visible')
|
||||
cy.get('.fa-thumb-tack').first().click()
|
||||
cy.get('.notifications-area .toast').should('be.visible')
|
||||
cy.getById('history-card').should('be.visible')
|
||||
cy.getById('history-entry-pin-button').first().click()
|
||||
cy.getById('notification-toast').should('be.visible')
|
||||
})
|
||||
|
||||
it('Table', () => {
|
||||
cy.get('i.fa-table').click()
|
||||
cy.get('.fa-thumb-tack').first().click()
|
||||
cy.get('.notifications-area .toast').should('be.visible')
|
||||
cy.getById('history-mode-table').click()
|
||||
cy.getById('history-entry-pin-button').first().click()
|
||||
cy.getById('notification-toast').should('be.visible')
|
||||
})
|
||||
})
|
||||
})
|
||||
|
@ -136,43 +136,37 @@ describe('History', () => {
|
|||
})
|
||||
|
||||
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({
|
||||
cy.getById('import-history-file-button').click()
|
||||
cy.getById('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.getById('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({
|
||||
cy.getById('import-history-file-button').click()
|
||||
cy.getById('import-history-file-input').attachFile({
|
||||
filePath: 'history.json.license',
|
||||
mimeType: 'text/plain'
|
||||
})
|
||||
cy.get('[data-cypress-id="notification-toast"]').should('be.visible')
|
||||
cy.getById('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({
|
||||
cy.getById('import-history-file-button').click()
|
||||
cy.getById('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({
|
||||
cy.getById('history-entry-title').should('have.length', 1).contains('cy-Test')
|
||||
cy.getById('import-history-file-button').click()
|
||||
cy.getById('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')
|
||||
cy.getById('history-entry-title').should('have.length', 2).contains('cy-Test2')
|
||||
})
|
||||
})
|
||||
})
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue