Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Jonas #337

Open
wants to merge 14 commits into
base: master
Choose a base branch
from
16 changes: 15 additions & 1 deletion test/cucumber/Book.feature
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,18 @@ Feature: Book
And the system has no book entitled "Next Generation Software Product Line Engineering"
When I go to new book page
And I use the webpage to create the book "Next Generation Software Product Line Engineering" with file name "Ngs.pdf"
Then the book "Next Generation Software Product Line Engineering" was stored by the system
Then the book "Next Generation Software Product Line Engineering" was stored by the system

Scenario: list existing book web
Given I am at the book page
And the system has the book entitled "Next Generation Software Product Line Engineering" with file name "Ngs.pdf"
Then the book list contains "Next Generation Software Product Line Engineering"

Scenario: remove existing book web
Given I am at the book page
And the system has the book entitled "Next Generation Software Product Line Engineering" with file name "Ngs.pdf"
When I choose to view "Next Generation Software Product Line Engineering" in book list
And I press to remove at the book show page
Then the book "Next Generation Software Product Line Engineering" is removed from the system


25 changes: 9 additions & 16 deletions test/cucumber/Dissertacao.feature
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Feature: Dissertation Tests

Scenario: new dissertation duplicated
Given the dissertation "Dissertation duplicated" is stored in the system with file name "Dissertationduplicated.txt"
When I create the dissertation "Dissertation duplicated" with file name "Dissertationduplicated2.txt" and school "UFPE"
When I create the dissertation "Dissertation duplicated" with file name "Dissertationduplicated2.txt"
Then the dissertation "Dissertation duplicated" is not stored twice

Scenario: new dissertation without file
Expand All @@ -39,11 +39,6 @@ Feature: Dissertation Tests
And I cant add the dissertation without a file
Then the system has no dissertation entitled "Dissertacao sem arquivo"

Scenario: upload a dissertation and system has no dissertation stored
Given the system has no dissertation entitled "New dissertation"
When I upload a new dissertation "curriculo4.xml" with title "New dissertation"
Then the system has more dissertations now

Scenario: new dissertation with file
Given I am at the publications menu
When I select the "Dissertacao" option at the program menu
Expand All @@ -58,18 +53,16 @@ Feature: Dissertation Tests
Then the dissertation "Edit dissertation" is properly updated by the system

Scenario: delete dissertation
Given the dissertation "Delete dissertation" is stored in the system with file name "Deletedissertation.txt"
Given I am at the publications menu
When I select the "Dissertacao" option at the program menu
And I select "Delete dissertation" at the dissertation page
And I delete "Delete dissertation"
Then the system has no dissertation entitled "Delete dissertation"
Given I am at the dissertation page
And the dissertation named "Dissertation One" is stored in the system
When I select "Dissertation One" at the dissertation list
And I press to remove "Delete dissertation" at the dissertation show page
Then the system has no dissertation entitled "Dissertation One"

Scenario: upload dissertation without a file
Given I am at the publications menu
When I select the "Dissertacao" option at the program menu
And I select the upload button at the dissertation page
Then I'm still on dissertation page
Given I am at the dissertation page
And I select the upload button with no file selected
Then I stay on dissertation page with an error message

Scenario: upload dissertation with a file
Given the system has some dissertation stored
Expand Down
52 changes: 42 additions & 10 deletions test/cucumber/steps/BookSteps.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
*/

import pages.BookCreatePage
import pages.BookShowPage
import pages.BookPage
import pages.LoginPage
import pages.PublicationsPage
Expand All @@ -16,7 +17,7 @@ import steps.BookTestDataAndOperations
import static cucumber.api.groovy.EN.*

Given(~'^the system has no book entitled "([^"]*)"$') { String title ->
checkIfExists(title)
assert !checkIfExists(title)
}

