From 40cfe23a0b4da8c3d161081a2d267ba68330bc39 Mon Sep 17 00:00:00 2001 From: Bruno Silva Date: Tue, 21 Jan 2014 02:00:04 -0300 Subject: [PATCH] Adicionando todos os testes e corrigindo as issues #249 e #251 --- .../domain/rgms/member/Orientation.groovy | 2 + test/cucumber/Orientation.feature | 33 +- test/cucumber/Thesis.feature | 18 +- test/cucumber/steps/BookChapterSteps.groovy | 42 +- test/cucumber/steps/MemberSteps.groovy | 26 +- test/cucumber/steps/OrientationSteps.groovy | 109 +-- test/cucumber/steps/ThesisSteps.groovy | 87 ++- .../OrientationCreatePage.groovy | 22 +- .../OrientationEditPage.groovy | 20 +- .../OrientationShowPage.groovy | 19 +- .../OrientationPages/OrientationsPage.groovy | 32 +- test/functional/pages/ThesisPage.groovy | 2 +- .../pages/thesis/ThesisCreatePage.groovy | 3 + .../pages/thesis/ThesisShowPage.groovy | 11 +- .../steps/MemberTestDataAndOperations.groovy | 1 - test/functional/steps/NewthesisGUI2.txt | 711 ++++++++++++++++++ .../OrientationTestDataAndOperations.groovy | 10 +- ...OrDissertationTestDataAndOperations.groovy | 16 + .../steps/ThesisTestDataAndOperations.groovy | 5 + 19 files changed, 996 insertions(+), 173 deletions(-) create mode 100644 test/functional/steps/NewthesisGUI2.txt diff --git a/grails-app/domain/rgms/member/Orientation.groovy b/grails-app/domain/rgms/member/Orientation.groovy index 13ff3c21..c53f5713 100644 --- a/grails-app/domain/rgms/member/Orientation.groovy +++ b/grails-app/domain/rgms/member/Orientation.groovy @@ -10,6 +10,7 @@ class Orientation { String instituicao String curso + static constraints = { tipo(nullable: false, blank: false, inList: ["Mestrado","Doutorado","Iniciação Científica"]) orientando(nullable: false) @@ -17,6 +18,7 @@ class Orientation { tituloTese(nullable: false, blank: false, unique: true) anoPublicacao(nullable: false, min: 0) instituicao(nullable: false, blank: false) + curso(nullable: true) } boolean Equals(Orientation other) diff --git a/test/cucumber/Orientation.feature b/test/cucumber/Orientation.feature index b0c154fb..feaa8927 100644 --- a/test/cucumber/Orientation.feature +++ b/test/cucumber/Orientation.feature @@ -5,9 +5,9 @@ Feature: orientations so that I can generate web pages and reports containing these orientations Scenario: new orientation - Given the system has no orientations entitled "The Book of Software" - When I create a new orientation entitled "The Book of Software" - Then the orientation "The Book of Software" is properly stored by the system + Given the system has no orientations entitled "The Book is on the table" + When I create a new orientation entitled "The Book is on the table" + Then the orientation "The Book is on the table" is properly stored by the system Scenario: remove existing orientation Given the system has an orientation entitled "The Book is on the table" supervised for someone @@ -17,21 +17,21 @@ Feature: orientations Scenario: create orientation web Given I am at the create orientation page When I fill the orientation title with "The Book of Web Software" - Then I am on the orientation show page + Then the orientation "The Book of Web Software" is properly stored by the system Scenario: edit existing orientation web Given I am at the orientation page and the orientation "The Book of Software Engineering" is stored in the system When I select to view orientation "The Book of Software Engineering" in resulting list And I change the orientation tituloTese to "Hexa" - And I select the "Alterar" option - Then I am on the orientation show page + And I select the alterar option at orientation edit page + Then I am on the orientation show page with edition completed #1 - Scenario: new orientation with registered member orientated - Given the system has no orientations entitled "The Book is on the table 2" - And Exists a member with username "rlfs" that has been an registered member - When I create a orientation for the thesis "The Book is on the table 2" with registered member "rlfs" - Then the orientation "The Book is on the table 2" is properly stored by the system + #Scenario: new orientation with registered member orientated + # Given the system has no orientations entitled "The Book is on the table 2" + # And Exists a member "Rubens Lopes" with username "rlfs" that has been an registered member + #When I create a orientation for the thesis "The Book is on the table 2" with registered member "rlfs" + #Then the orientation "The Book is on the table 2" is properly stored by the system #2 Scenario: duplicate orientation @@ -51,7 +51,7 @@ Feature: orientations When I select to view orientation "The Book is on the table" in resulting list And I change the orientation tituloTese to "Hexa" And I change the orientation anoPublicacao to -1 - And I select the "Alterar" option + And I select the alterar option at orientation edit page Then I am still on the change orientation page with the error message #if ($XMLUpload) @@ -68,8 +68,9 @@ Feature: orientations And the orientations are not stored by the system #end + #9 extra Scenario: remove orientation web - Given I am at the orientation page and the orientation "Hexa" is stored in the system - When I select to view orientation "Hexa" in resulting list - And I select the "Remover" option - Then The orientation "Hexa" is properly removed by the system \ No newline at end of file + Given I am at the orientation page and the orientation "Hexa2" is stored in the system + When I select to view "Hexa2" in the list of orientations + And I select the option remove at Orientation Show Page + Then The orientation "Hexa2" is properly removed by the system \ No newline at end of file diff --git a/test/cucumber/Thesis.feature b/test/cucumber/Thesis.feature index e9e1c7b3..d256942b 100644 --- a/test/cucumber/Thesis.feature +++ b/test/cucumber/Thesis.feature @@ -2,12 +2,12 @@ Feature: Thesis Tests As a member of a research group I want to add, remove and modify theses I have added - + Scenario: new thesis duplicated Given The thesis "Thesis duplicated" is stored in the system with file name "Thesisduplicated.txt" When I create the thesis "Thesis duplicated" with file name "Thesisduplicated2.txt" and school "UFPE" Then The thesis "Thesis duplicated" is not stored twice - + Scenario: new thesis Given The system has no thesis entitled "New thesis" When I create the thesis "New thesis" with file name "Newthesis.txt" and school "UFPE" @@ -15,9 +15,9 @@ Feature: Thesis Tests #6 Scenario: remove existing thesis - Given the system has thesis entitled "New thesis" - When I delete the thesis "New thesis" - Then the thesis "New thesis" is properly removed by the system + Given the system has thesis entitled "New thesis2" + When I delete the thesis "New thesis2" + Then the thesis "New thesis2" is properly removed by the system Scenario: create thesis web Given I am at the create thesis page @@ -32,10 +32,10 @@ Feature: Thesis Tests #7 Scenario: remove existing thesis web - Given I am at the thesis page and the thesis "Software Enginnering" is stored in the system - When I select to view thesis "Software Enginnering" in resulting list - And I select the "Remover" option on Thesis Show Page - Then the system show that the thesis has been removed + Given I am at the thesis page and the thesis "Software Enginnering2" is stored in the system + When I select to view thesis "Software Enginnering2" in resulting list + And I select the remover option on Thesis Show Page + Then the thesis "Software Enginnering2" has been removed from the system #if ($contextualInformation) Scenario: Add a new thesis with user data already filled by default diff --git a/test/cucumber/steps/BookChapterSteps.groovy b/test/cucumber/steps/BookChapterSteps.groovy index 6c0064f1..e81be63b 100644 --- a/test/cucumber/steps/BookChapterSteps.groovy +++ b/test/cucumber/steps/BookChapterSteps.groovy @@ -41,12 +41,12 @@ Then(~'^the book chapter "([^"]*)" is properly removed by the system$') { String checkIfExists(title) } -When(~'^I select the Novo BookChapter option at the book chapter page$') {-> +When(~'^I select the Novo BookChapter option at the book chapter page$') { -> at BookChapterPage page.selectNewBookChapter() } -Given(~'^I am at the book chapter page$') {-> +Given(~'^I am at the book chapter page$') { -> to LoginPage at LoginPage page.fillLoginData("admin", "adminadmin") @@ -60,20 +60,20 @@ And(~'^I fill only the title field with the value "([^"]*)"$') { String title -> page.fillTitle(title) } -Then(~'^A failure message is displayed$') {-> - assert ( page.readFlashMessage() != null ) +Then(~'^A failure message is displayed$') { -> + assert (page.readFlashMessage() != null) } -And(~'^I still on the book chapter create page$'){-> +And(~'^I still on the book chapter create page$') { -> at BookChapterCreatePage } -Then(~'^I see my user listed as a member of book chapter by default$') {-> +Then(~'^I see my user listed as a member of book chapter by default$') { -> at BookChapterCreatePage assert TestDataAndOperationsPublication.containsUser(page.selectedMembers()) } -When(~'^I view the book chapter list$') {-> +When(~'^I view the book chapter list$') { -> to BookChapterPage } @@ -82,7 +82,7 @@ Then(~'my book chapter list contains "([^"]*)"$') { String title -> bookChapterList = BookChapter.findAll() assert BookChapterTestDataAndOperations.containsBookChapter(title, bookChapterList) } -And(~'^the book chapter "([^"]*)" with file name "([^"]*)" was created before$'){ String title, filename -> +And(~'^the book chapter "([^"]*)" with file name "([^"]*)" was created before$') { String title, filename -> page.selectNewBookChapter() to BookChapterCreatePage at BookChapterCreatePage @@ -95,30 +95,30 @@ Then(~'My resulting book chapter list contains "([^"]*)"$') { String title -> at BookChapterPage page.checkBookChapterAtList(title, 0) } -When(~'^I go to NewBookChapter page$'){-> +When(~'^I go to NewBookChapter page$') { -> to BookChapterPage at BookChapterPage page.selectNewBookChapter() at BookChapterCreatePage } -And(~'^I use the webpage to create the book chapter "([^"]*)" with file name "([^"]*)"$'){ String title, filename -> +And(~'^I use the webpage to create the book chapter "([^"]*)" with file name "([^"]*)"$') { String title, filename -> at BookChapterCreatePage createAndCheckBookOnBrowser(title, filename) to BookChapterPage at BookChapterPage } -Then(~'^the book chapter "([^"]*)" was stored by the system$'){String title -> +Then(~'^the book chapter "([^"]*)" was stored by the system$') { String title -> book = BookChapter.findByTitle(title) assert book != null to BookChapterPage at BookChapterPage } -And(~'^it is shown in the book chapter list with title "([^"]*)"$'){ String title -> +And(~'^it is shown in the book chapter list with title "([^"]*)"$') { String title -> to BookChapterPage at BookChapterPage page.checkBookChapterAtList(title, 0) } -Given(~'^the system has some book chapters stored$') {-> +Given(~'^the system has some book chapters stored$') { -> initialSize = BookChapter.findAll().size() } When(~'^I upload the book chapters of "([^"]*)"$') { filename -> @@ -128,7 +128,7 @@ When(~'^I upload the book chapters of "([^"]*)"$') { filename -> finalSize = BookChapter.findAll().size() assert initialSize < finalSize } -Then(~'^the system has all the book chapters of the xml file$') {-> +Then(~'^the system has all the book chapters of the xml file$') { -> assert BookChapter.findByTitle("Refinement of Concurrent Object Oriented Programs") != null assert BookChapter.findByTitle("A RUP-Based Software Process Supporting Progressive Implementation") != null assert BookChapter.findByTitle("Transformation Laws for Sequential Object-Oriented Programming") != null @@ -138,21 +138,21 @@ Then(~'^the system has all the book chapters of the xml file$') {-> } -And(~'^I select the upload button at the book chapter page$') {-> +And(~'^I select the upload button at the book chapter page$') { -> at BookChapterPage page.uploadWithoutFile() } -Then(~'^I\'m still on book chapter page$') {-> +Then(~'^I\'m still on book chapter page$') { -> at BookChapterPage } -And(~'^the book chapters are not stored by the system$') {-> +And(~'^the book chapters are not stored by the system$') { -> at BookChapterPage page.checkIfBookChapterListIsEmpty() } And(~'^the system has a book chapter entitled "([^"]*)" with file name "([^"]*)"$') { String title, String filename -> book = BookChapter.findByPublisher(title) - if(book == null){ + if (book == null) { BookChapterTestDataAndOperations.createBookChapter(title, filename) to BookChapterCreatePage } @@ -163,20 +163,20 @@ Then(~'^the book chapter "([^"]*)" was not stored twice$') { String entitled -> assert bookChapter.size() < 2 } -And(~'^it is shown an message error$'){ -> +And(~'^it is shown an message error$') { -> at BookChapterSavePage assert page.readFlashMessage() != null } -def createAndCheckBookOnBrowser(String title, String filename){ +def createAndCheckBookOnBrowser(String title, String filename) { page.fillBookChapterDetails(title, filename) page.clickSaveBookChapter() book = BookChapter.findByTitle(title) assert book != null } -def checkIfExists(String title){ +def checkIfExists(String title) { bookChapter = BookChapter.findByTitle(title) assert bookChapter == null } diff --git a/test/cucumber/steps/MemberSteps.groovy b/test/cucumber/steps/MemberSteps.groovy index cb32c257..450d060e 100644 --- a/test/cucumber/steps/MemberSteps.groovy +++ b/test/cucumber/steps/MemberSteps.groovy @@ -35,7 +35,7 @@ Then(~'^the system has no member with a username "([^"]*)"$') { String username assert member == null } -Given(~'^I am at the login page$') {-> +Given(~'^I am at the login page$') { -> to LoginPage at LoginPage //assert (page.flashmessage?.size() == 0) @@ -46,12 +46,12 @@ When(~'^I fill username and password with "([^"]*)" and "([^"]*)"$') { String lo page.fillLoginData(login, password) } -Then(~'^I am still on the login page with an error message$') {-> +Then(~'^I am still on the login page with an error message$') { -> at LoginPage assert page.readFlashMessage() != null } -Given(~'^I am at the register page$') {-> +Given(~'^I am at the register page$') { -> to RegisterPage at RegisterPage } @@ -61,7 +61,7 @@ When(~'^I fill the user details with a name, username, passoword1, password2, em page.fillUserDetails(name, username, password1, password2, email, university, status) } -Then(~'^I am still on the register page with the message user created$') {-> +Then(~'^I am still on the register page with the message user created$') { -> at RegisterPage } @@ -99,7 +99,7 @@ Then(~'^the member "([^"]*)" is not registered$') { String username -> assert users.size() == 1 } -Given(~'^I am at the create member page$') {-> +Given(~'^I am at the create member page$') { -> to LoginPage at LoginPage page.fillLoginData("admin", "adminadmin") @@ -115,7 +115,7 @@ When(~'^I fill some user details with "([^"]*)" "([^"]*)" "([^"]*)" "([^"]*)"$') page.fillSomeMemberDetails(name, username, email, university) } -Then(~'^I am on the member show page$') {-> +Then(~'^I am on the member show page$') { -> at MemberViewPage } @@ -129,7 +129,7 @@ Then(~'^I am on the member show page$') {-> page.fillMemberDetails(name, username, email, university) }*/ -Then(~'^I am still on the create member page with the error message$') {-> +Then(~'^I am still on the create member page with the error message$') { -> at MemberCreatePage //assert mensagem != null @@ -143,7 +143,7 @@ When(~'^I fill user details with "([^"]*)" "([^"]*)" "([^"]*)" "([^"]*)"$') { St page.fillSomeMemberDetails(name, username, email, university) } -When(~"^I view the member list\$") {-> +When(~"^I view the member list\$") { -> members = Member.findAll() assert members != null } @@ -159,15 +159,15 @@ Then(~'the member with username "([^"]*)" is created$') { String username -> assert member != null } -Then(~'^I see default data filled on create form$'){ -> +Then(~'^I see default data filled on create form$') { -> at MemberCreatePage - defaultUniversity = "Federal University of Pernambuco" - defaultCity = "Recife" + defaultUniversity = "Federal University of Pernambuco" + defaultCity = "Recife" assert page.compareMemberUniversity(defaultUniversity) && page.compareMemberCity(defaultCity) } -Then(~'^I see default data filled on register form$'){ -> +Then(~'^I see default data filled on register form$') { -> at RegisterPage - defaultUniversity = "Federal University of Pernambuco" + defaultUniversity = "Federal University of Pernambuco" assert page.compareMemberUniversity(defaultUniversity) } \ No newline at end of file diff --git a/test/cucumber/steps/OrientationSteps.groovy b/test/cucumber/steps/OrientationSteps.groovy index aa520562..765b441c 100644 --- a/test/cucumber/steps/OrientationSteps.groovy +++ b/test/cucumber/steps/OrientationSteps.groovy @@ -32,12 +32,10 @@ When(~'^I create a new orientation entitled "([^"]*)"$') { String tituloTese -> } Then(~'^the orientation "([^"]*)" is properly stored by the system$') { String tituloTese -> - // Express the Regexp above with the code you wish you had orientation = Orientation.findByTituloTese(tituloTese) - assert OrientationTestDataAndOperations.OrientationCompatibleTo(orientation, tituloTese) + assert orientation != null } - //delete Given(~'^the system has an orientation entitled "([^"]*)" supervised for someone$') { String tituloTese -> OrientationTestDataAndOperations.createOrientation(tituloTese) @@ -56,44 +54,55 @@ Then(~'^the orientation for "([^"]*)" is properly removed by the system$') { Str } //create web -Given(~'^I am at the create orientation page$') {-> +Given(~'^I am at the create orientation page$') { -> Login() - to OrientationCreatePage - at OrientationCreatePage + to PublicationsPage + at PublicationsPage + page.select("Orientation") + at OrientationsPage + page.selectNewOrientation() + + at OrientationCreatePage } When(~'^I fill the orientation title with "([^"]*)"$') { title -> page.fillOrientationDetails(title) page.selectCreateOrientation() -} -Then(~'^I am on the orientation show page$') { -> at OrientationShowPage + page.showList() + + at OrientationsPage + } //edit web Given(~'^I am at the orientation page and the orientation "([^"]*)" is stored in the system$') { String title -> Login() + + to PublicationsPage at PublicationsPage page.select("Orientation") + at OrientationsPage page.selectNewOrientation() at OrientationCreatePage page.fillOrientationDetails(title) page.selectCreateOrientation() - orientation = Orientation.findByTituloTese(title) - assert orientation != null - to OrientationsPage - at OrientationsPage + at OrientationShowPage + page.showList() + at OrientationsPage + orientation = Orientation.findByTituloTese(title) + assert orientation != null } When(~'^I select to view orientation "([^"]*)" in resulting list$') { String oldtitle -> @@ -101,36 +110,38 @@ When(~'^I select to view orientation "([^"]*)" in resulting list$') { String old at OrientationsPage page.selectViewOrientation(oldtitle) - to OrientationShowPage at OrientationShowPage - page.select() + page.edit() + at OrientationEditPage } When(~'^I change the orientation tituloTese to "([^"]*)"$') { String newtitle -> - - at OrientationEditPage - page.edit(newtitle) + page.editTituloTese(newtitle) } -When(~'^I select the "([^"]*)" option$') { String option -> +When(~'^I select the alterar option at orientation edit page$') { -> + page.confirmEdit() +} - at OrientationEditPage - page.select(option) +Then(~'^I am on the orientation show page with edition completed$'){ -> + at OrientationShowPage + assert page.readFlashMessage() != null } -Given(~'^the system has some orientations stored$') {-> + +Given(~'^the system has some orientations stored$') { -> // save old metaclass def registry = GroovySystem.metaClassRegistry this.oldMetaClass = registry.getMetaClass(SecurityUtils) registry.removeMetaClass(SecurityUtils) // Mock login - def subject = [getPrincipal: {"admin"}, - isAuthenticated: {true} - ]as Subject + def subject = [getPrincipal: { "admin" }, + isAuthenticated: { true } + ] as Subject ThreadContext.put(ThreadContext.SECURITY_MANAGER_KEY, - [getSubject: {subject} as SecurityManager]) - SecurityUtils.metaClass.static.getSubject = {subject} + [getSubject: { subject } as SecurityManager]) + SecurityUtils.metaClass.static.getSubject = { subject } initialSize = Orientation.findAll().size() } @@ -143,22 +154,22 @@ When(~'^I upload a new orientation "([^"]*)"$') { filename -> assert inicialSize < finalSize } -Then(~'the system has more orientations now$') {-> +Then(~'the system has more orientations now$') { -> // restore metaclass GroovySystem.metaClassRegistry.setMetaClass(SecurityUtils, this.oldMetaClass) finalSize = Orientation.findAll().size() } -And(~'^I select the upload button at the orientations page$') {-> +And(~'^I select the upload button at the orientations page$') { -> at OrientationsPage page.uploadWithoutFile() } -Then(~'^I\'m still on orientations page$') {-> +Then(~'^I\'m still on orientations page$') { -> at OrientationsPage } -And(~'^the orientations are not stored by the system$') {-> +And(~'^the orientations are not stored by the system$') { -> at OrientationsPage page.checkIfOrientationListIsEmpty() } @@ -168,7 +179,7 @@ And(~'^the orientations are not stored by the system$') {-> * @author bss3 */ When(~'^I fill the orientation title with "([^"]*)" and the year with (-?\\d+)$') { title, year -> - page.fillOrientationDetailsWithGivenYear(title,year) + page.fillOrientationDetailsWithGivenYear(title, year) page.selectCreateOrientation() } @@ -181,14 +192,17 @@ Then(~'^I am still on the create orientation page with the error message$') { -> /** * @author rlfs */ -Given(~'^Exists a member with username "([^"]*)" that has been an registered member$') { String username -> - member = MemberTestDataAndOperations.findByUsername(username) - assert member != null +Given(~'^Exists a member "([^"]*)" with username "([^"]*)" that has been an registered member$') { String name, String username -> + + MemberTestDataAndOperations.createMember(username,"") + member = Member.findByName(name) + user = User.findByUsernameAndAuthor(username,member) + assert user != null } When(~'I create a orientation for the thesis "([^"]*)" with registered member "([^"]*)"$') { entitled, username -> member = MemberTestDataAndOperations.findByUsername(username) - OrientationTestDataAndOperations.createOrientationWithMenber(entitled,member) + OrientationTestDataAndOperations.createOrientationWithMenber(entitled, member) } //#2 @@ -198,30 +212,39 @@ Then(~'^the orientation for the thesis "([^"]*)" was not stored twice$') { entit } //#5 -And(~'^I change the orientation anoPublicacao to (-?\\d+)$'){ anoPublicacao -> +And(~'^I change the orientation anoPublicacao to (-?\\d+)$') { anoPublicacao -> at OrientationEditPage page.editYear(anoPublicacao) } -Then(~'^I am still on the change orientation page with the error message$'){ -> +Then(~'^I am still on the change orientation page with the error message$') { -> at OrientationEditPage assert page.readFlashMessage() != null } -Then(~'^The orientation "([^"]*)" is properly removed by the system$') { title-> +Then(~'^The orientation "([^"]*)" is properly removed by the system$') { title -> + assert Orientation.findByTituloTese(title) == null +} + +//Remover Orientation Web +When(~'^I select to view "([^"]*)" in the list of orientations$') { title -> at OrientationsPage - assert orientationNoExist(title) + page.selectViewOrientation(title) + + at OrientationShowPage } +When(~'^I select the option remove at Orientation Show Page$') { -> + at OrientationShowPage + page.delete() + +} //FUNCOES AUXILIARES -def orientationNoExist(String title){ - return Orientation.findByTituloTese(title) == null -} // o problema de duplicação que este método resolve não foi identificado pela ferramenta de detecção de clones -def Login(){ +def Login() { to LoginPage at LoginPage page.fillLoginData("admin", "adminadmin") diff --git a/test/cucumber/steps/ThesisSteps.groovy b/test/cucumber/steps/ThesisSteps.groovy index 8e6da2fb..074fd61e 100644 --- a/test/cucumber/steps/ThesisSteps.groovy +++ b/test/cucumber/steps/ThesisSteps.groovy @@ -13,23 +13,23 @@ import rgms.member.Member import java.io.File import static cucumber.api.groovy.EN.* -import org.codehaus.groovy.grails.web.context.ServletContextHolder +import org.codehaus.groovy.grails.web.context.ServletContextHolder -Given(~'^The system has no thesis entitled "([^"]*)"$') {String title -> +Given(~'^The system has no thesis entitled "([^"]*)"$') { String title -> article = Tese.findByTitle(title) assert article == null } -Given(~'^The thesis "([^"]*)" is stored in the system with file name "([^"]*)"$') { +Given(~'^The thesis "([^"]*)" is stored in the system with file name "([^"]*)"$') { String title, filename -> - ThesisTestDataAndOperations.createTese(title, filename, "UFPE") - article = Tese.findByTitle(title) - assert article != null + ThesisTestDataAndOperations.createTese(title, filename, "UFPE") + article = Tese.findByTitle(title) + assert article != null } When(~'^I create the thesis "([^"]*)" with file name "([^"]*)" and school "([^"]*)"$') { String title, filename, school -> - ThesisTestDataAndOperations.createTese(title, filename, school) + ThesisTestDataAndOperations.createTese(title, filename, school) } Then(~'^The thesis "([^"]*)" is not stored twice$') { String title -> @@ -42,7 +42,7 @@ Then(~'^The thesis "([^"]*)" is properly stored by the system$') { String title assert thesis != null } -Given(~'^I am at the create thesis page$') {-> +Given(~'^I am at the create thesis page$') { -> to LoginPage at LoginPage page.fillLoginData("admin", "adminadmin") @@ -52,27 +52,27 @@ Given(~'^I am at the create thesis page$') {-> When(~'^I fill the thesis details with "([^"]*)", "([^"]*)", "([^"]*)", "([^"]*)", "([^"]*)" and "([^"]*)"$') { title, pub_day, pub_month, pub_year, school, address -> - def absolutePath = ServletContextHolder.servletContext.getRealPath("/test/functional/steps/NewthesisGUI.txt") - absolutePath = absolutePath.replace("\\", "/").replaceAll("/web-app", "") - page.fillThesisDetails(title, pub_day, pub_month, pub_year, school, address, absolutePath) + def absolutePath = ServletContextHolder.servletContext.getRealPath("/test/functional/steps/NewthesisGUI.txt") + absolutePath = absolutePath.replace("\\", "/").replaceAll("/web-app", "") + page.fillThesisDetails(title, pub_day, pub_month, pub_year, school, address, absolutePath) } When(~'^I fill some thesis details with "([^"]*)", "([^"]*)", "([^"]*)", "([^"]*)", "([^"]*)" and "([^"]*)"$') { title, pub_day, pub_month, pub_year, school, address -> - page.fillSomeThesisDetails(title, pub_day, pub_month, pub_year, school, address) + page.fillSomeThesisDetails(title, pub_day, pub_month, pub_year, school, address) } -Then(~'^I am on the thesis show page$') {-> +Then(~'^I am on the thesis show page$') { -> at ThesisShowPage } -Then(~'^I am still on the create thesis page with the error message$') {-> +Then(~'^I am still on the create thesis page with the error message$') { -> at ThesisCreatePage } /** * @author carloscemb */ -When(~'^I select the new thesis option at the thesis page$') {-> +When(~'^I select the new thesis option at the thesis page$') { -> at ThesisPage page.selectNewThesis() at ThesisCreatePage @@ -81,12 +81,12 @@ When(~'^I select the new thesis option at the thesis page$') {-> /** * @author carloscemb */ -Then(~'^I see my user listed as an author member of thesis by default$') {-> +Then(~'^I see my user listed as an author member of thesis by default$') { -> at ThesisCreatePage assert TestDataAndOperationsPublication.containsUser(page.selectedMembers()) } -Then(~'^I see my school name as school of thesis by default$') {-> +Then(~'^I see my school name as school of thesis by default$') { -> at ThesisCreatePage userData = User.findByUsername('admin')?.author?.university assert page.currentSchool() == userData @@ -99,9 +99,23 @@ Then(~'^I see my school name as school of thesis by default$') {-> Given(~'^I am at the thesis page and the thesis "([^"]*)" is stored in the system$') { title -> Login() - at PublicationsPage page.select("Tese") + at ThesisPage + + if (Tese.findByTitle(title) == null) { //tese ja existe não e preciso criar denovo + System.out.println("Tese " + title + " não existia, criando-a") + page.selectNewThesis() + at ThesisCreatePage + def absolutePath = ServletContextHolder.servletContext.getRealPath("/test/functional/steps/NewthesisGUI2.txt") + absolutePath = absolutePath.replace("\\", "/").replaceAll("/web-app", "") + page.fillThesisDetails(title, "10", "8", "1998", "UFPE", "Recife", absolutePath) + page.selectCreateThesis() + tese = Tese.findByTitle(title) + assert tese != null + + at ThesisShowPage + } to ThesisPage at ThesisPage @@ -110,21 +124,46 @@ Given(~'^I am at the thesis page and the thesis "([^"]*)" is stored in the syste When(~'^I select to view thesis "([^"]*)" in resulting list$') { title -> at ThesisPage page.selectViewThesis(title) -} -When(~'^I select the "([^"]*)" option on Thesis Show Page$') { option -> at ThesisShowPage - page.select(option) } -Then(~'^the system show that the thesis has been removed$') { title -> +When(~'^I select the remover option on Thesis Show Page$') { -> + at ThesisShowPage + page.delete() + //passo para remover o alert +} + +Then(~'^the thesis "([^"]*)" has been removed from the system$') { title -> at ThesisPage - assert page.readFlashMessage() != null + thesisDoNotExists(title) +} + +// #6 +Given(~'^the system has thesis entitled "([^"]*)"$') { title -> + ThesisTestDataAndOperations.createTese(title, 'teste.txt', 'UFPE') + thesis = Tese.findByTitle(title) + assert thesis != null +} + +When(~'^I delete the thesis "([^"]*)"$') { title -> + ThesisTestDataAndOperations.deleteTeseByTitle(title) +} + +Then(~'^the thesis "([^"]*)" is properly removed by the system$') { title -> + tese = Tese.findByTitle(title) + assert tese == null } //FUNÇÔES AUXILIARES -def Login(){ +def thesisDoNotExists(title) { + tese = Tese.findByTitle(title) + assert tese == null +} + + +def Login() { to LoginPage at LoginPage page.fillLoginData("admin", "adminadmin") diff --git a/test/functional/pages/OrientationPages/OrientationCreatePage.groovy b/test/functional/pages/OrientationPages/OrientationCreatePage.groovy index 79f16d0b..27341e83 100644 --- a/test/functional/pages/OrientationPages/OrientationCreatePage.groovy +++ b/test/functional/pages/OrientationPages/OrientationCreatePage.groovy @@ -8,6 +8,7 @@ class OrientationCreatePage extends Page { static url = "orientation/create" static at = { + //title ==~ /Criar Orientation/ GetPageTitle gp = new GetPageTitle() @@ -15,7 +16,7 @@ class OrientationCreatePage extends Page { def currentTitle = gp.msg("default.create.label", [currentOrientation]) title ==~ currentTitle - tituloTese != null + //tituloTese != null } def fillOrientationDetails() { @@ -23,31 +24,26 @@ class OrientationCreatePage extends Page { } def fillOrientationDetails(title) { - - //def orientador = TestDataAndOperations.members[0] - - $("form").tituloTese = title $("form").tipo = "Mestrado" $("form").orientando = "Tomaz" - //$("form").orientador = orientador + $("form").tituloTese = title $("form").anoPublicacao = 2013 $("form").instituicao = "UFPE" - //selectCreateOrientation() - - // Could parametrize, obtaining data from class TestDataAndOperations + $("form").curso = "Ciencia da Computacao" } def fillOrientationDetailsWithGivenYear(title, year) { - $("form").tituloTese = title $("form").tipo = "Mestrado" $("form").orientando = "Tomaz" + $("form").tituloTese = title $("form").anoPublicacao = year $("form").instituicao = "UFPE" + $("form").curso = "Ciencia da Computacao" } - def selectCreateOrientation() { - $("input", name: "create").click() - + //$("input", name: "create").click() + $("input", name:"create", class:"save").click() } + } diff --git a/test/functional/pages/OrientationPages/OrientationEditPage.groovy b/test/functional/pages/OrientationPages/OrientationEditPage.groovy index f3bd1ae6..726de2b2 100644 --- a/test/functional/pages/OrientationPages/OrientationEditPage.groovy +++ b/test/functional/pages/OrientationPages/OrientationEditPage.groovy @@ -7,7 +7,6 @@ class OrientationEditPage extends Page { static url = "orientation/edit/1" static at = { - //title ==~ /Editar Orientation/ GetPageTitle gp = new GetPageTitle() @@ -15,9 +14,6 @@ class OrientationEditPage extends Page { def currentTitle = gp.msg("default.edit.label", [currentOrientation]) title ==~ currentTitle - - - } static content = { @@ -26,12 +22,8 @@ class OrientationEditPage extends Page { } } - - def edit(String novovalor){ - + def editTituloTese(String novovalor){ $("form").tituloTese = novovalor - //$("form").save().click() - } def editYear(String newYear){ @@ -42,4 +34,14 @@ class OrientationEditPage extends Page { def select(String s) { $("form").find("input", value: s).click() } + + def confirmEdit(){ + $('input', class:'save').click() + } + + + def delete(){ + assert withConfirm(true) { $("form").find('input', class: 'delete').click() } + } + } diff --git a/test/functional/pages/OrientationPages/OrientationShowPage.groovy b/test/functional/pages/OrientationPages/OrientationShowPage.groovy index 71fbcb25..cab39658 100644 --- a/test/functional/pages/OrientationPages/OrientationShowPage.groovy +++ b/test/functional/pages/OrientationPages/OrientationShowPage.groovy @@ -4,9 +4,10 @@ import geb.Page import pages.GetPageTitle class OrientationShowPage extends Page { - static url = "orientation/show/1" + static url = "orientation/show" static at = { + //title ==~ /Ver orientation/ GetPageTitle gp = new GetPageTitle() @@ -17,11 +18,27 @@ class OrientationShowPage extends Page { } static content = { + flashmessage { + $("div", class: "message") + } } def select() { $("form").find('a', class: 'edit').click() } + + def edit(){ + $('a', class: 'edit').click() + } + + def delete() { + assert withConfirm(true) { $("form").find('input', class: 'delete').click() } + } + + def showList(){ + $('a', class:'list').click() + } + //#if ($Twitter) def clickOnTwitteIt(String login, pw) { $("#button_twitter").click() diff --git a/test/functional/pages/OrientationPages/OrientationsPage.groovy b/test/functional/pages/OrientationPages/OrientationsPage.groovy index d631b687..c146a33a 100644 --- a/test/functional/pages/OrientationPages/OrientationsPage.groovy +++ b/test/functional/pages/OrientationPages/OrientationsPage.groovy @@ -9,6 +9,7 @@ class OrientationsPage extends Page { static at = { + //title ==~ /Orientation Listagem/ GetPageTitle gp = new GetPageTitle() @@ -24,30 +25,29 @@ class OrientationsPage extends Page { } } - def selectNewOrientation() { - $('a.create').click() + $('a', class:'create').click() } + def selectViewOrientation(title) { + def id = Orientation.findByTituloTese(title).id + $("a", text: id.toString()).click() - - def getRow(){ - - def listDiv = $('div', id: 'list-orientation') + /*def listDiv = $('div', id: 'list-orientation') def orientationTable = (listDiv.find('table'))[0] - def orientationRow = orientationTable.find('tbody').find('tr') - - return orientationRow - } - - def selectViewOrientation(title) { - getRow() - def showLink = getRow().find('td').find([text:title]) - showLink.click() + def orientationRow = (orientationTable.find('tbody'))[0].find('tr') + System.out.println("------------------------------------") + System.out.println(orientationRow.toString()) + System.out.println("------------------------------------") + def showLink = orientationRow.find('td').find([text:title]) + showLink.click()*/ + + /*def showLink = (getRow().find([text:title]))[0].find('td') + System.out.println("testando "+showLink) + showLink[0].click()*/ } - def checkOrientationAtList(title,row){ def orientationColumns = getRow()[row].find('td') diff --git a/test/functional/pages/ThesisPage.groovy b/test/functional/pages/ThesisPage.groovy index a0d8bd5c..7a361878 100644 --- a/test/functional/pages/ThesisPage.groovy +++ b/test/functional/pages/ThesisPage.groovy @@ -37,7 +37,7 @@ class ThesisPage extends Page { } def selectViewThesis(title) { - getRow() + //getRow() def showLink = getRow().find('td').find([text:title]) showLink.click() } diff --git a/test/functional/pages/thesis/ThesisCreatePage.groovy b/test/functional/pages/thesis/ThesisCreatePage.groovy index 4e065c2e..1b3101f1 100644 --- a/test/functional/pages/thesis/ThesisCreatePage.groovy +++ b/test/functional/pages/thesis/ThesisCreatePage.groovy @@ -38,4 +38,7 @@ class ThesisCreatePage extends FormPage { $("form").school } + def selectCreateThesis() { + $("input", name: "create", class: "save").click() + } } diff --git a/test/functional/pages/thesis/ThesisShowPage.groovy b/test/functional/pages/thesis/ThesisShowPage.groovy index f5a98fd6..14e7372f 100644 --- a/test/functional/pages/thesis/ThesisShowPage.groovy +++ b/test/functional/pages/thesis/ThesisShowPage.groovy @@ -5,7 +5,7 @@ import pages.GetPageTitle import rgms.publication.Tese class ThesisShowPage extends Page { - static url = "tese/show/1" + static url = "tese/show" static at = { GetPageTitle gp = new GetPageTitle() @@ -17,7 +17,12 @@ class ThesisShowPage extends Page { static content = { } - def select(String s) { - $("form").find("input", value: s).click() + def select() { + $("form").find('a', class: 'edit').click() } + + def delete(){ + assert withConfirm(true) { $("form").find('input', class: 'delete').click() } + } + } \ No newline at end of file diff --git a/test/functional/steps/MemberTestDataAndOperations.groovy b/test/functional/steps/MemberTestDataAndOperations.groovy index a2baa2dd..16b0b7de 100644 --- a/test/functional/steps/MemberTestDataAndOperations.groovy +++ b/test/functional/steps/MemberTestDataAndOperations.groovy @@ -47,7 +47,6 @@ class MemberTestDataAndOperations { cont.params << [id: identificador] cont.request.setContent(new byte[1000]) // Could also vary the request content. cont.delete() - //cont.save() cont.response.reset() } static public boolean containsMember(username) { diff --git a/test/functional/steps/NewthesisGUI2.txt b/test/functional/steps/NewthesisGUI2.txt new file mode 100644 index 00000000..eddf3b42 --- /dev/null +++ b/test/functional/steps/NewthesisGUI2.txt @@ -0,0 +1,711 @@ + + + + + + + + + rgms/test/functional/steps/NewthesisGUI.txt at master · macenas/rgms + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + +
+
+ + + + + +
+ + + + + +
+ + +
+
+ + + + + +
+ + This repository + + +
+
+ +
+ + +
This repository
+
+ +
+ + +
All repositories
+
+ +
+
+
+ + + + + + + + +
+ +
+ + + + + + + + + + + + +
+
+ + + + + + + + +
+ +
+
+ + +
    + +
  • +
    + +
    + + + + + Unwatch + + + +
    +
    +
    + Notification status + +
    + +
    + +
    + +
    + +

    Not watching

    + You only receive notifications for discussions in which you participate or are @mentioned. + + + Watch + +
    +
    + +
    + +
    + +

    Watching

    + You receive notifications for all discussions in this repository. + + + Unwatch + +
    +
    + +
    + +
    + +

    Ignoring

    + You do not receive any notifications for discussions in this repository. + + + Stop ignoring + +
    +
    + +
    + +
    +
    +
    + +
    +
  • + +
  • + + + +
  • + + +
  • + + Fork + + +
  • + + +
