diff --git a/COMANDO GEBS b/COMANDO GEBS index a65afe4a..2751e247 100644 --- a/COMANDO GEBS +++ b/COMANDO GEBS @@ -1 +1,4 @@ -Dgeb.env=chrome -Dwebdriver.chrome.driver=/Users/Rodrigo/Documents/workspaces/TAES/gitsource/rgms/chromedrivers/chromedrivermac test-app functional:cucumber + +LSA2 +-Dserver.port=8090 -Dgeb.env=chrome -Dwebdriver.chrome.driver="Users\\Targelia Albuquerque\\Documents\\GitHub\\rgms\\chromedrivers\\chromedriverwindows" test-app functional:cucumber \ No newline at end of file diff --git a/chromedrivers/chromedriver.exe b/chromedrivers/chromedriver.exe new file mode 100644 index 00000000..42d553d2 Binary files /dev/null and b/chromedrivers/chromedriver.exe differ diff --git a/grails-app/conf/BuildConfig.groovy b/grails-app/conf/BuildConfig.groovy index 42066943..078281bc 100644 --- a/grails-app/conf/BuildConfig.groovy +++ b/grails-app/conf/BuildConfig.groovy @@ -53,6 +53,7 @@ grails.project.dependency.resolution = { compile(group: 'org.apache.poi', name: 'poi-ooxml', version: '3.7') { excludes 'xmlbeans' } + compile('commons-codec:commons-codec:1.6') // runtime 'mysql:mysql-connector-java:5.1.16' } @@ -61,7 +62,6 @@ grails.project.dependency.resolution = { compile ":remote-control:1.4" compile ":codenarc:0.20" compile ":gmetrics:0.3.1" - runtime ":hibernate:$grailsVersion" runtime ":jquery:1.7.1" runtime ":resources:1.1.6" diff --git a/grails-app/controllers/rgms/member/MemberController.groovy b/grails-app/controllers/rgms/member/MemberController.groovy index 9da75bf4..1c91c4ae 100644 --- a/grails-app/controllers/rgms/member/MemberController.groovy +++ b/grails-app/controllers/rgms/member/MemberController.groovy @@ -74,7 +74,7 @@ class MemberController { userInstance.errors.each { println it } - memberInstance.delete(flush: true) + memberInstance.delete() render(view: "create", model: [userMemberInstanceList: [memberInstance: memberInstance, userInstance: userInstance]]) return } diff --git a/grails-app/controllers/rgms/member/MembershipController.groovy b/grails-app/controllers/rgms/member/MembershipController.groovy index 1977f2a4..dd40bfcc 100644 --- a/grails-app/controllers/rgms/member/MembershipController.groovy +++ b/grails-app/controllers/rgms/member/MembershipController.groovy @@ -32,25 +32,11 @@ class MembershipController { } def show = { - def membershipInstance = Membership.get(params.id) - if (!membershipInstance) { - flash.message = message(code: 'default.not.found.message', args: [message(code: 'membership.label', default: 'Membership'), params.id]) - redirect(action: "list") - return - } - - [membershipInstance: membershipInstance] + showOrEdit(); } def edit = { - def membershipInstance = Membership.get(params.id) - if (!membershipInstance) { - flash.message = message(code: 'default.not.found.message', args: [message(code: 'membership.label', default: 'Membership'), params.id]) - redirect(action: "list") - return - } - - [membershipInstance: membershipInstance] + showOrEdit(); } def update = { @@ -118,4 +104,14 @@ class MembershipController { } } //#end + def showOrEdit(){ + def membershipInstance = Membership.get(params.id) + if (!membershipInstance) { + flash.message = message(code: 'default.not.found.message', args: [message(code: 'membership.label', default: 'Membership'), params.id]) + redirect(action: "list") + return + } + + [membershipInstance: membershipInstance] + } } diff --git a/grails-app/controllers/rgms/publication/BookController.groovy b/grails-app/controllers/rgms/publication/BookController.groovy index eab9da7a..1dbe5197 100644 --- a/grails-app/controllers/rgms/publication/BookController.groovy +++ b/grails-app/controllers/rgms/publication/BookController.groovy @@ -2,7 +2,7 @@ package rgms.publication class BookController { - static allowedMethods = [save: "POST", update: "POST", delete: "POST"] + static allowedMethods = [save: "POST", update: "POST", delete: "POST", share: "POST"] AuxiliarController aux = new AuxiliarController() def index() { @@ -23,10 +23,9 @@ class BookController { } def save() { - PublicationController pb = new PublicationController() def bookInstance = new Book(params) - bookInstance = pb.extractAuthors(bookInstance) + bookInstance = PublicationController.extractAuthors(bookInstance) if (!bookInstance.save(flush: true)) { @@ -38,10 +37,10 @@ class BookController { redirect(action: "show", id: bookInstance.id) } - def show(Long id) { - def bookInstance = Book.get(id) + def show() { + def bookInstance = Book.get(params.id) if (!bookInstance) { - flash.message = message(code: 'default.not.found.message', args: [message(code: 'book.label', default: 'Book'), id]) + flash.message = message(code: 'default.not.found.message', args: [message(code: 'book.label', default: 'Book'), params.id]) redirect(action: "list") return } @@ -49,10 +48,10 @@ class BookController { [bookInstance: bookInstance] } - def edit(Long id) { - def bookInstance = Book.get(id) + def edit() { + def bookInstance = Book.get(params.id) if (!bookInstance) { - flash.message = message(code: 'default.not.found.message', args: [message(code: 'book.label', default: 'Book'), id]) + flash.message = message(code: 'default.not.found.message', args: [message(code: 'book.label', default: 'Book'), params.id]) redirect(action: "list") return } diff --git a/grails-app/controllers/rgms/publication/PublicationController.groovy b/grails-app/controllers/rgms/publication/PublicationController.groovy index 3f0198ee..04619231 100644 --- a/grails-app/controllers/rgms/publication/PublicationController.groovy +++ b/grails-app/controllers/rgms/publication/PublicationController.groovy @@ -75,18 +75,7 @@ class PublicationController { return false } - InputStream inputStream = request.getInputStream() - OutputStream outputStream = new FileOutputStream(f) - byte[] buffer = new byte[1024 * 10] //buffer de 10MB - int length - - while ((length = inputStream.read(buffer)) > 0) { - outputStream.write(buffer, 0, length) - } - outputStream.close() - inputStream.close() - - return true + uploadFileStream(); } def static newUpload(Publication publicationInstance, flash, request) { @@ -100,18 +89,7 @@ class PublicationController { flash.message = 'File already exists. Please try to use a different file name.' return false } - InputStream inputStream = request.getInputStream() - OutputStream outputStream = new FileOutputStream(f) - byte[] buffer = new byte[1024 * 10] //buffer de 10MB - int length - - while ((length = inputStream.read(buffer)) > 0) { - outputStream.write(buffer, 0, length) - } - outputStream.close() - inputStream.close() - - return true + uploadFileStream(); } def static extractAuthors(instance) { @@ -161,4 +139,18 @@ class PublicationController { // return statusLine.getStatusCode(); } //#end + def static uploadFileStream() { + InputStream inputStream = request.getInputStream() + OutputStream outputStream = new FileOutputStream(f) + byte[] buffer = new byte[1024 * 10] //buffer de 10MB + int length + + while ((length = inputStream.read(buffer)) > 0) { + outputStream.write(buffer, 0, length) + } + outputStream.close() + inputStream.close() + + return true + } } diff --git a/grails-app/controllers/rgms/researchProject/FunderController.groovy b/grails-app/controllers/rgms/researchProject/FunderController.groovy index 0d845d43..01cc4705 100644 --- a/grails-app/controllers/rgms/researchProject/FunderController.groovy +++ b/grails-app/controllers/rgms/researchProject/FunderController.groovy @@ -32,25 +32,11 @@ class FunderController { } def show(Long id) { - def funderInstance = Funder.get(id) - if (!funderInstance) { - flash.message = message(code: 'default.not.found.message', args: [message(code: 'funder.label', default: 'Funder'), id]) - redirect(action: "list") - return - } - - [funderInstance: funderInstance] + showOrEdit(id); } def edit(Long id) { - def funderInstance = Funder.get(id) - if (!funderInstance) { - flash.message = message(code: 'default.not.found.message', args: [message(code: 'funder.label', default: 'Funder'), id]) - redirect(action: "list") - return - } - - [funderInstance: funderInstance] + showOrEdit(id); } def update(Long id, Long version) { @@ -100,5 +86,15 @@ class FunderController { redirect(action: "show", id: id) } } + def showOrEdit(Long id){ + def funderInstance = Funder.get(id) + if (!funderInstance) { + flash.message = message(code: 'default.not.found.message', args: [message(code: 'funder.label', default: 'Funder'), id]) + redirect(action: "list") + return + } + + [funderInstance: funderInstance] + } } //#end \ No newline at end of file diff --git a/grails-app/views/book/show.gsp b/grails-app/views/book/show.gsp index 7664a16c..019cea01 100644 --- a/grails-app/views/book/show.gsp +++ b/grails-app/views/book/show.gsp @@ -130,6 +130,25 @@ + + + + + + + + + +
diff --git a/test/cucumber/Article.feature b/test/cucumber/Article.feature index 01606f0d..73f3b97f 100644 --- a/test/cucumber/Article.feature +++ b/test/cucumber/Article.feature @@ -58,7 +58,7 @@ Feature: journal article Scenario: edit existing article web Given I am at the articles page and the article "A theory of software product line refinement" is stored in the system with file name "TCS-99.pdf" - When I select to view "A theory of software product line refinement" in resulting list + When I select to view "A theory of software product line refinement" in resulting list And I change the article title to "REVIEWED" And I select the "Alterar" option in Article Show Page Then I am at Article show page diff --git a/test/cucumber/Book.feature b/test/cucumber/Book.feature index 3624ed38..8ea0b39a 100644 --- a/test/cucumber/Book.feature +++ b/test/cucumber/Book.feature @@ -29,9 +29,43 @@ Feature: Book When I upload the books of "curriculo.xml" Then the system has all the books of the xml file + # @author droa + # BEGIN + + #MODIFIED Scenario: new book web - Given I am at the book page - 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 + Given I am at the publications menu + When I select the "Book" option at the publications menu + And I select the new book option at the book page + Then I can fill the book details + + Scenario: remove book web + Given I am logged in as admin + And I am at the Book Page + When I go to the page of the "Next Generation Software Product Line Engineering" book + And I follow the delete button confirming with OK + Then the book "Next Generation Software Product Line Engineering" is properly removed by the system + + Scenario: Add a new book and tweet it + Given I am logged in as admin + And I am at the Book Page + When I try to create a book named "Next Generation Software Product Line Engineering" with filename "NGS.pdf" + And I click on Share to share the book on Twitter with "rgms_ufpe" and "rgmsadmin2013" + Then a pop-up window with a tweet regarding the new book "Next Generation Software Product Line Engineering" is shown + + Scenario: edit book web + Given I am logged in as admin + And I am at the Book Page + And the book "Next Generation Software Product Line Engineering" is in the book list with file name "NGS.pdf" + When I select to edit the book "Next Generation Software Product Line Engineering" in resulting list + Then I can change the book details + + # END # + + Scenario: download book file + Given I am logged in as admin + And I am at the Book Page + And the book "Next Generation Software Product Line Engineering" is in the book list with file name "NGS.pdf" + When I select the download button + Then the download the file named "Ngs.pdf" is properly filed + diff --git a/test/cucumber/Book.feature.orig b/test/cucumber/Book.feature.orig new file mode 100644 index 00000000..e3d61506 --- /dev/null +++ b/test/cucumber/Book.feature.orig @@ -0,0 +1,70 @@ +@i9n +Feature: Book + As a member of a research group + I want to add, remove and modify books I have published + so that I can generate web pages and reports containing these books + + Scenario: new book + Given the system has no book entitled "SPL Development" + When I create the book "SPL Development" with file name "HSPLE.pdf" + Then the book "SPL Development" is properly stored by the system + + Scenario: remove book + Given the book "SPL Development" is stored in the system with file name "NGSPL-2.pdf" + When I remove the book "SPL Development" + Then the book "SPL Development" is properly removed by the system + + Scenario: duplicate book + Given the book "SPL Development" is stored in the system with file name "NGSPL-0.pdf" + When I create the book "SPL Development" with file name "NGSPL-0.pdf" + Then the book "SPL Development" is not stored twice + + Scenario: edit existing book + Given the book "SPL Development" is stored in the system with file name "HSPLE.pdf" + When I edit the book title from "SPL Development" to "New Title" + Then the book "New Title" is properly updated by the system + + Scenario: upload book with a file + Given the system has no books stored + When I upload the books of "curriculo.xml" + Then the system has all the books of the xml file + + # @author droa + # BEGIN + + #MODIFIED + Scenario: new book web + Given I am at the publications menu + When I select the "Book" option at the publications menu + And I select the new book option at the book page + Then I can fill the book details + + Scenario: remove book web + Given I am at the Book Page + When I go to the page of the "Next Generation Software Product Line Engineering" book + And I follow the delete button confirming with OK + Then the book "Next Generation Software Product Line Engineering" is properly removed by the system + +<<<<<<< HEAD + # END # + + Scenario: downloadd book file + Given I am at the book page + And the book entitled "Next Generation Software Product Line Engineering" is stored in the system with file name "Ngs.pdf" + When I select the download button + Then the download the file named "Ngs.pdf" is properly filed +======= + Scenario: Add a new book and tweet it + Given I am at the Book Page + When I try to create a book named "Next Generation Software Product Line Engineering" with filename "NGS.pdf" + And I click on Share to share the book on Twitter with "rgms_ufpe" and "rgmsadmin2013" + Then a pop-up window with a tweet regarding the new book "Next Generation Software Product Line Engineering" is shown + + Scenario: edit book web + Given I am at the Book Page + And the book "Next Generation Software Product Line Engineering" is in the book list with file name "NGS.pdf" + When I select to edit the book "Next Generation Software Product Line Engineering" in resulting list + Then I can change the book details + + # END # +>>>>>>> droa diff --git a/test/cucumber/BookChapter.feature b/test/cucumber/BookChapter.feature index 9f21361b..fa29a224 100644 --- a/test/cucumber/BookChapter.feature +++ b/test/cucumber/BookChapter.feature @@ -4,6 +4,19 @@ Feature: BookChapter I want to add, remove and modify book chapters I have published so that I can generate web pages and reports containing these book chapters +#if($editExistingBookChapter) + Scenario: edit existing Book Chapter + Given the book chapter "Chapter One" is stored on the system with file name "one.pdf" + When I update the existing chapter with a book chapter "Chapter One" with file name "two.pdf" + Then the book chapter "Chapter One" is updated in the system +#end +#if($bookChapterDoesNotExistTitle) + Scenario: book chapter does not exist (Title) + Given the book chapter "Chapter Zero" is not stored on the system + When I try to directly access the book chapter "Chapter Zero" + Then there is no book chapter entitled "Chapter Zero" on the system +#end + Scenario: new book chapter Given the system has no book chapter entitled "SPL Development" When I create the book chapter "SPL Development" with file name "HSPLE.pdf" @@ -14,10 +27,12 @@ Feature: BookChapter When I create the book chapter "Next Generation Software Product Line Engineering" with file name "NGSPL-0.pdf" Then the book chapter "Next Generation Software Product Line Engineering" is not stored twice +#if($removeBookChapter) Scenario: remove book chapter Given the book chapter "Next Generation Software Product Line Engineering" is stored in the system with file name "NGSPL-2.pdf" When I remove the book chapter "Next Generation Software Product Line Engineering" - * the book chapter "Next Generation Software Product Line Engineering" is properly removed by the system + Then the book chapter "Next Generation Software Product Line Engineering" is properly removed by the system +#end Scenario: register book chapter with invalid data Given I am at the book chapter page diff --git a/test/cucumber/Dissertacao.feature b/test/cucumber/Dissertacao.feature index 98a20dd2..d171e7ec 100644 --- a/test/cucumber/Dissertacao.feature +++ b/test/cucumber/Dissertacao.feature @@ -3,19 +3,21 @@ Feature: Dissertation Tests As a member of a research group I want to add, remove and modify dissertations I have added - Scenario: first dissertation and delete +#if($firstDissertationStored) + Scenario: first dissertation stored Given the system has no dissertation stored When I create the dissertation "New dissertation" with file name "dissertation.txt" and school "federal" - And I am at the publications menu And I select the "Dissertacao" option at the program menu - And I select "Delete dissertation" at the dissertation page - And I delete "New dissertation" - Then the system has no dissertation stored + And I select "Upload dissertation" at the dissertation page + Then the dissertation "New dissertation" is properly stored by the system +#end +#if($newDissertationWithoutSchool) Scenario: new dissertation without school Given the system has no dissertation entitled "Dissertation without school" When I create the dissertation "Dissertation without school" with file name "Dissertationwithoutschool.txt" without school - Then the system has no dissertation entitled "Dissertation without school" + Then the dissertation "Dissertation without school" is not properly stored by the system +#end Scenario: new dissertation without address Given the system has no dissertation entitled "Dissertation without address" @@ -51,11 +53,13 @@ Feature: Dissertation Tests And I can add the dissertation with a file "Modularity.pdf" Then the system has a dissertation entitled "Dissertacao Teste 1" - Scenario: edit dissertation +#if($editDissertationTitle) + Scenario: edit dissertation title Given the dissertation "Edit dissertation" is stored in the system with file name "Editdissertation.txt" - Given the system has no dissertation entitled "Edit dissertation reviewed" - When I edit the dissertation title from "Edit dissertation" to "Edit dissertation reviewed" - Then the dissertation "Edit dissertation" is properly updated by the system + And the system has no dissertation entitled "Edit dissertation reviewed" + When I edit the dissertation title from "Edit dissertation" to "Edit dissertation reviewed" + Then the dissertation "Edit dissertation" is properly updated by the system to "Edit dissertation reviewed" +#end Scenario: delete dissertation Given the dissertation "Delete dissertation" is stored in the system with file name "Deletedissertation.txt" @@ -71,11 +75,12 @@ Feature: Dissertation Tests And I select the upload button at the dissertation page Then I'm still on dissertation page +#if($uploadDissertationWithAFile) Scenario: upload dissertation with a file - Given the system has some dissertation stored - Given the system has no dissertation entitled "New dissertation" + Given the system has no dissertation entitled "New dissertation" stored When I upload a new dissertation "curriculo3.xml" with title "New dissertation" - Then the system has more dissertations now + Then the system will store "New dissertation" with the file "curriculo3.xml" +#end Scenario: upload a dissertation and system has no dissertation stored Given the system has no dissertation entitled "New dissertation" diff --git a/test/cucumber/Ferramenta.feature b/test/cucumber/Ferramenta.feature index 1db4f31c..3235e5de 100644 --- a/test/cucumber/Ferramenta.feature +++ b/test/cucumber/Ferramenta.feature @@ -10,6 +10,13 @@ Feature: Ferramenta When I create the ferramenta "Target" with file name "target.pdf" without its website Then the ferramenta "Target" is not stored +#if($newFerramentaWithWebsite) + Scenario: new ferramenta with website + Given the system has no ferramenta entitled "WebTarget" + When I create the ferramenta "WebTarget" with file name "target.pdf" with website "www.facebook.com" + Then the ferramenta "WebTarget" is stored +#end + Scenario: duplicate ferramenta Given the ferramenta "Emergo" is stored in the system with file name "emergo.pdf" When I create the ferramenta "Emergo" with file name "emergo.pdf" @@ -25,7 +32,7 @@ Feature: Ferramenta When I create the ferramenta "New" with file name "new.pdf" Then The system list "Tool" and "New" ferramentas - Scenario: upload dissertation with a file + Scenario: upload ferramenta with a file Given the system has some ferramenta stored When I upload a new ferramenta "testelattes.xml" Then the system has more ferramenta now @@ -43,19 +50,21 @@ Feature: Ferramenta And I select the new ferramenta option at the ferramenta page Then I can create a ferramenta filling the details - Scenario: new ferramenta without any information - Given I am at the publications menu - When I select the "Ferramenta" option at the program menu - And I select the new ferramenta option at the ferramenta page +#if($createFerramentaWithoutAnyInformation) + Scenario: create ferramenta without any information + Given I am at the ferramenta page And I click on Criar button Then I am still on create new ferramenta page And the ferramenta is not displayed in the ferramentas list page +#end - Scenario: upload dissertation without a file +#if($uploadFerramentaWithoutAFile) + Scenario: upload ferramenta without a file Given I am at the publications menu When I select the "Ferramenta" option at the program menu - And I select the upload button at the ferramenta page - Then I am still on ferramenta page + And I select the upload button at the ferramenta page without attaching a file + Then the ferramenta won't be inserted into the system. +#end #if ($contextualInformation) Scenario: new ferramenta filled with user data by default diff --git a/test/cucumber/Funder.feature b/test/cucumber/Funder.feature index be8c4fe8..95a277de 100644 --- a/test/cucumber/Funder.feature +++ b/test/cucumber/Funder.feature @@ -22,3 +22,11 @@ Feature: Funder Given I am at the create funder page When I fill the funder code with "12345" Then the funder with code "12345" is properly stored by the system + +#if(remove funder web) + Scenario: remove funder web + Given I am the funder page + And has funder in the list with code "12345" + When I select the funder with code "12345" + Then the funder with code "12345" is properly removed by the click on "remove" button +#end \ No newline at end of file diff --git a/test/cucumber/Member.feature b/test/cucumber/Member.feature index 239da9ff..8ff7568f 100644 --- a/test/cucumber/Member.feature +++ b/test/cucumber/Member.feature @@ -2,11 +2,33 @@ Feature: member As an administrator of the RGMS system I want to add, remove and modify users in the system. - +#if($newMemberWithValidMailServer) Scenario: new member with valid mail server Given the system has no member with username "usernametest" - When I create a member with username "usernametest" + When I create a member with username "usernametest" with valid mail server Then the member with username "usernametest" is properly stored by the system +#end + +#if($newMemberWithoutValidMailServer) + Scenario: new member without valid mail server + Given the system has no member with username "usernametest" + When I create a member with username "usernametest" with a invalid mail server "notReal" + Then the member with username "usernametest" is not properly stored by the system +#end + +#if($newMemberWithABlankUsername) + Scenario: new member with a blank username + Given the system without a member "" + When I create a member with username "" + Then the new member wont be inserted +#end + +#if($deleteInexistentMember) + Scenario: delete inexistent member + Given the system without a member "username" + When I delete a member with username "username" + Then the system will throw a message with an error "cannot find member" +#end Scenario: list existing member Given the system has member with username "usernametest" @@ -28,17 +50,26 @@ Feature: member When I try to create the member "Rebeca Souza" with email "memberEmail@ufpe.br" Then the member named "Rebeca Souza" is not registered + # User + +#if($loginWithCorrectPassword) + Scenario: login with correct password + Given I am at the login page + When I fill username and password with "admin" and "adminadmin" + Then I am at the main page logged in +#end + Scenario: login with incorrect password Given I am at the login page When I fill username and password with "admin" and "incorrectpassword" - Then I am still on the login page with an error message - Scenario: user registration +#if($validUserRegistration) + Scenario: valid user registration Given I am at the register page - When I fill the user details with a name, username, passoword1, password2, email, university, status "jose" "josesilva" "123456" "123456" "jose@ufpe.br" "UFPE" "Graduate Student" + When I fill the user details with a name "jose", a username "josesilva", a password1 "123456", a password2 "123456", a valid email "jose@ufpe.br", a university "UFPE" and a status "Graduate Student" Then I am redirected to the Login Page And A message indicating the user was successfully registered is displayed - +#end # Scenario: create member web # Given I am at the create member page diff --git a/test/cucumber/News.feature b/test/cucumber/News.feature index ff54e938..794a77fa 100644 --- a/test/cucumber/News.feature +++ b/test/cucumber/News.feature @@ -41,19 +41,26 @@ Feature: news Then there is no duplicated news in Twitter account associated with research group "SPG" +#if( $new news web) Scenario: new news web Given I am at the publications menu - And I create a research group because it is necessary + And I create a research group When I select the "News" option at the publications menu - And I select the novo noticias option at the news page + And I select the "new news" option at the news page Then I can fill the news details +#end +#if($newInvalidNewsInvalidResearchGroup) + Scenario: new invalid news (Invalid research group) + Given the system has no news with description "noticiaTeste" and date "01-01-2014" for "abc" research group + When I create a news with description "noticiaTeste" and date "01-01-2014" for "abc" research group + Then the news with description "noticiaTeste", date "01-01-2014" and "abc" research group is not stored by the system because it is invalid +#end - Scenario: new invalid news (Description blank) - Given the system has no news with description "" and date "17-12-2013" for "SPG" research group - When I create a news with description "" and date "17-12-2013" for "SPG" research group - Then the news with description "", date "17-12-2013" and "SPG" research group is not stored by the system because it is invalid - + Scenario: new invalid news + Given the system has some stored news + When I create a news with invalid fields + Then the news with with the invalid fields is not stored by the system because it is invalid Scenario: edit existing news Given the system has a news with description "noticiaTeste" and date "07-04-2012" for "SPG" research group @@ -65,9 +72,4 @@ Feature: news When I select the news page And the news "Noticia1" is stored in the system And I select the option to remove in news show page - Then the news "Noticia1" is properly removed by the system - - Scenario: new invalid news (invalid date) - Given the system has no news with description "teste" and date "31-02-2013" for "SPG" research group - When I try to create a news with description "teste" and date "31-02-2013" for "SPG" research group - Then the news with description "teste", date "31-02-2013" and "SPG" research group is not stored by the system because it is invalid + Then the news "Noticia1" is properly removed by the system \ No newline at end of file diff --git a/test/cucumber/Orientation.feature b/test/cucumber/Orientation.feature index 6ca3f5e4..daf1a409 100644 --- a/test/cucumber/Orientation.feature +++ b/test/cucumber/Orientation.feature @@ -9,6 +9,13 @@ Feature: orientations 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 +#if($duplicateOrientation) + Scenario: duplicate orientation + Given the system has an orientation entitled "The Book is on the table" supervised by someone + When I create a new orientation entitled "The Book is on the table" + Then the duplicate orientation "The Book is on the table" is not properly stored by the system +#end + Scenario: remove existing orientation Given the system has an orientation entitled "The Book is on the table" supervised by someone When I delete the orientation for "The Book is on the table" diff --git a/test/cucumber/Record.feature b/test/cucumber/Record.feature index 848071c0..67cd8ba3 100644 --- a/test/cucumber/Record.feature +++ b/test/cucumber/Record.feature @@ -39,6 +39,14 @@ Feature: record When I click the create record option Then I can fill the record details +#if(remove record web) + Scenario: remove record web + Given I am logged + And I am at record list + When I click the "remove record" option with status "MSc Student" + Then the system has no record with status "MSc Student" in the list +#end + Scenario: update record with status empty web Given I am logged And I am at record list @@ -54,4 +62,20 @@ Feature: record And the system has only one record with status "MSc Student" And the record with status "MSc Student" is associated to a member When I click to remove the record - Then I am still at the visualize page of the record with status "MSc Student" \ No newline at end of file + Then I am still at the visualize page of the record with status "MSc Student" + +#if($successfullyEditAStatus) + Scenario: successfully edit a status + Given a record with status "status" + When I fill the field of status with "new status" + And confirm the edit + Then the record will now show "new status" +#end + +#if($cancelTheEditOfAStatus) + Scenario: Cancel the edit of a status + Given a record with status "status" + When I fill the field of status with "new status" + And the member press the button cancel + Then the record wont save the "new status" +#end diff --git a/test/cucumber/Record.feature.orig b/test/cucumber/Record.feature.orig new file mode 100644 index 00000000..a6e80961 --- /dev/null +++ b/test/cucumber/Record.feature.orig @@ -0,0 +1,93 @@ +@i9n +Feature: record + As a member, I want to edit my status and create, edit and remove records + +#Depends on BootStrap code. Remove that. + + Scenario: Delete record without dependency + Given the system has only one record with status "Graduate Student" + And the record with status "Graduate Student" is not associated to a member + When I remove the record with status "Graduate Student" + Then the record with status "Graduate Student" is properly removed by the system + + Scenario: Delete record with dependency + Given the system has only one record with status "MSc Student" + And the record with status "MSc Student" is associated to a member + When I remove the record with status "MSc Student" + Then the record with status "MSc Student" is not removed by the system + + Scenario: Update record + Given the system has only one record with status "MSc Student" and this record has a null end date + When I update the record with status "MSc Student" with an end date "04/03/2013" + Then the record with status "MSc Student" has end date "04/03/2013" + + Scenario: Create record with same status name + Given the system has only one record with status "MSc Student" + When I create the record with status "MSc Student" + Then the record with status "MSc Student" is properly stored and the system has two records with this status + + Scenario: visualize record web + Given I am logged + And I am at record list + And the system has only one record with status "MSc Student" + When I click the record with status "MSc Student" at the record list + Then I am still at the visualize page of the record with status "MSc Student" + + Scenario: new record web + Given I am logged + And I am at record list + When I click the create record option + Then I can fill the record details + +#if(remove record web) + Scenario: remove record web + Given I am logged + And I am at record list + When I click the "remove record" option with status "MSc Student" + Then the system has no record with status "MSc Student" in the list +#end + + Scenario: update record with status empty web + Given I am logged + And I am at record list + And the system has only one record with status "MSc Student" + When I click the record with status "MSc Student" at the record list + And I click the edit button of the record + And I set the status to "" and I click the save button + Then I am at the edit page of the record with status "MSc Student" + + Scenario: delete record web with dependency + Given I am logged + And I am at the visualize page of the record with status "MSc Student" + And the system has only one record with status "MSc Student" + And the record with status "MSc Student" is associated to a member + When I click to remove the record + Then I am still at the visualize page of the record with status "MSc Student" + +#if($successfullyEditAStatus) + Scenario: successfully edit a status +<<<<<<< HEAD + Given a record with status "status" + When I fill the field of status with "new status" + And confirm the edit + Then the record will now show "new status" +======= + Given I am logged at my profile page, + When I fill the field of status with "new status", + Then my profile will now show my new status. +>>>>>>> droa +#end + +#if($cancelTheEditOfAStatus) + Scenario: Cancel the edit of a status +<<<<<<< HEAD + Given a record with status "status" + When I fill the field of status with "new status" + And the member press the button cancel + Then the record wont save the "new status" +======= + Given a field of status filled with "new status", + When the member press the button 'cancel', + Then nothing will be posted. +>>>>>>> droa +#end diff --git a/test/cucumber/Reports.feature b/test/cucumber/Reports.feature index bf58123a..bf685f7c 100644 --- a/test/cucumber/Reports.feature +++ b/test/cucumber/Reports.feature @@ -2,17 +2,11 @@ Feature: Reports I want to generate PDF, HTML or XML report files of Members, Research Groups and News - Scenario: export existent member report to html + Scenario: export existent member report Given I am at the Member list page When I select the "1" option at the Member list - And I can select the option Export to HTML at the Member show - Then I can generate a HTML report about Member "1" - - Scenario: export existent member report to xml - Given I am at the Member list page - When I select the "1" option at the Member list - And I can select the option Export to XML at the Member show - Then I can generate a XML report about Member "1" + And I can select any of the export options at the Member menu + Then I can generate a report about Member "1" Scenario: export recently created member report to pdf Given I am at the publications menu @@ -22,33 +16,14 @@ Feature: Reports And I can select the option Export to PDF at the Member show Then I can generate a PDF report about Member "2" - Scenario: export report to pdf of recently created research group - Given I am at the publications menu - When I select the "Research Group" option at the publications menu - And I select the new research group option at research group list page - Then I can fill the research group details with name "RGroup" and create a new one - And I select the "RGroup" option at the Research Group list - And I can select the option Export to PDF at the Research Group show - And I can generate a PDF report about Research Group "RGroup" - - - Scenario: export report to html of recently created research group - Given I am at the publications menu - When I select the "Research Group" option at the publications menu - And I select the new research group option at research group list page - Then I can fill the research group details with name "RGroup" and create a new one - And I select the "RGroup" option at the Research Group list - And I can select the option Export to HTML at the Research Group show - And I can generate a HTML report about Research Group "RGroup" - - Scenario: export report to xml of recently created research group + Scenario: export report of recently created research group Given I am at the publications menu When I select the "Research Group" option at the publications menu And I select the new research group option at research group list page Then I can fill the research group details with name "RGroup" and create a new one And I select the "RGroup" option at the Research Group list - And I can select the option Export to XML at the Research Group show - And I can generate a XML report about Research Group "RGroup" + And I can select any of the export options at the Research Group show + And I can generate a report about Research Group "RGroup" Scenario: export existent member report to html and access bibtex from him Given I am at the Member list page @@ -73,12 +48,6 @@ Feature: Reports Then I can select the Member "3" option And I can see the bibtex details - Scenario: export existent member report to pdf - Given I am at the Member list page - When I select the "3" option at the Member list - And I can select the option Export to PDF at the Member show - Then I can generate a PDF report about Member "3" - #if ($news && $HTML) Scenario: export report link not enabled when there are no news stored in the system Given I am at the publications menu diff --git a/test/cucumber/ResearchGroup.feature b/test/cucumber/ResearchGroup.feature index 00b98a39..15530ecb 100644 --- a/test/cucumber/ResearchGroup.feature +++ b/test/cucumber/ResearchGroup.feature @@ -37,7 +37,14 @@ Feature: research group When I modify the name of research group entitled "modcs-3" to none Then the research group is not stored in the system because it has no name - +#if($edit research group) + Scenario:edit research group + Given the system has a research group entitled "modcs" with the description "modcs research group" stored in the system + When I modify the research group entitled "modcs" to "modcs 123" + And its description to "modcs research group 1234" + Then the edited research group "modcs 123" with description "modcs research group 1234" is properly stored in the system +#end + Scenario:edit research group Given the system has a research group entitled "modcs" with the description "modcs research group" stored in the system When I modify the research group entitled "modcs" to "modcs 123" and its description to "modcs research group 1234" diff --git a/test/cucumber/ResearchLine.feature b/test/cucumber/ResearchLine.feature index 7e13bd62..0651e674 100644 --- a/test/cucumber/ResearchLine.feature +++ b/test/cucumber/ResearchLine.feature @@ -8,6 +8,13 @@ Feature: research line When I remove the research line "Novo Padrao Arquitetural MVCE" Then the research line "Novo Padrao Arquitetural MVCE" is properly removed by the system + Scenario: Delete research line web + Given I am logged as "admin" and at the visits page + And a research line named "Novo Padrao Arquitetural MVCE" with a description "Nova arquitetura que promete revolucionar a web" is stored in the system + When I select to view the research line named "Novo Padrao Arquitetural MVCE" with a description "Nova arquitetura que promete revolucionar a web" in resulting list + Then the visit details are showed and I can select the option to remove + And the research line named "Novo Padrao Arquitetural MVCE" with a description "Nova arquitetura que promete revolucionar a web" is properly removed by the system + Scenario: Update research line Given the system has a research line named "Teoria da informacao - Complexidade no espaco" with a description "P = NP" When I update the research line "Teoria da informacao - Complexidade no espaco" with a description "P != NP" diff --git a/test/cucumber/TechnicalReport.feature b/test/cucumber/TechnicalReport.feature index 6a92530a..8f033a33 100644 --- a/test/cucumber/TechnicalReport.feature +++ b/test/cucumber/TechnicalReport.feature @@ -48,6 +48,11 @@ Feature: technical report Then The technical report "TC88" with filename "TCS-88.pdf" and institution "UFRPE" is properly updated. And The technical report "TC88" details page is shown + Scenario: remove existing technical report + Given the system has a techincal report entitled "Joe-E" with file name "Joee.pdf" + When I delete the technical report entitled "Joe-E" with file name "Joee.pdf" + Then he technical report "Joe-E" is properly removed by the system + Scenario: remove existing technical report Given I am at the technical reports page And The system has an technical report entitled "Joe-E" with file name "Joee.pdf" diff --git a/test/cucumber/Thesis.feature b/test/cucumber/Thesis.feature index e664276f..1501dae6 100644 --- a/test/cucumber/Thesis.feature +++ b/test/cucumber/Thesis.feature @@ -13,6 +13,22 @@ Feature: Thesis Tests 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 +#if ($editExistingThesisWeb) + Scenario: edit existing thesis web + Given I am at the thesis page and the thesis "Software Engineering" is stored in the system + When I select to edit thesis "Software Engineering" in resulting list + And I modify the field School to "UFRPE" + Then The thesis "Software Engineering" now has "UFRPE" in the school field +#end + +#if ($filterThesisList) +# Scenario: filter thesis list +# Given I am at the thesis show page +# When I select Filter Thesis +# And I fill the field School with "UFPE" +# Then I only see the thesis with the field School equal to "UFPE" +#end + Scenario: remove existing thesis Given the system has thesis entitled "New thesis2" When I delete the thesis "New thesis2" @@ -38,7 +54,7 @@ Feature: Thesis Tests #if ($contextualInformation) Scenario: Add a new thesis with user data already filled by default Given I am at the publications menu - When I select the "Tese" option at the publications menu + When I select the Tese option at the publications menu And I select the new thesis option at the thesis page Then I see my user listed as an author member of thesis by default And I see my school name as school of thesis by default @@ -50,6 +66,13 @@ Feature: Thesis Tests When I click in order thesis by date Then the returned thesis list has the same items but it is sorted by date +#if ($SortThesisListInAlphabeticalOrder) +# Scenario: sort thesis list in alphabetical order +# Given I am at the thesis page and the thesis "Augmented Reality" is stored in the system +# When The user adds a thesis entitled "Software Engineering" +# Then The thesis "Software Engineering" is properly stored after "Augmented Reality" +#end + Scenario: search an existing thesis Given the system has one thesis entitled "Software Engineering" with author name "Pressman", year of publication "1998" and university "UFPE" And I am at the thesis search page diff --git a/test/cucumber/Visit.feature b/test/cucumber/Visit.feature index 2ddf3bdc..cb44bd4b 100644 --- a/test/cucumber/Visit.feature +++ b/test/cucumber/Visit.feature @@ -4,17 +4,20 @@ Feature: Visit I want to add, remove and modify visits of external members to the group so that I can store the visits that external member perform to the group, so do as the visitor +#if($visitOfADayForANonStoredVisitor) Scenario: visit of a day for a non stored visitor Given the system has no visitor named "Person" - When I create the visit for the visitor "Person" with initial date "11/11/2000" + When I create the one-day visit for the visitor "Person" with initial date "11/11/2000" Then the visitor named "Person" is properly stored by the system And the visit for the visitor "Person" with initial and final date equal to "11/11/2000" is properly stored by the system - +#end +#if($visitOfAPeriodForANonStoredVisitor) Scenario: visit of a period for a non stored visitor Given the system has no visitor named "Person" - When I create the visit for the visitor "Person" with initial date "11/11/2000" and final date "12/11/2000" + When I create the period visit for the visitor "Person" with initial date "11/11/2000" and final date "12/11/2000" Then the visitor named "Person" is properly stored by the system And the visit for the visitor "Person" with initial date "11/11/2000" and final date "12/11/2000" is properly stored by the system +#end Scenario: visit of a day for a stored visitor Given the system has visitor named "Person" @@ -75,6 +78,20 @@ Feature: Visit When I try to edit the visit of the visitor named "Person" with initial date "11/11/2000" and final date "12/11/2000" changing the final date to "10/11/2000" Then the visit of the visitor named "Person" with initial date "11/11/2000" and final date "12/11/2000" is not properly updated by the system because it is invalid + Scenario: duplicate visit instance + Given the system has a visitor named "Person" + And a visit for the visitor "Person" with initial date "11/11/2000" and final date "12/11/2000" + When I create the visit for the visitor "Person" with initial date "11/11/2000" and final date "12/11/2000" + Then the visit for the visitor "Person" with initial date "11/11/2000" and final date "12/11/2000" is not stored twice + + Scenario: duplicate vist instance web + Given I am logged as "admin" and at the visits page + And a visit for the visitor "Person" with initial date "11/11/2000" and final date "12/11/2000" is stored on the system + When I try to create the visit for the visitor "Person" with initial date "11/11/2000" and final date "12/11/2000" + And I confirm the details by clicking on the confirm button + Then no new vist is stored by the system + And I get an error message + @ignore Scenario: list existing visits and periods Given the system has visits with initial or final date greater than or equal "01/01/2011" diff --git a/test/cucumber/XMLImport.feature b/test/cucumber/XMLImport.feature index cc0dcc6a..06d9aa84 100644 --- a/test/cucumber/XMLImport.feature +++ b/test/cucumber/XMLImport.feature @@ -5,14 +5,13 @@ Feature: XMLImport So that the system register the corresponding publications in my profile @ignore - Scenario: invalid file web + Scenario: invalid file web Given I am at the "Import XML File" Page When I select the "upload" button And I upload the file "cv.pdf" - Then the system outputs an error message - And no new publication is stored by the system - And the previously stored publications do not change - + Then no new publication is stored by the system + And the system outputs an error message + @ignore Scenario: invalid file Given the system has some publications stored diff --git a/test/cucumber/steps/ArticleSteps.groovy b/test/cucumber/steps/ArticleSteps.groovy index 1ef4ff03..d0f665bb 100644 --- a/test/cucumber/steps/ArticleSteps.groovy +++ b/test/cucumber/steps/ArticleSteps.groovy @@ -45,6 +45,7 @@ When(~'^I select the new article option at the article page$') {-> Then(~'^I can fill the article details$') {-> at ArticleCreatePage page.fillArticleDetails() + page.selectCreateArticle() } @@ -65,12 +66,7 @@ Given(~'^I am at the articles page and the article "([^"]*)" is stored in the sy Login() at PublicationsPage page.select("Periodico") - selectNewArticleInArticlesPage() - page.fillArticleDetails(ArticleTestDataAndOperations.path() + filename, title) - page.selectCreateArticle() - assert !periodicoNoExist(title) - to ArticlesPage - at ArticlesPage + addNewArticleWeb(title, filename); } /** diff --git a/test/cucumber/steps/BookChapterSteps.groovy b/test/cucumber/steps/BookChapterSteps.groovy index 1ef01632..2f19a6ec 100644 --- a/test/cucumber/steps/BookChapterSteps.groovy +++ b/test/cucumber/steps/BookChapterSteps.groovy @@ -22,12 +22,38 @@ Then(~'^the book chapter "([^"]*)" is properly stored by the system$') { String assert BookChapterTestDataAndOperations.bookChapterCompatibleTo(bookChapter, title) } +//if($editExistingBookChapter) Given(~'^the book chapter "([^"]*)" is stored in the system with file name "([^"]*)"$') { String title, String filename -> BookChapterTestDataAndOperations.createBookChapter(title, filename) bookChapter = BookChapter.findByTitle(title) assert bookChapter != null } +When(~'^I update the file with a book chapter "([^"]*)" with file name "([^"]*)"$') { String title, String filename -> + BookChapterTestDataAndOperations.removeBookChapter(title) + BookChapterTestDataAndOperations.createBookChapter(title, filename) +} + +Then(~'^the book chapter "([^"]*)" is updated on the system$'){ String title -> + bookChapters = BookChapter.findAllByTitle(title) + assert bookChapters.size() == 1 +} +//end +//if($bookChapterDoesNotExistTitle) +Given(~'^the book chapter "([^"]*)" is not stored on the system$') { String title -> + bookChapters = BookChapter.findAllByTitle(title) + assert bookChapters.size() == 0 +} + +When(~'^I try to directly access the book chapter "([^"]*)"$') { String title -> + checkIfExists(title) +} + +Then(~'there is no book chapter entitled "([^"]*)" on the system$') { String title -> + bookChapters = BookChapter.findByTitle(title) + assert bookChapters.size() == 0 +} + Then(~'^the book chapter "([^"]*)" is not stored twice$') { String title -> bookChapters = BookChapter.findAllByTitle(title) assert bookChapters.size() == 1 diff --git a/test/cucumber/steps/BookSteps.groovy b/test/cucumber/steps/BookSteps.groovy index 45aae835..cbf0f744 100644 --- a/test/cucumber/steps/BookSteps.groovy +++ b/test/cucumber/steps/BookSteps.groovy @@ -7,10 +7,13 @@ */ import pages.BookCreatePage +import pages.BookEditPage import pages.BookPage +import pages.BookShowPage import pages.LoginPage import pages.PublicationsPage import rgms.publication.Book +import rgms.tool.TwitterTool import steps.BookTestDataAndOperations import static cucumber.api.groovy.EN.* @@ -19,7 +22,7 @@ Given(~'^the system has no book entitled "([^"]*)"$') { String title -> checkIfExists(title) } -When(~'^I create the book "([^"]*)" with file name "([^"]*)"$') { String title, filename -> +When(~'^I create the book "([^"]*)" with file name "([^"]*)"$') { String title, String filename -> BookTestDataAndOperations.createBook(title, filename) } @@ -38,6 +41,78 @@ When(~'^I remove the book "([^"]*)"$') { String title -> BookTestDataAndOperations.removeBook(title) } +/* + * @author droa + * BEGIN + */ + +When(~'^I select the new book option at the book page$') {-> + selectNewBookInBookPage() +} + +def selectNewBookInBookPage(){ + at BookPage + page.selectNewBook() + at BookCreatePage +} + +Then(~'^I can fill the book details$') {-> + at BookCreatePage + page.fillBookDetails() + page.selectCreateBook() +} + +When(~'I go to the page of the "([^"]*)" book$') { String title -> + at BookPage + page.selectBook(title) +} + +And(~'I follow the delete button confirming with OK$') { -> + at BookShowPage + page.select('input', 'delete') +} + +And(~'^I click on Share to share the book on Twitter with "([^"]*)" and "([^"]*)"$') { String twitterLogin, String twitterPw -> + at BookShowPage + page.clickOnTwitteIt(twitterLogin, twitterPw) +} + +Then(~'^a pop-up window with a tweet regarding the new book "([^"]*)" is shown$') { String bookTitle -> + TwitterTool.addTwitterHistory(bookTitle, "added") + assert TwitterTool.consult(bookTitle) +} + +Given(~'^the book "([^"]*)" is in the book list with file name "([^"]*)"$') { String title, String filename -> + book = Book.findByTitle(title) + if (book == null) { + page.selectNewBook() + at BookCreatePage + page.fillBookDetails(BookTestDataAndOperations.path() + filename, title) + page.selectCreateBook() + } + + to BookPage +} + +When(~'^I select to edit the book "([^"]*)" in resulting list$') { String title -> + at BookPage + page.selectBook(title) + + at BookShowPage + page.select('a', 'edit') + + at BookEditPage +} + +Then(~'^I can change the book details$') { -> + def path = new File(".").getCanonicalPath() + File.separator + "test" + File.separator + "files" + File.separator + page.edit("Next Generation Software Product Line Engineering REVIEWED", path + "NGS2.pdf") + + page.doEdit() +} + +/* END */ + Then(~'^the book "([^"]*)" is properly removed by the system$') { String title -> checkIfExists(title) } @@ -76,10 +151,7 @@ Then(~'^the system has all the books of the xml file$') { -> assert Book.findByTitle("AOSD 2011 Proceedings and Companion Material") != null } -Given(~'^I am at the book page$') { -> - to LoginPage - at LoginPage - page.fillLoginData("admin", "adminadmin") +And(~'^I am at the Book Page$') { -> at PublicationsPage to BookPage } @@ -89,11 +161,10 @@ When(~'^I go to new book page$') { -> 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 +And(~'^I try to create a book named "([^"]*)" with filename "([^"]*)"$') { String title, String filename -> + selectNewBookInBookPage() + page.fillBookDetails(BookTestDataAndOperations.path() + filename, title) + page.selectCreateBook() } Then(~'^the book "([^"]*)" was stored by the system$') { String title -> @@ -103,14 +174,21 @@ Then(~'^the book "([^"]*)" was stored by the system$') { String title -> at BookPage } +When(~'^I select the download button$') { -> + at BookPage + page.downloadFile() +} + +Then(~'^the download the file named "([^"]*) is properly filed"$') { String filename -> + at BookPage + assert page.downloadFile(book, title) +} + def checkIfExists(String title) { book = Book.findByTitle(title) assert book == null } -def createAndCheckBookOnBrowser(String title, String filename) { - page.fillBookDetails(title, filename) - page.clickSaveBook() - book = Book.findByTitle(title) - assert book != null +def downloadFile(String filename){ + return } \ No newline at end of file diff --git a/test/cucumber/steps/BookSteps.groovy.orig b/test/cucumber/steps/BookSteps.groovy.orig new file mode 100644 index 00000000..27ff7c37 --- /dev/null +++ b/test/cucumber/steps/BookSteps.groovy.orig @@ -0,0 +1,216 @@ +/** + * Created with IntelliJ IDEA. + * User: dyego + * Date: 22/02/14 + * Time: 15:30 + * To change this template use File | Settings | File Templates. + */ + +import pages.BookCreatePage +import pages.BookEditPage +import pages.BookPage +import pages.BookShowPage +import pages.LoginPage +import pages.PublicationsPage +import rgms.publication.Book +import rgms.tool.TwitterTool +import steps.BookTestDataAndOperations + +import static cucumber.api.groovy.EN.* + +Given(~'^the system has no book entitled "([^"]*)"$') { String title -> + checkIfExists(title) +} + +When(~'^I create the book "([^"]*)" with file name "([^"]*)"$') { String title, String filename -> + BookTestDataAndOperations.createBook(title, filename) +} + +Then(~'^the book "([^"]*)" is properly stored by the system$') { String title -> + book = Book.findByTitle(title) + assert BookTestDataAndOperations.bookCompatibleTo(book, title) +} + +Given(~'^the book "([^"]*)" is stored in the system with file name "([^"]*)"$') { String title, String filename -> + BookTestDataAndOperations.createBook(title, filename) + book = Book.findByTitle(title) + assert BookTestDataAndOperations.bookCompatibleTo(book, title) +} + +When(~'^I remove the book "([^"]*)"$') { String title -> + BookTestDataAndOperations.removeBook(title) +} + +/* + * @author droa + * BEGIN + */ + +When(~'^I select the new book option at the book page$') {-> + selectNewBookInBookPage() +} + +def selectNewBookInBookPage(){ + at BookPage + page.selectNewBook() + at BookCreatePage +} + +Then(~'^I can fill the book details$') {-> + at BookCreatePage + page.fillBookDetails() + page.selectCreateBook() +} + +When(~'I go to the page of the "([^"]*)" book$') { String title -> + at BookPage + page.selectBook(title) +} + +And(~'I follow the delete button confirming with OK$') { -> + at BookShowPage + page.select('input', 'delete') +} + +And(~'^I click on Share to share the book on Twitter with "([^"]*)" and "([^"]*)"$') { String twitterLogin, String twitterPw -> + at BookShowPage + page.clickOnTwitteIt(twitterLogin, twitterPw) +} + +Then(~'^a pop-up window with a tweet regarding the new book "([^"]*)" is shown$') { String bookTitle -> + TwitterTool.addTwitterHistory(bookTitle, "added") + assert TwitterTool.consult(bookTitle) +} + +Given(~'^the book "([^"]*)" is in the book list with file name "([^"]*)"$') { String title, String filename -> + book = Book.findByTitle(title) + if (book == null) { + page.selectNewBook() + at BookCreatePage + page.fillBookDetails(BookTestDataAndOperations.path() + filename, title) + page.selectCreateBook() + } + + to BookPage +} + +When(~'^I select to edit the book "([^"]*)" in resulting list$') { String title -> + at BookPage + page.selectBook(title) + + at BookShowPage + page.select('a', 'edit') + + at BookEditPage +} + +Then(~'^I can change the book details$') { -> + def path = new File(".").getCanonicalPath() + File.separator + "test" + File.separator + "files" + File.separator + page.edit("Next Generation Software Product Line Engineering REVIEWED", path + "NGS2.pdf") + + page.doEdit() +} + +/* END */ + +Then(~'^the book "([^"]*)" is properly removed by the system$') { String title -> + checkIfExists(title) +} + +Then(~'^the book "([^"]*)" is not stored twice$') { String title -> + books = Book.findAllByTitle(title) + assert books.size() == 1 +} + +When(~'^I edit the book title from "([^"]*)" to "([^"]*)"$') { String oldtitle, newtitle -> + def updatedBook = BookTestDataAndOperations.editBook(oldtitle, newtitle) + assert updatedBook != null +} + +Then(~'^the book "([^"]*)" is properly updated by the system$') { String title -> + assert Book.findByTitle(title) != null +} + +Given(~'^the system has no books stored$') { -> + initialSize = Book.findAll().size() + assert initialSize == 0 +} + +When(~'^I upload the books of "([^"]*)"$') { filename -> + initialSize = Book.findAll().size() + BookTestDataAndOperations.uploadBook(filename) + finalSize = Book.findAll().size() + assert initialSize < finalSize +} + +Then(~'^the system has all the books of the xml file$') { -> + assert Book.findByTitle("Proceedings of the IV Brazilian Symposium on Programming Languages") != null + assert Book.findByTitle("Testing Techniques in Software Engineering") != null + assert Book.findByTitle("Proceedings of the XXIII Brazilian Symposium on Software Engineering") != null + assert Book.findByTitle("Anais da IV Conferência Latina-Americana em Linguagens de Padrões para Programação (SugarLoafPLoP 2004)") != null + assert Book.findByTitle("AOSD 2011 Proceedings and Companion Material") != null +} + +Given(~'^I am at the Book Page$') { -> + to LoginPage + at LoginPage + page.fillLoginData("admin", "adminadmin") + at PublicationsPage + to BookPage +} + +When(~'^I go to new book page$') { -> + to BookPage + page.selectNewBook() +} + +And(~'^I try to create a book named "([^"]*)" with filename "([^"]*)"$') { String title, String filename -> + selectNewBookInBookPage() + page.fillBookDetails(BookTestDataAndOperations.path() + filename, title) + page.selectCreateBook() +} + +Then(~'^the book "([^"]*)" was stored by the system$') { String title -> + book = Book.findByTitle(title) + assert book != null + to BookPage + at BookPage +} + +Given(~'^I am at the book page'){-> + to BookPage + at BookPage +} +And(~'^the book "([^"]*)" is stored in the system with file name "([^"]*)"$') { String title, String filename -> + BookTestDataAndOperations.createBook(title, filename) + book = Book.findByTitle(title) + assert BookTestDataAndOperations.bookCompatibleTo(book, title) +} +When(~'^I select the download button$') { -> + at BookPage + page.downloadFile() +} + +Then(~'^the download the file named "([^"]*) is properly filed"$') { String filename -> + at BookPage + assert page.downloadFile(book, title) +} + +def checkIfExists(String title) { + book = Book.findByTitle(title) + assert book == null +<<<<<<< HEAD +} + +def createAndCheckBookOnBrowser(String title, String filename) { + page.fillBookDetails(title, filename) + page.clickSaveBook() + book = Book.findByTitle(title) + assert book != null +} + +def downloadFile(String filename){ + return +======= +>>>>>>> droa +} \ No newline at end of file diff --git a/test/cucumber/steps/CommonSteps.groovy b/test/cucumber/steps/CommonSteps.groovy index 0c570ea2..f021cfaa 100644 --- a/test/cucumber/steps/CommonSteps.groovy +++ b/test/cucumber/steps/CommonSteps.groovy @@ -5,6 +5,13 @@ import static cucumber.api.groovy.EN.And import static cucumber.api.groovy.EN.Given import static cucumber.api.groovy.EN.When +Given(~'I am logged in as admin$') {-> + to LoginPage + at LoginPage + page.fillLoginData("admin", "adminadmin") + at PublicationsPage +} + Given(~'^I am at the publications menu$') {-> to LoginPage at LoginPage diff --git a/test/cucumber/steps/DissertacaoSteps.groovy b/test/cucumber/steps/DissertacaoSteps.groovy index 03cd3324..1d30dfd8 100644 --- a/test/cucumber/steps/DissertacaoSteps.groovy +++ b/test/cucumber/steps/DissertacaoSteps.groovy @@ -71,12 +71,24 @@ When(~'^I create the dissertation "([^"]*)" with file name "([^"]*)" and school TestDataDissertacao.createDissertacao(title, filename, school) } +Then(~'^the system will store "([^"]*)" with the file "([^"]*)"$'){ String title, fileName -> + dissertation = Dissertacao.findByTitle(title) + dissertation2 = Dissertacao.findByFile(fileName) + assert dissertation != null + assert dissertation == dissertation2 +} + Then(~'^the dissertation "([^"]*)" is properly stored by the system$') { String title -> dissertation = Dissertacao.findByTitle(title) assert dissertation != null } +Then(~'^the dissertation "([^"]*)" is not properly stored by the system$') { String title -> + dissertation = Dissertacao.findByTitle(title) + assert dissertation == null +} + Then(~'^the dissertation "([^"]*)" is not stored twice$') { String title -> dissertations = Dissertacao.findAllByTitle(title) assert dissertations.size() == 1 @@ -101,6 +113,13 @@ Then(~'^the dissertation "([^"]*)" is properly updated by the system$') { String assert article == null } +Then(~'^the dissertation "([^"]*)" is properly updated by the system to "([^"]*)"$') { String title, newTitle -> + def article = Dissertacao.findByTitle(title) + def article2 = Dissertacao.findByTitle(newTitle) + assert article == null + assert article2 != null +} + When(~'^I select the upload button at the dissertation page$') {-> at DissertationPage page.uploadWithoutFile() @@ -109,19 +128,15 @@ 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 - inicialSize = Dissertacao.findAll().size() - TestDataDissertacao.uploadDissertacao(path) - finalSize = Dissertacao.findAll().size() - assert inicialSize < finalSize - //para funcionar é necessario que tenha um FilePath válido - // não consegui fazer de uma maneira que todos os passos sejam independentes -} -Then(~'the system has more dissertations now$') {-> - finalSize = Dissertacao.findAll().size() - +// esse método tinha sido complicado ao extremo. Como o cenário que eu tinha escolhido havia sido duplicado, +// resolvi, pelo menos, refazer este método para que ele fosse simplificado. +// #if($UploadDissertationWithAFile) +When(~'^I upload a new dissertation "([^"]*)" with title "([^"]*)"$') { filename, title -> + TestDataDissertacao.createDissertacao(title, filename, "UFPE") + dissertacao = TestDataDissertacao.findByTitle(title) + assert dissertacao != null } +// #end Given(~'^the system has some dissertation stored$'){-> size = Dissertacao.findAll().size() @@ -129,17 +144,6 @@ Given(~'^the system has some dissertation stored$'){-> } - -When(~'^I upload a new dissertation "([^"]*)" with title "([^"]*)"$') { filename, String title -> - String path = new File(".").getCanonicalPath() + File.separator + "test" + File.separator + "functional" + File.separator + "steps" + File.separator + filename - inicialSize = Dissertacao.findAll().size() - TestDataDissertacao.uploadDissertacao(path) - finalSize = Dissertacao.findAll().size() - assert inicialSize at DissertationCreate assert TestDataAndOperationsPublication.containsUser(page.selectedMembers()) diff --git a/test/cucumber/steps/DissertacaoSteps.groovy.orig b/test/cucumber/steps/DissertacaoSteps.groovy.orig new file mode 100644 index 00000000..a3589fda --- /dev/null +++ b/test/cucumber/steps/DissertacaoSteps.groovy.orig @@ -0,0 +1,179 @@ +import pages.DissertationCreate +import pages.DissertationEditPage +import pages.DissertationPage +import pages.DissertationShowPage +import rgms.authentication.User +import rgms.publication.Dissertacao +import steps.TestDataDissertacao +import steps.TestDataAndOperationsPublication + +import static cucumber.api.groovy.EN.* + + +When(~'^I select the new dissertation option at the dissertation page$') {-> + at DissertationPage + page.selectNewArticle() +} + +When(~'^I cant add the dissertation without a file$') {-> + at DissertationCreate + page.fillDissertationDetailsWithoutFile() +} + +When(~'^I can add the dissertation with a file "([^"]*)"$'){ String filename-> + at DissertationCreate + def path = new File(".").getCanonicalPath() + File.separator + "test" + File.separator + "files" + File.separator + filename + page.fillDissertationDetailsWithFile(path) +} +Then((~'^the system has a dissertation entitled "([^"]*)"$')){ String title-> + article = Dissertacao.findByTitle(title) + assert article != null +} + + + +When(~'^I select "([^"]*)" at the dissertation page$') { String title -> + at DissertationPage + page.selectDissertation(title) +} + +When(~'^I click on edit$') {-> + at DissertationShowPage + page.editDissertation() +} + +When(~'^I delete "([^"]*)"$') { String title -> + TestDataDissertacao.removeDissertacao(title) +} + +Then(~'^the school name is "([^"]*)"$') { String name -> + page.nameIs(name) +} + +When(~'^I edit the school to "([^"]*)"$') { String school -> + at DissertationEditPage + page.editSchool(school) +} + +Given(~'^the system has no dissertation entitled "([^"]*)"$') { String title -> + article = Dissertacao.findByTitle(title) + assert article == null +} + +Given(~'^the dissertation "([^"]*)" is stored in the system with file name "([^"]*)"$') { String title, filename -> + TestDataDissertacao.createDissertacao(title, filename, "UFPE") + article = Dissertacao.findByTitle(title) + assert article != null +} + + +When(~'^I create the dissertation "([^"]*)" with file name "([^"]*)" and school "([^"]*)"$') { String title, filename, school -> + TestDataDissertacao.createDissertacao(title, filename, school) +} + +Then(~'^the system will store "([^"]*)" with the file "([^"]*)"$'){ String title, fileName -> + dissertation = Dissertacao.findByTitle(title) + dissertation2 = Dissertacao.findByFile(fileName) + assert dissertation != null + assert dissertation == dissertation2 +} + + +Then(~'^the dissertation "([^"]*)" is properly stored by the system$') { String title -> + dissertation = Dissertacao.findByTitle(title) + assert dissertation != null +} + +Then(~'^the dissertation "([^"]*)" is not properly stored by the system$') { String title -> + dissertation = Dissertacao.findByTitle(title) + assert dissertation == null +} + +Then(~'^the dissertation "([^"]*)" is not stored twice$') { String title -> + dissertations = Dissertacao.findAllByTitle(title) + assert dissertations.size() == 1 + //A propriedade title de publication deveria estar unique:true, mas como n�o est�, este teste vai falhar +} + +When(~'^I create the dissertation "([^"]*)" with file name "([^"]*)" without school$') { String title, filename -> + TestDataDissertacao.createDissertacaoWithotSchool(title, filename); +} + +When(~'^I create the dissertation "([^"]*)" with file name "([^"]*)" without address$') { String title, filename -> + TestDataDissertacao.createDissertacaoWithoutAddress(title, filename); +} + +When(~'^I edit the dissertation title from "([^"]*)" to "([^"]*)"$') { String oldtitle, newtitle -> + def updatedDissertation = TestDataDissertacao.editDissertacao(oldtitle, newtitle) + assert updatedDissertation != null +} + +Then(~'^the dissertation "([^"]*)" is properly updated by the system$') { String title -> + def article = Dissertacao.findByTitle(title) + assert article == null +} + +Then(~'^the dissertation "([^"]*)" is properly updated by the system to "([^"]*)"$') { String title, newTitle -> + def article = Dissertacao.findByTitle(title) + def article2 = Dissertacao.findByTitle(newTitle) + assert article == null + assert article2 != nullI +} + +When(~'^I select the upload button at the dissertation page$') {-> + at DissertationPage + page.uploadWithoutFile() +} +Then(~'^I\'m still on dissertation page$') {-> + at DissertationPage +} +<<<<<<< HEAD + +// esse método tinha sido complicado ao extremo. Como o cenário que eu tinha escolhido havia sido duplicado, +// resolvi, pelo menos, refazer este método para que ele fosse simplificado. +// #if($UploadDissertationWithAFile) +When(~'^I upload a new dissertation "([^"]*)" with title "([^"]*)"$') { filename, title -> + TestDataDissertacao.createDissertacao(title, filename, "UFPE") + dissertacao = TestDataDissertacao.findByTitle(title) + assert dissertacao != null +======= +// #if($UploadDissertationWithAFile) +When(~'^I upload a new dissertation "([^"]*)" with title "([^"]*)"$') { filename -> + String path = new File(".").getCanonicalPath() + File.separator + "test" + File.separator + "functional" + File.separator + "steps" + File.separator + filename + inicialSize = Dissertacao.findAll().size() + TestDataDissertacao.uploadDissertacao(path) + finalSize = Dissertacao.findAll().size() + assert inicialSize < finalSize + //para funcionar é necessario que tenha um FilePath válido + // não consegui fazer de uma maneira que todos os passos sejam independentes +} + +Then(~'the system will store "([^"]*)" with the file "([^"]*)"$') {String filename, title-> + TestDataDissertacao.createDissertacao(title, filename, "UFPE") +>>>>>>> droa +} +// #end + +Given(~'^the system has some dissertation stored$'){-> + size = Dissertacao.findAll().size() + assert size > 0 + +} + +Then(~'^I see my user listed as an author member of dissertation by default$') {-> + at DissertationCreate + assert TestDataAndOperationsPublication.containsUser(page.selectedMembers()) +} + +Then(~'^I see my school name as school of dissertation by default$') {-> + at DissertationCreate + userData = User.findByUsername('admin')?.author?.university + assert page.currentSchool() == userData +} + +Given(~'^the system has no dissertation stored$') {-> + intialSize = Dissertacao.findAll().size() + assert intialSize == 0 +} + + diff --git a/test/cucumber/steps/FerramentaSteps.groovy b/test/cucumber/steps/FerramentaSteps.groovy index d19739b9..8d7fa13c 100644 --- a/test/cucumber/steps/FerramentaSteps.groovy +++ b/test/cucumber/steps/FerramentaSteps.groovy @@ -1,8 +1,11 @@ +import pages.PublicationsPage import pages.ferramenta.* import rgms.publication.Ferramenta import steps.FerramentaTestDataAndOperations import steps.TestDataAndOperationsPublication +import java.awt.Menu + import static cucumber.api.groovy.EN.* // new ferramenta without website @@ -17,6 +20,14 @@ Then(~'^the ferramenta "([^"]*)" is not stored$') { String title -> def tool = Ferramenta.findByTitle(title) assert tool == null } +Then(~'^the ferramenta "([^"]*)" is stored$') { String title -> + def tool = Ferramenta.findByTitle(title) + assert tool != null +} + +When(~'^I create the ferramenta "([^"]*)" with file name "([^"]*)" with website "([^"]*)"$') { String title, String filename, String website -> + FerramentaTestDataAndOperations.createFerramentaWeb(title, filename, website) +} // duplicate ferramenta Given(~'^the ferramenta "([^"]*)" is stored in the system with file name "([^"]*)"$') { String title, String filename -> @@ -101,19 +112,44 @@ And(~'^I click on Criar button$') {-> at FerramentaCreatePage page.clickCreateFerramenta() } + +Given(~'^I am at the ferramenta page$') {-> + to FerramentaPage + at FerramentaPage +} + Then(~'^I am still on create new ferramenta page$') {-> at FerramentaCreatePage } + And(~'^the ferramenta is not displayed in the ferramentas list page$') {-> to FerramentaPage at FerramentaPage - page.checkAnyFerramentaAtList() } -// upload dissertation without a file +// upload ferramenta without a file +// #if($UploadFerramentaWithoutAFile) +Given(~'^I am at publications menu$'){-> + to PublicationsPage + at PublicationsPage +} + +When(~'^I select the upload button at the ferramenta page without attaching a file$'){-> + to FerramentaPage + at FerramentaPage + page.click("Upload") +} + +Then(~'^the ferramenta wont be inserted into the system$') {-> + to FerramentaPage + at FerramentaPage +} +// #end + And(~'^I select the upload button at the ferramenta page$') {-> - // Express the Regexp above with the code you wish you had + } + Then(~'^I am still on ferramenta page$') {-> at FerramentaPage } diff --git a/test/cucumber/steps/FunderSteps.groovy b/test/cucumber/steps/FunderSteps.groovy index 255232e7..8963ee1d 100644 --- a/test/cucumber/steps/FunderSteps.groovy +++ b/test/cucumber/steps/FunderSteps.groovy @@ -48,11 +48,27 @@ Given(~'^I am at the create funder page$'){ -> goToFunderCreatePage() } -Then(~'^I fill the funder code with "([^"]*)"$'){ String code -> - fillCodefield(code) - clickSave() +//remove funder web +Given(~'^I am the funder page$') { -> + goToFunderCreatePage() +} +And(~'^has funder in the list with code "([^"]*)"$') { String code-> + if(Funder.count() == 0){ + FunderTestDataAndOperations.createFunderWithCode(code) + } + funder = Funder.findByCode(code) + assert funder != null +} +When(~'^I select the funder with code "([^"]*)"$'){String code -> + funder = Funder.findByCode(code) + assert funder != null +} +Then(~'^the funder with code "([^"]*)" is properly removed by the click on "remove" button$') { String code -> + funder = Funder.findByCode(code) + funder.delete() } +//---------------------------------------- private void checkIfFunderExists(String code){ funder = Funder.findByCode(code) diff --git a/test/cucumber/steps/MemberSteps.groovy b/test/cucumber/steps/MemberSteps.groovy index 210c1aa6..7cd5b673 100644 --- a/test/cucumber/steps/MemberSteps.groovy +++ b/test/cucumber/steps/MemberSteps.groovy @@ -22,6 +22,10 @@ When(~'^I create a member with username, phone "([^"]*)" "([^"]*)"$') { String u MemberTestDataAndOperations.createMember(username, phone) } +When(~'^I create a member with username "([^"]*)" with a invalid mail server "([^"]*)"$') { String username, mail -> + MemberTestDataAndOperations.createMemberWithEmail(username, mail) +} + Then(~'^the member with username "([^"]*)" is properly stored by the system$') { String username -> user = User.findByUsername(username); member = user?.author @@ -29,6 +33,13 @@ Then(~'^the member with username "([^"]*)" is properly stored by the system$') { assert member != null } +Then(~'^the member with username "([^"]*)" is not properly stored by the system$') { String username -> + user = User.findByUsername(username); + member = user?.author + //assert TestDataAndOperations.memberCompatibleTo(member, username) + assert member == null +} + Then(~'^the system has no member with a username "([^"]*)"$') { String username -> user = User.findByUsername(username); member = user?.author @@ -191,4 +202,29 @@ When(~'^I try to create the member "([^"]*)" with email "([^"]*)"$') { String na MemberTestDataAndOperations.createMemberWithEmail(name, email) //member = Member.findByEmail(email) //assert member.name == name -} \ No newline at end of file +} + +// #if($NewMemberWithABlankUsername) +Given(~'^the system without the member "([^*])"$'){String blank-> + member = MemberTestDataAndOperations.findByUsername("") + assert member == null +} + +When(~'^I create a member with no username and phone "([^"]*)"$') {String phone -> + MemberTestDataAndOperations.createMember("", phone) +} + +Then(~'^the new member wont be inserted$'){-> + member = Member.findByUsername("") + + if(member != null) { + MemberTestDataAndOperations.deleteMember("") + } +} +// #end + +// #if($DeleteInexistentMember) +Then(~'^the system will throw a message error "([^"]*)"$'){String error -> + page.throwError(error) +} +// #end \ No newline at end of file diff --git a/test/cucumber/steps/NewsSteps.groovy b/test/cucumber/steps/NewsSteps.groovy index fa07136f..999f02dc 100644 --- a/test/cucumber/steps/NewsSteps.groovy +++ b/test/cucumber/steps/NewsSteps.groovy @@ -154,6 +154,11 @@ Given(~'^the system has no stored news$') { -> assert News.count() == 0 } +Given(~'^the system has some stored news$') { -> + News.withTransaction { status -> News.findAll().each { n -> n.delete() } } + assert News.count() > 0 +} + //#if ($Report && $HTML) And (~'^I select the option Export to HTML at the News list page$'){ -> at NewsPage @@ -187,14 +192,6 @@ Then(~'^I can fill the news details$') { -> assert NewsTestDataAndOperations.checkExistingNewsByDescription("essa eh a descricao") } -When(~'^I try to create a news with description "([^"]*)" and date "([^"]*)" for "([^"]*)" research group$') { String description, String date, String group -> - if(NewsTestDataAndOperations.checkValidDate(date)) { - Date dateAsDateObj = Date.parse("dd-MM-yyyy", date) - def researchGroup = ResearchGroup.findByName(group) - NewsTestDataAndOperations.createNews(description, dateAsDateObj, researchGroup) - } -} - Then(~'^the news with description "([^"]*)", date "([^"]*)" and "([^"]*)" research group is not stored by the system because it is invalid$') { String description, String date, String group -> news = findNewsByDescriptionDateAndGroup(description, date, group) assert news == null diff --git a/test/cucumber/steps/OrientationSteps.groovy b/test/cucumber/steps/OrientationSteps.groovy index 3bec0229..683716de 100644 --- a/test/cucumber/steps/OrientationSteps.groovy +++ b/test/cucumber/steps/OrientationSteps.groovy @@ -30,6 +30,12 @@ Then(~'^the orientation "([^"]*)" is properly stored by the system$') { String t checkIfOrientationExists(title) } +Then(~'^the duplicate orientation "([^"]*)" is not properly stored by the system$') { String title -> + checkIfOrientationExists(title) + orientation = OrientationTestDataAndOperations.findOrientationByTitle(title) + assert orientation != null +} + //delete Given(~'^the system has an orientation entitled "([^"]*)" supervised by someone$') { String title -> OrientationTestDataAndOperations.createOrientation(title) diff --git a/test/cucumber/steps/RecordSteps.groovy b/test/cucumber/steps/RecordSteps.groovy index 368764f0..cae0a393 100644 --- a/test/cucumber/steps/RecordSteps.groovy +++ b/test/cucumber/steps/RecordSteps.groovy @@ -118,3 +118,36 @@ When(~'^I click to remove the record$') {-> at RecordVisualizePage page.removeRecord() } + +// #if($SuccessfullyEditAStatus) +Given(~'^Given a record with status "([^"]*)"$') {status -> + to ProfilePage + at ProfilePage + record = RecordTestDataAndOperations.findRecordByStatus(status) + assert record != null +} + +When(~'^I fill the field of status with "([^"]*)"$'){status -> + RecordTestDataAndOperations.updateRecord(status, Date.getTimeString()) +} + +When(~'^confirm the edit$') {-> + page.select("Confirm") +} + +Then(~'^the record will now show "([^"]*)"$'){status -> + record = RecordTestDataAndOperations.findRecordByStatus(status) + assert record != null +} +// #end + +// #if($CancelTheEditOfAStatus) +When(~'^the member press the button cancel$') {-> + page.select("Cancel") +} + +Then(~'^the record wont save the "([^"]*)"$') {status -> + record = RecordTestDataAndOperations.findRecordByStatus(status) + assert record == null +} +// #end \ No newline at end of file diff --git a/test/cucumber/steps/RecordSteps.groovy.orig b/test/cucumber/steps/RecordSteps.groovy.orig new file mode 100644 index 00000000..e89733ef --- /dev/null +++ b/test/cucumber/steps/RecordSteps.groovy.orig @@ -0,0 +1,160 @@ +import rgms.member.Record +import rgms.member.Member +import steps.RecordTestDataAndOperations +import pages.LoginPage +import pages.PublicationsPage +import pages.record.* +import static cucumber.api.groovy.EN.* + +Given(~'^the system has only one record with status "([^"]*)"$') { String status -> + RecordTestDataAndOperations.insertsRecord(status) + def records = Record.findAllByStatus_H(status) + assert records.size() == 1 && records.first() != null +} + +Given(~'^the record with status "([^"]*)" is not associated to a member$') { String status -> + assert RecordTestDataAndOperations.recordIsAssociated(status, false) +} + +Given(~'^the record with status "([^"]*)" is associated to a member$') { String status -> + assert RecordTestDataAndOperations.recordIsAssociated(status) +} + +When(~'^I remove the record with status "([^"]*)"$') { String status -> + def id = Record.findByStatus_H(status).id + RecordTestDataAndOperations.deleteRecord(id) +} + +Then(~'^the record with status "([^"]*)" is properly removed by the system$') { String status -> + def record = Record.findByStatus_H(status) + assert record == null +} + +Then(~'^the record with status "([^"]*)" is not removed by the system$') { String status -> + def record = Record.findByStatus_H(status) + assert record != null +} + +Given(~'^the system has only one record with status "([^"]*)" and this record has a null end date$') { String status -> + def records = Record.findAllByStatus_H(status) + def record = records.first() + assert records.size() == 1 && record != null && record.end == null +} + +When(~'^I update the record with status "([^"]*)" with an end date "([^"]*)"$') { String status, String end_str -> + RecordTestDataAndOperations.updateRecord(status, end_str) +} + +Then(~'^the record with status "([^"]*)" has end date "([^"]*)"$') { String status, String end_str -> + def record = Record.findByStatus_H(status) + assert record.end.format("dd/mm/yyyy").equals(end_str) +} + +When(~'^I create the record with status "([^"]*)"$') { String status -> + RecordTestDataAndOperations.createRecord(status) +} + +Then(~'^the record with status "([^"]*)" is properly stored and the system has two records with this status$') { String status -> + def records = Record.findAllByStatus_H(status) + assert records.size() == 2 && records.get(0).status_H == status && records.get(1).status_H == status +} + +Given(~'^I am logged$') { -> + to LoginPage + at LoginPage + page.fillLoginData("admin", "adminadmin") +} + +When(~'^I click the record with status "([^"]*)" at the record list$') { String status -> + at RecordPage + page.visualizeRecord(status) +} + +Then(~'^I am still at the visualize page of the record with status "([^"]*)"$') { String status -> + at RecordVisualizePage + page.checkRecordDetails(status) +} + +When(~'^I click the edit button of the record$') { + -> + at RecordVisualizePage + page.editRecord() +} + +When(~'^I set the status to "([^"]*)" and I click the save button$') { String status -> + at RecordEditPage + page.changeRecordDetails(status) +} + +Then(~'^I am at the edit page of the record with status "([^"]*)"$') { String status -> + at RecordEditPage + assert page.statusIsEmpty() +} + +Given(~'^I am at record list$') {-> + at PublicationsPage + to RecordPage +} + +When(~'^I click the create record option$') {-> + at RecordPage + page.selectNewRecord() +} + +Then(~'^I can fill the record details$') {-> + at RecordCreatePage + page.fillRecordDetails() +} + +Given(~'^I am at the visualize page of the record with status "([^"]*)"$') { + String status -> + at PublicationsPage + to RecordPage + page.visualizeRecord(status) + at RecordVisualizePage +} + +When(~'^I click to remove the record$') {-> + at RecordVisualizePage + page.removeRecord() +} + +// #if($SuccessfullyEditAStatus) +Given(~'^I am logged at my profile page$'){-> + to LoginPage + at LoginPage + page.fillLoginData("admin", "adminadmin") + to ProfilePage + at ProfilePage +} +When(~'^I fill the field of status with "([^"]*)"$'){String status-> + page.fillRecordDetails(status) +} + +Then(~'^my profile will now show my new status$'){-> + to ProfilePage +} +// #end + +// #if($CancelTheEditOfAStatus) +Given(~'^a field of status filled with "([^"]*)"$') {String status -> + to ProfilePage + at ProfilePage + page.fillRecordDetails(status) +} + +When(~'^the member press the button cancel$') {-> + page.click("Cancel") +} + +<<<<<<< HEAD +Then(~'^the record wont save the "([^"]*)"$') {status -> + record = RecordTestDataAndOperations.findRecordByStatus(status) + assert record == null +======= +Then(~'^nothing will be posted$') {-> + to ProfilePage + at ProfilePage +>>>>>>> droa +} +// #end \ No newline at end of file diff --git a/test/cucumber/steps/ThesisSteps.groovy b/test/cucumber/steps/ThesisSteps.groovy index 90129b91..6dcf77bb 100644 --- a/test/cucumber/steps/ThesisSteps.groovy +++ b/test/cucumber/steps/ThesisSteps.groovy @@ -3,6 +3,7 @@ import pages.LoginPage import pages.PublicationsPage import pages.ThesisPage import pages.thesis.ThesisCreatePage +import pages.thesis.ThesisEditPage import pages.thesis.ThesisShowPage import rgms.authentication.User import rgms.publication.Tese @@ -12,15 +13,13 @@ import steps.ThesisTestDataAndOperations import static cucumber.api.groovy.EN.* Given(~'^The system has no thesis entitled "([^"]*)"$') { String title -> - article = Tese.findByTitle(title) - assert article == null + thesisDoNotExists(title) } 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 + thesisDoExists(title) } When(~'^I create the thesis "([^"]*)" with file name "([^"]*)" and school "([^"]*)"$') { @@ -28,20 +27,80 @@ When(~'^I create the thesis "([^"]*)" with file name "([^"]*)" and school "([^"] ThesisTestDataAndOperations.createTese(title, filename, school) } +/** + * @author rff2 + * edit existing thesis test web + * BEGIN + */ +And(~'^I modify the field School to "([^"]*)"$') { + String school_name -> + at ThesisEditPage + page.fillThesisSchool(school_name) + page.saveModifications() +} + +When(~'^I select to edit thesis "([^"]*)" in resulting list$') { title -> + at ThesisPage + page.selectViewThesis(title) + page.select() + at ThesisEditPage + +} + +Then(~'^The thesis "([^"]*)" now has "([^"]*)" in the school field$') { + String title, String school_name -> + tese = Tese.findByTitle(title) + assert tese.school == school_name +} +/** + * @author rff2 + * edit existing thesis test web + * END + */ + +/** + * @author rff2 + * filter Thesis List + * BEGIN + */ +When(~'^The user adds a thesis entitled "([^"]*)"$') { + title -> + at ThesisPage + page.selectNewThesis() + at ThesisCreatePage + + def absolutePath = ServletContextHolder.servletContext.getRealPath("/test/functional/steps/NewthesisGUI.txt") + absolutePath = absolutePath.replace("\\", "/").replaceAll("/web-app", "") + page.fillThesisDetails(title, 01, 01, 1995, "UFPE", "Recife", absolutePath) + +} + +Then(~'^The thesis "([^"]*)" is properly stored after "([^"]*)"$') { + String title1, String title2 -> + at ThesisPage + thesis1 = Tese.findByTitle(title1) + thesis2 = Tese.findByTitle(title2) + assert thesis1 == page.getRow(0) + assert thesis2 == page.getRow(1) +} + +/** + * @author rff2 + * filter Thesis List + * END + */ + Then(~'^The thesis "([^"]*)" is not stored twice$') { String title -> theses = Tese.findAllByTitle(title) assert theses.size() == 1 } Then(~'^The thesis "([^"]*)" is properly stored by the system$') { String title -> - thesis = Tese.findByTitle(title) - assert thesis != null + thesisDoExists(title) } Given(~'^I am at the create thesis page$') { -> - to LoginPage - at LoginPage - page.fillLoginData("admin", "adminadmin") + Login() to ThesisCreatePage at ThesisCreatePage } @@ -107,8 +166,7 @@ Given(~'^I am at the thesis page and the thesis "([^"]*)" is stored in the syste absolutePath = absolutePath.replace("\\", "/").replaceAll("/web-app", "") page.fillThesisDetails(title, "10", "8", "1998", "UFPE", "Recife", absolutePath) page.selectCreateThesis() - tese = Tese.findByTitle(title) - assert tese != null + thesisDoExists(title) at ThesisShowPage } @@ -139,8 +197,7 @@ Then(~'^the thesis "([^"]*)" is removed from the system$') { title -> // #6 Given(~'^the system has thesis entitled "([^"]*)"$') { title -> ThesisTestDataAndOperations.createTese(title, 'teste.txt', 'UFPE') - thesis = Tese.findByTitle(title) - assert thesis != null + thesisDoExists(title) } When(~'^I delete the thesis "([^"]*)"$') { title -> @@ -148,8 +205,7 @@ When(~'^I delete the thesis "([^"]*)"$') { title -> } Then(~'^the thesis "([^"]*)" is properly removed by the system$') { title -> - tese = Tese.findByTitle(title) - assert tese == null + thesisDoNotExists(title) } //Scenario: order thesis list by date @@ -275,6 +331,10 @@ def thesisDoNotExists(title) { assert tese == null } +def thesisDoExists(title) { + tese = Tese.findByTitle(title) + assert tese != null +} def Login() { to LoginPage diff --git a/test/files/NGS.pdf b/test/files/NGS.pdf new file mode 100644 index 00000000..63e26fad Binary files /dev/null and b/test/files/NGS.pdf differ diff --git a/test/files/NGS2.pdf b/test/files/NGS2.pdf new file mode 100644 index 00000000..63e26fad Binary files /dev/null and b/test/files/NGS2.pdf differ diff --git a/test/functional/pages/BookCreatePage.groovy b/test/functional/pages/BookCreatePage.groovy index b4768335..958744f7 100644 --- a/test/functional/pages/BookCreatePage.groovy +++ b/test/functional/pages/BookCreatePage.groovy @@ -27,20 +27,21 @@ class BookCreatePage extends FormPage { } } - def fillBookDetails(title, filename) { - fillTitle(title) + def fillBookDetails() { + def path = new File(".").getCanonicalPath() + File.separator + "test" + File.separator + "files" + File.separator + "NGS.pdf" + fillBookDetails(path, "Next Generation Software Product Line Engineering") + } + + def fillBookDetails(filename, title) { + $("form").title = title + $("form").file = filename $("form").publisher = "Person" $("form").volume = 1 $("form").pages = "20" - $("form").file = new File(".").getCanonicalPath() + File.separator + "test" + File.separator + "functional" + File.separator + "steps" + File.separator + filename } - def clickSaveBook() { - $("form").create().click() + def selectCreateBook() { + $("input", name: "create").click() } - def fillTitle(title) { - $("form").title = title - clickSaveBook() - } } \ No newline at end of file diff --git a/test/functional/pages/BookEditPage.groovy b/test/functional/pages/BookEditPage.groovy new file mode 100644 index 00000000..1d5c0ee4 --- /dev/null +++ b/test/functional/pages/BookEditPage.groovy @@ -0,0 +1,31 @@ +package pages + +import geb.Page + +/** + * Created by Dickster on 21/01/2015. + */ +class BookEditPage extends Page { + static url = "book/edit/1" + + static at = { + GetPageTitle gp = new GetPageTitle() + def currentBook = gp.msg("default.book.label") + def currentTitle = gp.msg("default.edit.label", [currentBook]) + + title ==~ currentTitle + } + + def edit(String newTitle, newFile) { + $("form").title = newTitle + $("form").file = newFile + } + + def select(String s) { + $("form").find("input", value: s).click() + } + + def doEdit() { + $("form").find("input", name: "_action_update").click() + } +} diff --git a/test/functional/pages/BookPage.groovy b/test/functional/pages/BookPage.groovy index 2c658d49..92a525ca 100644 --- a/test/functional/pages/BookPage.groovy +++ b/test/functional/pages/BookPage.groovy @@ -22,11 +22,22 @@ class BookPage extends Page { title ==~ currentTitle } - static content = { - - } + /** + * @author droa + * BEGIN + */ def selectNewBook() { $('a.create').click() } + + def selectBook(String 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() + } + + /* END */ } \ No newline at end of file diff --git a/test/functional/pages/BookShowPage.groovy b/test/functional/pages/BookShowPage.groovy new file mode 100644 index 00000000..891fd374 --- /dev/null +++ b/test/functional/pages/BookShowPage.groovy @@ -0,0 +1,31 @@ +package pages + +import geb.Page + +/** + * Created by droa on 22/11/2014. + */ +class BookShowPage extends Page { + static url = "book/show/1" + + static at = { + + GetPageTitle gp = new GetPageTitle() + def currentBook = gp.msg("default.book.label") + def currentTitle = gp.msg("default.show.label", [currentBook]) + + title ==~ currentTitle + } + + def select(String e, v) { + if (v == 'delete') { + assert withConfirm(true) { $("form").find(e, class: v).click() } + } else { + $("form").find(e, class: v).click() + } + } + + def clickOnTwitteIt(String login, pw) { + $("#button_twitter").click() + } +} diff --git a/test/functional/pages/thesis/ThesisEditPage.groovy b/test/functional/pages/thesis/ThesisEditPage.groovy index 75da2a0b..1758e85c 100644 --- a/test/functional/pages/thesis/ThesisEditPage.groovy +++ b/test/functional/pages/thesis/ThesisEditPage.groovy @@ -29,4 +29,12 @@ class ThesisEditPage extends Page { def select(String s) { $("form").find("input", value: s).click() } + + def fillThesisSchool(school_name) { + $("form").school = school_name + } + + def saveModifications() { + $("form").find('input', class: 'save').click() + } } diff --git a/test/functional/steps/BookTestDataAndOperations.groovy b/test/functional/steps/BookTestDataAndOperations.groovy index a6a8f379..044deb2b 100644 --- a/test/functional/steps/BookTestDataAndOperations.groovy +++ b/test/functional/steps/BookTestDataAndOperations.groovy @@ -76,4 +76,9 @@ class BookTestDataAndOperations { } return compatible } + + static public def path(){ + return new File(".").getCanonicalPath() + File.separator + "test" + File.separator + "files" + File.separator + } + } diff --git a/test/functional/steps/FerramentaTestDataAndOperations.groovy b/test/functional/steps/FerramentaTestDataAndOperations.groovy index a9f8285b..eda9dde4 100644 --- a/test/functional/steps/FerramentaTestDataAndOperations.groovy +++ b/test/functional/steps/FerramentaTestDataAndOperations.groovy @@ -40,7 +40,6 @@ class FerramentaTestDataAndOperations { def cont = new FerramentaController() cont.params << ferramenta.properties cont.update() - def updatedferramenta = Ferramenta.findByTitle(newtitle) return updatedferramenta } @@ -52,22 +51,40 @@ class FerramentaTestDataAndOperations { cont.response.reset() } - static public void createFerramenta(String title, filename) { + static public void createFerramenta(String new_title, new_filename) { def cont = new FerramentaController() def date = new Date() - cont.params << findFerramentaByTitle(title) << [file: filename] - cont.request.setContent(new byte[1000]) // Could also vary the request content. + cont = find_and_set_content(cont, new_title, new_filename) + save_controller(cont) + } + + private static void save_controller(FerramentaController cont) { cont.create() cont.save() cont.response.reset() } + static public void createFerramentaWithWebsite(String new_title, new_filename, new_website) { + def cont = new FerramentaController() + def date = new Date() + cont = find_and_set_content(cont, new_title, new_filename) + cont.params << [website: new_website] + save_controller(cont) + } + + private static FerramentaController find_and_set_content(FerramentaController cont, String title, filename) { + cont.params << findFerramentaByTitle(title) << [file: filename] + cont.request.setContent(new byte[1000]) // Could also vary the request content. + return cont; + } + + static public void uploadFerramenta(filepath) { def cont = new XMLController() def xml = new File((String) filepath); def records = new XmlParser() cont.saveTools(records.parse(xml)); - cont.response.reset() + save_controller(cont); } static public Ferramenta getFerramenta(title){ diff --git a/test/functional/steps/MemberTestDataAndOperations.groovy b/test/functional/steps/MemberTestDataAndOperations.groovy index 01345ddb..347cf4d1 100644 --- a/test/functional/steps/MemberTestDataAndOperations.groovy +++ b/test/functional/steps/MemberTestDataAndOperations.groovy @@ -39,22 +39,37 @@ class MemberTestDataAndOperations { } } - static public void createMember(String username, String phone) { + static public void createMember(String new_username) { def cont = new MemberController() - if (phone.equals("")) { - cont.params << findByUsername(username) + cont.params << findByUsername(new_username) + save_controller(cont) + } + + static public void createMemberWithPhone(String new_username, String new_phone) { + def cont = new MemberController() + if (if_empty(new_phone)) { + cont.params << findByUsername(new_username) } else { - cont.params << [username: username, phone: phone] + cont.params << [username: new_username, phone: new_phone] } - cont.create() - cont.save() - cont.response.reset() + save_controller(cont) + } + + private static boolean if_empty(String text) { + text.equals("") } - //TODO evitar duplicação, depois de resolver toda a confusão conceitual entre user vs member - static public void createMemberWithEmail(String name, String email) { + static public void createMemberWithEmail(String new_username, String new_email) { def cont = new MemberController() - cont.params << findByName(name) << [email: email] + if (if_empty(new_email)) { + cont.params << findByUsername(new_username) + } else { + cont.params << [username: new_username, email: new_email] + } + save_controller(cont) + } + + private static void save_controller(MemberController cont) { cont.create() cont.save() cont.response.reset() @@ -65,17 +80,17 @@ class MemberTestDataAndOperations { def identificador = User.findByUsername(username)?.author?.id cont.params << [id: identificador] cont.request.setContent(new byte[1000]) // Could also vary the request content. - cont.delete() - cont.response.reset() + save_controller(cont) } - static public boolean containsMember(username) { + static public boolean containsMember(String username) { def cont = new MemberController() def result = cont.list().userMemberInstanceList - for (i in result) { - if (i.user.username == username && i.member != null) + for (userMember in result) { + if (userMember.user.username == username && userMember.member != null) return true; } return false; } + } diff --git a/test/functional/steps/TestDataAndOperations.groovy b/test/functional/steps/TestDataAndOperations.groovy index 34006453..09057619 100644 --- a/test/functional/steps/TestDataAndOperations.groovy +++ b/test/functional/steps/TestDataAndOperations.groovy @@ -100,20 +100,6 @@ class TestDataAndOperations { cont.response.reset() } - static public boolean conferenciaCompatibleTo(conferencia, title) { - def testConferencia = findConferenciaByTitle(title) - def compatible = false - if (testConferencia == null && conferencia == null) { - compatible = true - } else if (testConferencia != null && conferencia != null) { - compatible = true - testConferencia.each { key, data -> - compatible = compatible && (conferencia."$key" == data) - } - } - return compatible - } - static public void createArticle(String title, filename) { def cont = new PeriodicoController() def date = new Date() diff --git a/test/functional/steps/TestDataDissertacao.groovy b/test/functional/steps/TestDataDissertacao.groovy index a7e034fa..6556905e 100644 --- a/test/functional/steps/TestDataDissertacao.groovy +++ b/test/functional/steps/TestDataDissertacao.groovy @@ -5,6 +5,7 @@ import rgms.publication.* class TestDataDissertacao { + static dissertacoes = [] static public void createDissertacao(String title, filename, school) { def cont = new DissertacaoController() diff --git a/web-app/css/ui-lightness/images/Thumbs.db b/web-app/css/ui-lightness/images/Thumbs.db deleted file mode 100644 index 92d94cd9..00000000 Binary files a/web-app/css/ui-lightness/images/Thumbs.db and /dev/null differ diff --git a/web-app/images/Thumbs.db b/web-app/images/Thumbs.db deleted file mode 100644 index f378e0e1..00000000 Binary files a/web-app/images/Thumbs.db and /dev/null differ diff --git a/web-app/images/skin/Thumbs.db b/web-app/images/skin/Thumbs.db index 32b964cf..5806d85c 100644 Binary files a/web-app/images/skin/Thumbs.db and b/web-app/images/skin/Thumbs.db differ