When(~'^I create the book "([^"]*)" with file name "([^"]*)"$') { String title, filename ->
Expand All @@ -39,7 +40,7 @@ When(~'^I remove the book "([^"]*)"$') { String title ->
}

Then(~'^the book "([^"]*)" is properly removed by the system$') { String title ->
checkIfExists(title)
assert !checkIfExists(title)
}

Then(~'^the book "([^"]*)" is not stored twice$') { String title ->
Expand Down Expand Up @@ -88,29 +89,60 @@ When(~'^I go to new book page$') { ->
to BookPage
page.selectNewBook()
}

And(~'^I use the webpage to create the book "([^"]*)" with file name "([^"]*)"$') { String title, filename ->
at BookCreatePage
createAndCheckBookOnBrowser(title, filename)
to BookPage
at BookPage
}

Then(~'^the book "([^"]*)" was stored by the system$') { String title ->
book = Book.findByTitle(title)
assert book != null
assert checkIfExists(title)
to BookPage
at BookPage
}


When(~'^I choose to view "([^"]*)" in book list$') { String title ->
page.selectViewBook(title)
at BookShowPage
}
And(~'^I press to remove at the book show page$') {->
at BookShowPage
page.select('input', 'delete')
}




Then(~'^the book list contains" ([^"]*)"$') { String title ->
at BookPage
page.checkArticleAtList(title, 0)
}


Given(~'^the system has the book entitled "([^"]*)" with file name "([^"]*)"$') { String title, String file ->
book = Book.findByTitleAndFile(title, file)
assert book != null
}

Then(~'^the book "([^"]*)" is removed from the system$') { String title ->

assert !checkIfExists(title)
}

Then(~'^the book list contains "([^"]*)"$') { String title ->
assert checkIfExists(title)
}

def checkIfExists(String title) {
book = Book.findByTitle(title)
assert book == null
book != null
}


def createAndCheckBookOnBrowser(String title, String filename) {
page.fillBookDetails(title, filename)
page.clickSaveBook()
book = Book.findByTitle(title)
assert book != null
}
assert checkIfExists(title)
}

47 changes: 39 additions & 8 deletions test/cucumber/steps/DissertacaoSteps.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ import rgms.authentication.User
import rgms.publication.Dissertacao
import steps.TestDataDissertacao
import steps.TestDataAndOperationsPublication

import pages.LoginPage
import pages.PublicationsPage
import static cucumber.api.groovy.EN.*


Expand Down Expand Up @@ -101,13 +102,6 @@ Then(~'^the dissertation "([^"]*)" is properly updated by the system$') { String
assert article == null
}

When(~'^I select the upload button at the dissertation page$') {->
at DissertationPage
page.uploadWithoutFile()
}
Then(~'^I\'m still on dissertation page$') {->
at DissertationPage
}

When(~'^I upload a new dissertation "([^"]*)"$') { filename ->
String path = new File(".").getCanonicalPath() + File.separator + "test" + File.separator + "functional" + File.separator + "steps" + File.separator + filename
Expand Down Expand Up @@ -157,3 +151,40 @@ Given(~'^the system has no dissertation stored$') {->
}


Given(~'^I am at the dissertation page$') { ->
to LoginPage
at LoginPage
page.fillLoginData("admin", "adminadmin")
at PublicationsPage
to DissertationPage
}
When(~'^I select the upload button with no file selected$') {->
page.uploadWithoutFile()
}
Then(~'^I stay on dissertation page with an error message$') { ->
at DissertationPage
assert page.readFlashMessage() != null
}


When(~'^I press to remove "([^"]*)" at the dissertation show page$'){ String title->
at DissertationShowPage
page.select('input', 'delete')
}

When(~'^I create the dissertation "([^"]*)" with file name "([^"]*)"$') { String title, String filename ->
TestDataDissertacao.createDissertacao(title, filename, "UFPE")
dissertation = Dissertacao.findByTitle(title)
assert dissertation != null
}

Given(~'^the dissertation named "([^"]*)" is stored in the system$') { String title ->
TestDataDissertacao.createDissertacao(title, "testDissertation.pdf", "UFPE")
dissertation = Dissertacao.findByTitle(title)
assert dissertation != null
}

When(~'^I select "([^"]*)" at the dissertation list$') { String title ->
page.selectDissertation(title)
}

8 changes: 8 additions & 0 deletions test/functional/pages/BookPage.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,14 @@ class BookPage extends Page {

}

def selectViewBook(title) {
def listDiv = $('div', id: 'list-book')
def bookTable = (listDiv.find('table'))[0]
def bookRow = bookTable.find('tbody').find('tr')
def showLink = bookRow.find('td').find([text: title])
showLink.click()
}

def selectNewBook() {
$('a.create').click()
}
Expand Down
31 changes: 31 additions & 0 deletions test/functional/pages/BookShowPage.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package pages

import geb.Page

/**
* Created by Casa on 20/01/2015.
*/
class BookShowPage extends Page {

static url = "book/show"

static at = {
GetPageTitle gp = new GetPageTitle()
def currentBook = gp.msg("default.book.label")
def currentTitle = gp.msg("default.show.label", [currentBook])

title ==~ currentTitle
}

static content = {
}

def select(String e, v) {
if (v == 'delete') {
assert withConfirm(true) { $("form").find(e, class: v).click() }
} else {
$("form").find(e, class: v).click()
}
}

}
15 changes: 14 additions & 1 deletion test/functional/pages/DissertationPage.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@ class DissertationPage extends Page {
static url = "dissertacao/list"

static at = {
title ==~ /Dissertacao Listagem/
GetPageTitle gp = new GetPageTitle()
def currentDissertation = gp.msg("default.periodico.label")
def currentTitle = gp.msg("default.list.label", [currentDissertation])

title ==~ currentTitle
}

static content = {
Expand All @@ -23,6 +27,14 @@ class DissertationPage extends Page {
$('input.save').click()
}

def selectViewDissertation(title) {
def listDiv = $('div', id: 'list-dissertacao')
def dissertationTable = (listDiv.find('table'))[0]
def dissertationRow = dissertationTable.find('tbody').find('tr')
def showLink = dissertationRow.find('td').find([text: title])
showLink.click()
}

def checkIfDissertationListIsEmpty(){
def listDiv = $('div', id: 'list-dissertacao')
def dissertationTable = (listDiv.find('table'))[0]
Expand All @@ -31,4 +43,5 @@ class DissertationPage extends Page {

assert dissertationColumns.size() < 6
}

}
16 changes: 14 additions & 2 deletions test/functional/pages/DissertationShowPage.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,13 @@ import geb.Page;

class DissertationShowPage extends Page{
static url = "dissertacao/show"

static at = {
title ==~ /Ver Dissertacao/
GetPageTitle gp = new GetPageTitle()
def currentDissertation = gp.msg("default.dissertacao.label")
def currentTitle = gp.msg("default.show.label", [currentDissertation])

title ==~ currentTitle
}

static content = {
Expand All @@ -26,4 +30,12 @@ class DissertationShowPage extends Page{
$('input.delete').click()
}
}

def select(String e, v) {
if (v == 'delete') {
assert withConfirm(true) { $("form").find(e, class: v).click() }
} else {
$("form").find(e, class: v).click()
}
}
}
2 changes: 1 addition & 1 deletion test/functional/steps/TestDataDissertacao.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class TestDataDissertacao
def testDissertation = Dissertacao.findByTitle(title)
def cont = new DissertacaoController()
def date = new Date()
cont.params << [id: testDissertation.id]
cont.params << [id: testDissertation?.id]
cont.delete()
}

Expand Down