+ +

+ public + + + /rgms + + + Octocat-spinner-32 + + + + forked from spgroup/rgms + +

+
+
+ +
+ +
+ +
+ + + + +
+ + + + +
+

HTTPS clone URL

+ + + + +
+ + + +
+

SSH clone URL

+ + + + +
+ + + +
+

Subversion checkout URL

+ + + + +
+ + + +

You can clone with + HTTPS, + SSH, + Subversion, + and other methods. +

+ + + + + Clone in Desktop + + + + + Download ZIP + +
+
+ +
+ + + + + + + + +Show File Finder + +
+ + + +
+ + + branch: + master + + +
+ +
+
+ Switch branches/tags + +
+ +
+
+ +
+
+ +
+
+ +
+ +
+ + +
+ + master +
+
+ +
+ +
+

Create branch:

+ from ‘master’ +
+ + + +
+ +
+ +
+
+ + +
+ +
Nothing to show
+
+ +
+
+
+ + +
+ + +
+ Fetching contributors… + +
+

Octocat-spinner-32-eaf2f5

+

Cannot retrieve contributors at this time

+
+
+ +
+
+
+
+ + file + 25 lines (20 sloc) + 1.017 kb +
+ + +
+
+ + + + + +
+ 1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 + + +
@i9n
Feature: Thesis Tests
  As a member of a research group
  I want to add, remove and modify theses I have added

  Scenario: new thesis
    Given The system has no thesis entitled "New thesis"
    When I create the thesis "New thesis" with file name "Newthesis.txt" and school "UFPE"
    Then The thesis "New thesis" is properly stored by the system
    
  Scenario: new thesis duplicated
    Given The thesis "Thesis duplicated" is stored in the system with file name "Thesisduplicated.txt"
    When I create the thesis "Thesis duplicated" with file name "Thesisduplicated2.txt" and school "UFPE"
    Then The thesis "Thesis duplicated" is not stored twice

  Scenario: create thesis web
    Given I am at the create thesis page
    When I fill the thesis details
    Then I am on the thesis show page

  Scenario: create thesis web with partial information
    Given I am at the create thesis page
    When I fill some thesis details
    Then I am still on the create thesis page with the error message
