tests: add cypress tests for deck dashboard, boards, lists, cards

Signed-off-by: Luka Trovic <luka@nextcloud.com>
This commit is contained in:
Luka Trovic
2022-04-14 10:30:50 +02:00
parent 23ae20efe7
commit e6c2d85197
5 changed files with 157 additions and 20 deletions

View File

@@ -0,0 +1,40 @@
import { randHash } from "../utils"
const randUser = randHash()
describe('Board', function () {
const password = 'pass123'
before(function () {
cy.nextcloudCreateUser(randUser, password)
})
beforeEach(function() {
cy.login(randUser, password)
})
it('Can create a board', function () {
let board = 'Test'
// Click "Add board"
cy.get('.app-navigation button.app-navigation-toggle').click()
cy.get('#app-navigation-vue .app-navigation__list .app-navigation-entry')
.eq(1)
.find('a')
.first()
.click({force: true})
// Type the board title
cy.get('.board-create form input[type=text]')
.type(board, {force: true})
// Submit
cy.get('.board-create form input[type=submit]')
.first()
.click({force: true})
cy.get('.app-navigation__list .app-navigation-entry__children .app-navigation-entry')
.first()
.contains(board)
.should('be.visible')
})
})

View File

@@ -0,0 +1,40 @@
import { randHash } from '../utils'
const randUser = randHash()
describe('Card', function () {
const board = 'TestBoard'
const list = 'TestList'
const password = 'pass123'
before(function () {
cy.nextcloudCreateUser(randUser, password)
cy.deckCreateBoard({ user: randUser, password }, board)
cy.deckCreateList({ user: randUser, password }, list)
})
beforeEach(function () {
cy.login(randUser, password)
})
it('Can add a card', function () {
let card = 'Card 1'
cy.get('.app-navigation button.app-navigation-toggle').click()
cy.get('#app-navigation-vue .app-navigation__list .app-navigation-entry')
.eq(1)
.find('.app-navigation-entry__children .app-navigation-entry a.app-navigation-entry-link')
.first()
.click({force: true})
cy.get('.board .stack').eq(0).within(() => {
cy.get('button.action-item.action-item--single.icon-add')
.first().click()
cy.get('.stack__card-add form input#new-stack-input-main')
.type(card)
cy.get('.stack__card-add form input[type=submit]')
.first().click()
cy.get('.card').first().contains(card).should('be.visible')
})
})
})

View File

@@ -2,13 +2,14 @@ import { randHash } from '../utils'
const randUser = randHash() const randUser = randHash()
describe('Deck dashboard', function() { describe('Deck dashboard', function() {
const password = 'pass123'
before(function () { before(function () {
// Create a user cy.nextcloudCreateUser(randUser, password)
cy.nextcloudCreateUser(randUser, 'pass123')
}) })
beforeEach(function() { beforeEach(function() {
cy.login(randUser, 'pass123') cy.login(randUser, password)
}) })
it('Can show the right title on the dashboard', function() { it('Can show the right title on the dashboard', function() {
@@ -26,20 +27,4 @@ describe('Deck dashboard', function() {
.first() .first()
.contains('Personal') .contains('Personal')
}) */ }) */
it('Can create a board', function () {
cy.get('#app-navigation-vue .app-navigation__list .app-navigation-entry')
.eq(1)
.find('a')
.first()
.click({force: true})
cy.get('.board-create form input[type=text]')
.type('Test', {force: true})
cy.get('.board-create form input[type=submit]')
.first()
.click({force: true})
})
}) })

View File

@@ -0,0 +1,35 @@
import { randHash } from '../utils'
const randUser = randHash()
describe('Stack', function () {
const board = 'TestBoard'
const password = 'pass123'
const stack = 'List 1'
before(function () {
cy.nextcloudCreateUser(randUser, password)
cy.deckCreateBoard({ user: randUser, password }, board)
})
beforeEach(function() {
cy.logout()
cy.login(randUser, password)
})
it('Can create a stack', function () {
cy.get('.app-navigation button.app-navigation-toggle').click()
cy.get('#app-navigation-vue .app-navigation__list .app-navigation-entry')
.eq(1)
.find('.app-navigation-entry__children .app-navigation-entry a.app-navigation-entry-link')
.first().click({force: true})
cy.get('#stack-add button').first().click()
cy.get('#stack-add form input#new-stack-input-main')
.type(stack)
cy.get('#stack-add form input[type=submit]')
.first().click()
cy.get('.board .stack').eq(0).contains(stack).should('be.visible')
})
})

View File

@@ -24,7 +24,8 @@
Cypress.env('baseUrl', url) Cypress.env('baseUrl', url)
Cypress.Commands.add('login', (user, password, route = '/apps/deck/') => { Cypress.Commands.add('login', (user, password, route = '/apps/deck/') => {
cy.session(user, function () { let session = `${user}-${Date.now()}`
cy.session(session, function () {
cy.visit(route) cy.visit(route)
cy.get('input[name=user]').type(user) cy.get('input[name=user]').type(user)
cy.get('input[name=password]').type(password) cy.get('input[name=password]').type(password)
@@ -76,3 +77,39 @@
}) })
}) })
Cypress.Commands.add('deckCreateBoard', ({ user, password }, title) => {
cy.login(user, password)
cy.get('.app-navigation button.app-navigation-toggle').click()
cy.get('#app-navigation-vue .app-navigation__list .app-navigation-entry')
.eq(1)
.find('a')
.first()
.click({force: true})
cy.get('.board-create form input[type=text]')
.type(title, {force: true})
cy.get('.board-create form input[type=submit]')
.first()
.click({force: true})
})
Cypress.Commands.add('deckCreateList', ({ user, password }, title) => {
cy.login(user, password)
cy.get('.app-navigation button.app-navigation-toggle').click()
cy.get('#app-navigation-vue .app-navigation__list .app-navigation-entry')
.eq(1)
.find('.app-navigation-entry__children .app-navigation-entry a.app-navigation-entry-link')
.first()
.click({force: true})
cy.get('#stack-add button').first().click()
cy.get('#stack-add form input#new-stack-input-main')
.type(title)
cy.get('#stack-add form input[type=submit]')
.first()
.click()
})