diff --git a/test/cucumber/Book.feature b/test/cucumber/Book.feature index 3624ed38..c03bfbb9 100644 --- a/test/cucumber/Book.feature +++ b/test/cucumber/Book.feature @@ -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 \ No newline at end of file + 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 + + diff --git a/test/cucumber/Dissertacao.feature b/test/cucumber/Dissertacao.feature index 98a20dd2..5eb67b28 100644 --- a/test/cucumber/Dissertacao.feature +++ b/test/cucumber/Dissertacao.feature @@ -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 @@ -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 @@ -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 diff --git a/test/cucumber/steps/BookSteps.groovy b/test/cucumber/steps/BookSteps.groovy index 45aae835..a39f34ea 100644 --- a/test/cucumber/steps/BookSteps.groovy +++ b/test/cucumber/steps/BookSteps.groovy @@ -7,6 +7,7 @@ */ import pages.BookCreatePage +import pages.BookShowPage import pages.BookPage import pages.LoginPage import pages.PublicationsPage @@ -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 -> @@ -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 -> @@ -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 -} \ No newline at end of file + assert checkIfExists(title) +} + diff --git a/test/cucumber/steps/DissertacaoSteps.groovy b/test/cucumber/steps/DissertacaoSteps.groovy index 03cd3324..5cb6b3ea 100644 --- a/test/cucumber/steps/DissertacaoSteps.groovy +++ b/test/cucumber/steps/DissertacaoSteps.groovy @@ -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.* @@ -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 @@ -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) +} + diff --git a/test/functional/pages/BookPage.groovy b/test/functional/pages/BookPage.groovy index 2c658d49..c2fdcba0 100644 --- a/test/functional/pages/BookPage.groovy +++ b/test/functional/pages/BookPage.groovy @@ -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() } diff --git a/test/functional/pages/BookShowPage.groovy b/test/functional/pages/BookShowPage.groovy new file mode 100644 index 00000000..46e923f9 --- /dev/null +++ b/test/functional/pages/BookShowPage.groovy @@ -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() + } + } + +} diff --git a/test/functional/pages/DissertationPage.groovy b/test/functional/pages/DissertationPage.groovy index b510ee72..473f7455 100644 --- a/test/functional/pages/DissertationPage.groovy +++ b/test/functional/pages/DissertationPage.groovy @@ -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 = { @@ -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] @@ -31,4 +43,5 @@ class DissertationPage extends Page { assert dissertationColumns.size() < 6 } + } diff --git a/test/functional/pages/DissertationShowPage.groovy b/test/functional/pages/DissertationShowPage.groovy index 30d667a3..eebd00d3 100644 --- a/test/functional/pages/DissertationShowPage.groovy +++ b/test/functional/pages/DissertationShowPage.groovy @@ -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 = { @@ -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() + } + } } diff --git a/test/functional/steps/TestDataDissertacao.groovy b/test/functional/steps/TestDataDissertacao.groovy index a7e034fa..d0dcfb74 100644 --- a/test/functional/steps/TestDataDissertacao.groovy +++ b/test/functional/steps/TestDataDissertacao.groovy @@ -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() }