+
+
+ +
+
+ + + + +
+ +
+ +
+
+ + +
+ +
+ +
+ + +
+
+
+ +
+
+
+
+
+
+ +
+ + + +
+ + + Something went wrong with that request. Please try again. +
+ + + + + diff --git a/test/functional/steps/OrientationTestDataAndOperations.groovy b/test/functional/steps/OrientationTestDataAndOperations.groovy index 2bb49868..b6e14444 100644 --- a/test/functional/steps/OrientationTestDataAndOperations.groovy +++ b/test/functional/steps/OrientationTestDataAndOperations.groovy @@ -1,6 +1,7 @@ package steps import rgms.member.Member +import rgms.member.Orientation import rgms.member.OrientationController import rgms.publication.XMLController @@ -37,7 +38,11 @@ class OrientationTestDataAndOperations { static public void createOrientation(String tituloTese) { def cont = new OrientationController() - cont.params << [tipo: "Mestrado", orientando: "Tomaz", tituloTese: tituloTese, anoPublicacao: 2013, instituicao: "UFPE", orientador: (new Member(members[0]))] + def memberCreater = new Member(members[0]) + memberCreater.create() + memberCreater.save() + def member = Member.findByName(memberCreater.name) + cont.params << [tipo: "Mestrado", orientando: "Tomaz", tituloTese: tituloTese, anoPublicacao: 2013, instituicao: "UFPE", orientador: member] cont.request.setContent(new byte[1000]) // Could also vary the request content. cont.create() cont.save() @@ -55,8 +60,7 @@ class OrientationTestDataAndOperations { } static public void removeOrientation(String tituloTese) { - - def testOrientation = OrientationTestDataAndOperations.findOrientationByTitle(tituloTese) + def testOrientation = Orientation.findByTituloTese(tituloTese) def cont = new OrientationController() cont.params << [id: testOrientation.id] cont.delete() diff --git a/test/functional/steps/ThesisOrDissertationTestDataAndOperations.groovy b/test/functional/steps/ThesisOrDissertationTestDataAndOperations.groovy index f6fe0afc..53e3a49b 100644 --- a/test/functional/steps/ThesisOrDissertationTestDataAndOperations.groovy +++ b/test/functional/steps/ThesisOrDissertationTestDataAndOperations.groovy @@ -1,5 +1,10 @@ package steps +import rgms.publication.Dissertacao +import rgms.publication.Publication +import rgms.publication.Tese +import rgms.publication.TeseController + class ThesisOrDissertationTestDataAndOperations { static protected void createThesisOrDissertation(String title, filename, school, cont) { @@ -12,4 +17,15 @@ class ThesisOrDissertationTestDataAndOperations { cont.response.reset() } + static protected void deleteThesisOrDissertation(String title, cont) { + def test + if (cont instanceof TeseController) { + test = Tese.findByTitle(title) + } else { + test = Dissertacao.findByTitle(title) + } + cont.params << [id: test.id] + cont.delete() + + } } diff --git a/test/functional/steps/ThesisTestDataAndOperations.groovy b/test/functional/steps/ThesisTestDataAndOperations.groovy index c89740fe..ab29efe6 100644 --- a/test/functional/steps/ThesisTestDataAndOperations.groovy +++ b/test/functional/steps/ThesisTestDataAndOperations.groovy @@ -9,4 +9,9 @@ class ThesisTestDataAndOperations { ThesisOrDissertationTestDataAndOperations.createThesisOrDissertation(title, filename, school, cont) } + static public void deleteTeseByTitle(String title){ + def cont = new TeseController() + ThesisOrDissertationTestDataAndOperations.deleteThesisOrDissertation(title,cont) + } + }