Example #1
0
module.exports = (function() {
    var library = helper.getLibrary()
        .define('I wait (.*) seconds?', function(time) {
            time = parseFloat(time) * 1000
            var driver = this.driver
            var endTime = new Date().getTime() + time
            driver.wait(function() {
                return new Date().getTime() > endTime
            }, endTime + 5000, 'Error with wait helper')
        })
        .define('I wait for animations to finish', function() {
            time = 300
            var driver = this.driver
            var endTime = new Date().getTime() + time
            driver.wait(function() {
                return new Date().getTime() > endTime
            }, endTime + 5000, 'Error with wait helper')
        })
        .define('I wait for the panel to close', function() {
             var driver = this.driver
             driver.wait(function() {
                 return driver.element('.ui-panel-dismiss').isDisplayed(function(visible) {
                     return !visible
                 })
             }, 3000, 'Waiting for panel to close')
        })
    
    return library
    
})()
Example #2
0
module.exports = (function() {
    var library = massah.getLibrary()
        .then('I expect to see ([0-9]*) options', function(expected) {
            this.driver.elements('li').count(function(count) {
                count.should.equal(parseInt(expected))
            })
        })
        .then('one of the options matches that which I entered', function() {
            this.driver.content(this.params.newOption, 'li').then(
                null,
                function() { throw new Error('Missing expected item') }
            )
        })
    
    return library
})()
Example #3
0
module.exports = (function() {
    var library = helper.getLibrary()
        .then('an (.*) notification of \'(.*)\' should be seen', function(type, message) {
            var selector = 'div.bootstrap-growl.alert-' + type
            var driver = this.driver
            driver.wait(function() {
                return driver.element(selector).then(
                    function() {
                        return true
                    },
                    function() { return false }
                )
            }, 15000, 'Waiting for notification')
            this.driver.element(selector).text(function(text) {
                text.should.include(message)
            })
        })
    
    return library
})()
Example #4
0
module.exports = (function() {
    var library = helper.getLibrary()
        .when('I enter the password \'(.*)\'', function(password) {
            this.driver.input('div.board-password input').enter(password)
        })
        .then('I see the authentication elements', function(page) {
            var params = this.params
            this.driver.content('Board ID', 'label')
            this.driver.content('Password', 'label')
            this.driver.element('div.board-id div').text(function(text) {
                text.should.include(params.boardId)
            })
            this.driver.element('div.board-password div input[type="password"]')
            this.driver.content('Get me some access...', 'button')
            this.driver.element('button.leave').text(function(text) {
                text.should.equal('Cancel')
            })
        })
    
    return library
})()
Example #5
0
module.exports = (function() {
    var library = massahHelper.getLibrary()
        .when('I open the board title modal', function() {
            var driver = this.driver
            var selector = 'a[href="#set-board-name-modal"]'
            driver.element('a[title="Settings"]').click()
            driver.wait(function() {
                return driver.element(selector).isDisplayed(function(displayed) {
                    return displayed
                })
            }, 5000, 'Waiting for settings panel to open')
            driver.element('a[href="#set-board-name-modal"]').click()
        })
        .when('I change the board title to \'(.*)\'', function(title) {
            var driver = this.driver
            var params = this.params
            var selector = 'div#set-board-name-modal input[type=text]'
            driver.wait(function() {
                return driver.element(selector).isDisplayed(function(displayed) {
                    if (false === displayed) return false
                    driver.input(selector).enter(title)
                    params.boardTitle = title
                    return true
                })
            }, 5000, 'Waiting for board title form')
        })
        .then('the board title is (.*)updated', function(not) {
            var params = this.params
            this.driver.element('h4.board-name').html(function(title) {
                if (not) {
                    title.should.not.equal(params.boardTitle)
                } else {
                    title.should.equal(params.boardTitle)
                }
            })
        })
    
    return library
})()
Example #6
0
module.exports = (function() {
    var library = massahHelper.getLibrary()
        .then('the user has the access level (.*)', function(level) {
            var driver = this.driver

            driver.element('a[title="Settings"]').click()
            driver.wait(function() {
                return driver.element('a.change-access-level').isDisplayed(function(displayed) {
                    if (!displayed) return false
                    driver.element('a.change-access-level').html(function(label) {
                        label.should.equal(
                            'Change access <p class="ui-li-aside">' +
                                level + '</p>'
                        )
                    })
                    return true
                })
            }, 5000, 'Waiting for access level label')
        })
    
    return library
})()
Example #7
0
module.exports = (function() {
    var library = massahHelper.getLibrary()
        .given('I create a board with identifier \'(.*)\'', function(identifier) {
            var driver = this.driver
            driver.get(helper.baseUrl + '/#create')
            driver.input('*[name="owner"]').enter('*****@*****.**')
            driver.input('*[name="slug"]').enter(identifier)
            if (!this.params.fields) this.params.fields = {}
            this.params.fields.slug = identifier
            driver.button('Create board').click()
            checkIdentifier(this)
        })
        .then('I expect to see the create board page elements', function(page) {
            this.driver.element('input[type="text"][name="owner"]')
            this.driver.element('input[name="board-name"]')
            this.driver.element('input[type="password"][name="password-admin"]')
            this.driver.element('input[type="password"][name="password-write"]')
            this.driver.element('input[type="password"][name="password-read"]')
            this.driver.element('select[name="grid-size"]')
            this.driver.element('select[name="grid-position"]')
            this.driver.button('Cancel')
            this.driver.button('Create board').then(
                function() {},
                function(error) {
                    throw new Error('Missing home page elements', error)
                }
            )
        })
        .given('I create a board without an? (.*) password', function(level) {
            var self = this
            this.driver.get(helper.baseUrl + '/#create')
            this.driver.input('*[name="owner"]').enter('*****@*****.**')
            switch (level) {
                case 'read':
                    this.driver.input('*[name="password-admin"]').clear()
            this.driver.input('*[name="password-admin"]').enter('admin')
                    this.driver.input('*[name="password-read"]').clear()
                    break
                case 'write':
                    this.driver.input('*[name="password-admin"]').clear()
            this.driver.input('*[name="password-admin"]').enter('admin')
                    this.driver.input('*[name="password-read"]').clear()
                    this.driver.input('*[name="password-write"]').clear()
                case 'admin':
                    break
            }
            this.driver.button('Create board').click()
            this.driver.wait(function() {
                return self.driver.currentUrl(function(url, currentUrl) {
                    var matches = currentUrl.path.match(/\/([a-z0-9]{24}).*/)
                    if (matches) {
                        self.params.boardId = matches[1]
                        self.params.boardTitle = self.params.boardId
                        return true
                    }
                    return false
                })
            }, 5000, 'Waiting for a new board')
            this.driver.wait(function() {
                return self.driver.element('a[title="Settings"]').then(
                    function() { return true },
                    function() { return false }
                )
            }, 15000, 'Waiting for settings bar to load')
            this.driver.element('a[title="Settings"]').click()
            this.driver.wait(function() {
                return self.driver.element('a.leave').isDisplayed(function(visible) {
                    if (!visible) return false
                    self.driver.element('a.leave').click() 
                    return true
                })
            }, 5000, 'Waiting for logout link')
        })
        .given('I create a board with access passwords', function() {
            var self = this
            var driver = this.driver
            driver.get(helper.baseUrl + '/#create')
            driver.input('*[name="owner"]').enter('*****@*****.**')
            driver.input('*[name="password-admin"]').enter('admin')
            driver.input('*[name="password-write"]').clear()
            driver.input('*[name="password-write"]').enter('write')
            driver.input('*[name="password-read"]').clear()
            driver.input('*[name="password-read"]').enter('read')
            driver.button('Create board').click()
            driver.wait(function() {
                return driver.currentUrl(function(url, currentUrl) {
                    var matches = currentUrl.path.match(/\/([a-z0-9]{24}).*/)
                    if (matches) {
                        self.params.boardId = matches[1]
                        self.params.boardTitle = self.params.boardId
                        return true
                    }
                    return false
                })
            }, 5000, 'Waiting for a new board')
            
            driver.element('a[title="Settings"]').click()
            driver.wait(function() {
                return driver.element('a.leave').isDisplayed(function(visible) {
                    if (!visible) return false
                    driver.element('a.leave').click()
                    return true
                })
            }, 5000, 'Waiting for settings panel to open')
        })
        .given('a created board', function() {
            var self = this
            this.driver.get(helper.baseUrl + '/#create')
            this.driver.exec('localStorage.clear()')
            this.driver.input('*[name="owner"]').enter('*****@*****.**')
            this.driver.button('Create board').click()
            self.driver.wait(function() {
                return self.driver.currentUrl(function(url, currentUrl) {
                    var matches = currentUrl.path.match(/\/([a-z0-9]{24}).*/)
                    if (matches) {
                        self.params.boardId = matches[1]
                        self.params.boardTitle = self.params.boardId
                        return true
                    }
                    return false
                })
            }, 5000, 'Waiting for a new board')
            time = 2000
            var endTime = new Date().getTime() + time
            this.driver.wait(function() {
                return new Date().getTime() > endTime
            }, endTime + 5000, 'Error with wait helper')
        })
        .then('the board has the expected title', function() {
            var expected = (this.params.fields && this.params.fields['board-name']) ||
                this.params.boardTitle
            var selector = 'div[data-role="header"] h4.board-name'
            this.driver.element(selector).text(function(title) {
                title.should.equal(expected)
            })
        })
        .then('I am redirected to the identified board', function() {
            checkIdentifier(this)
        })
    
    return library
})()
Example #8
0
module.exports = (function() {
    var library = massahHelper.getLibrary()
        .given('I navigate to the (.*) page', function(page) {
            switch (page) {
                case 'home':
                    this.driver.get(helper.baseUrl + '/')
                    break
                case 'create board':
                    this.driver.get(helper.baseUrl + '/#create')
                    break
                default:
                    throw new Error('Unknown page \'' + page + '\'')
            }
        })
        .when('I click the \'(.*)\' button', function(label) {
            var driver = this.driver
            driver.wait(function() {
                return driver.button(label).isDisplayed(function(visible) {
                    if (!visible) return false
                    driver.button(label).click()
                    return true
                })
            }, 3000, 'Waiting for button to appear')
        })
        .when('I click the \'(.*)\' link', function(linkText) {
            this.driver.link(linkText).click()
        })
        .when('I click element \'(.*)\'', function(selector) {
            this.driver.element(selector).click()  
        })
        .when('I visit the board', function() {
            this.driver.get(helper.baseUrl + '/' + this.params.boardId)  
        })
        .then('I am sent to the (.*) page', function(page) {
            switch (page) {
                case 'create board':
                    this.driver.currentUrl(function(url, currentUrl) {
                        currentUrl.hash.should.equal('#create')
                    })
                    break
                default:
                    throw new Error('Unknown page \'' + page + '\'')
            }
        })
        .then('I am redirected to the authentication screen', function() {
            var driver = this.driver
            driver.wait(function() {
                return driver.currentUrl(function(url, currentUrl) {
                    return currentUrl.path.match(/\/?id=[a-z0-9]{24}.*/)
                })
            }, 5000, 'Waiting for the authentication screen')
        })
        .then('I am redirected to a new board', function() {
            var driver = this.driver
            driver.wait(function() {
                return driver.currentUrl(function(url, currentUrl) {
                    return currentUrl.path.match(/\/[a-z0-9]{24}.*/)
                })
            }, 5000, 'Waiting for a new board')
        })
        .then('I am redirected to the board', function() {
            var driver = this.driver
            driver.wait(function() {
                return driver.currentUrl(function(url, currentUrl) {
                    return currentUrl.path.match(/\/[a-z0-9]{24}.*/)
                })
            }, 5000, 'Waiting for board access')
        })
    
    return library
})()