This repository has been archived by the owner on Dec 27, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 21
MoveTopicPermissionsTest #61
Open
timisoreana
wants to merge
4
commits into
jtalks-org:master
Choose a base branch
from
timisoreana:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 2 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
115 changes: 115 additions & 0 deletions
115
...onal-tests-jcommune/src/test/java/org/jtalks/tests/jcommune/MoveTopicsPermissionTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
package org.jtalks.tests.jcommune; | ||
|
||
import org.jtalks.tests.jcommune.webdriver.JCommuneSeleniumConfig; | ||
import org.jtalks.tests.jcommune.webdriver.action.Branches; | ||
import org.jtalks.tests.jcommune.webdriver.action.Notifications; | ||
import org.jtalks.tests.jcommune.webdriver.action.Topics; | ||
import org.jtalks.tests.jcommune.webdriver.action.Users; | ||
import org.jtalks.tests.jcommune.webdriver.entity.branch.Branch; | ||
import org.jtalks.tests.jcommune.webdriver.entity.topic.CodeReview; | ||
import org.jtalks.tests.jcommune.webdriver.entity.topic.CodeReviewComment; | ||
import org.jtalks.tests.jcommune.webdriver.entity.topic.Question; | ||
import org.jtalks.tests.jcommune.webdriver.entity.topic.Topic; | ||
import org.jtalks.tests.jcommune.webdriver.entity.user.User; | ||
import org.jtalks.tests.jcommune.webdriver.exceptions.ValidationException; | ||
import org.jtalks.tests.jcommune.webdriver.page.TopicPage; | ||
import org.testng.Assert; | ||
import org.testng.annotations.BeforeMethod; | ||
import org.testng.annotations.Parameters; | ||
import org.testng.annotations.Test; | ||
|
||
import static org.apache.commons.lang.RandomStringUtils.randomAlphanumeric; | ||
import static org.jtalks.tests.jcommune.webdriver.JCommuneSeleniumConfig.driver; | ||
import static org.jtalks.tests.jcommune.webdriver.JCommuneSeleniumConfig.getAppUrl; | ||
import static org.jtalks.tests.jcommune.webdriver.page.Pages.mainPage; | ||
/** | ||
* @author timisoreana 23.03.2015 | ||
*/ | ||
public class MoveTopicsPermissionTest { | ||
|
||
|
||
@BeforeMethod(alwaysRun = false) | ||
@Parameters({"appUrl"}) | ||
public void setupCase(String appUrl) throws ValidationException { | ||
driver.get(appUrl); | ||
mainPage.logOutIfLoggedIn(driver); | ||
} | ||
|
||
@Test | ||
public void moveTopicToOtherBranch_ShouldPass() throws Exception { | ||
User user = Users.signUpAndSignIn(); | ||
Topic topic = Topics.createTopic(new Topic().withTopicStarter(user)).withBranch("Micro level"); | ||
Users.logout(); | ||
|
||
User userTopicMover = new User(); | ||
Users.signIn(userTopicMover); | ||
|
||
Topics.moveTopic(topic, "Classical Mechanics"); | ||
Assert.assertEquals("Classical Mechanics", topic.getBranch().getTitle()); | ||
} | ||
|
||
@Test | ||
public void userWithoutMoveTopicsPermissionAndWithVewTopic_MoveTopic_ShouldFail() throws Exception { | ||
User user = Users.signUpAndSignIn(); | ||
Topic topic = Topics.createTopic(new Topic().withTopicStarter(user)); | ||
|
||
User userWithoutMoveAndWithViewTopicPerm = Users.signUpAndSignIn(); | ||
Topics.moveByUser(topic, userWithoutMoveAndWithViewTopicPerm); | ||
} | ||
|
||
|
||
|
||
@Test | ||
public void userWithMoveTopicsAndWithoutViewTopic_MoveTopic_ShouldFail() throws Exception { | ||
User user = Users.signUpAndSignIn(); | ||
Topic topic = Topics.createTopic(new Topic().withTopicStarter(user)); | ||
|
||
User userWithMoveAndWithoutPerm = Users.signUpAndSignIn(); | ||
Topics.moveByUser(topic, userWithMoveAndWithoutPerm); | ||
} | ||
|
||
|
||
@Test | ||
public void userWithoutMoveTopicsAndWithoutViewTopic_MoveTopic_ShouldFail() throws Exception { | ||
|
||
User user = Users.signUpAndSignIn(); | ||
Topic topic = Topics.createTopic(new Topic().withTopicStarter(user)); | ||
|
||
User userWithoutMoveAndWithoutPerm = Users.signUpAndSignIn(); | ||
Topics.moveByUser(topic, userWithoutMoveAndWithoutPerm); | ||
} | ||
|
||
|
||
@Test | ||
public void anonymousUser_MoveTopic_ShouldFail() throws Exception { | ||
User user = Users.signUpAndSignIn(); | ||
Topic topic = Topics.createTopic(new Topic().withTopicStarter(user)); | ||
Users.logout(); | ||
|
||
Topics.moveByUser(topic, user); | ||
} | ||
|
||
@Test | ||
public void user_MoveCodeReviewTopic_ShouldPass() throws Exception { | ||
Users.signUpAndSignIn(); | ||
CodeReview codeReview = new CodeReview(); | ||
Topics.createCodeReview(codeReview); | ||
|
||
User user = Users.signUpAndSignIn(); | ||
Topics.moveByUser(codeReview, user); | ||
} | ||
|
||
@Test | ||
public void user_MoveQATopic_ShouldPass() throws Exception { | ||
User user = Users.signUpAndSignIn(); | ||
Question question = new Question(); | ||
Topics.createQuestion(question, user); | ||
Users.logout(); | ||
|
||
User mover = Users.signUpAndSignIn(); | ||
Topics.moveByUser(question, mover); | ||
} | ||
|
||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
jcommune-webdriver/src/main/java/org/jtalks/tests/jcommune/webdriver/entity/topic/QA.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package org.jtalks.tests.jcommune.webdriver.entity.topic; | ||
|
||
|
||
import com.google.common.base.Splitter; | ||
import org.jtalks.tests.jcommune.webdriver.entity.branch.Branch; | ||
import org.apache.commons.lang3.StringUtils; | ||
import java.util.List; | ||
|
||
import static org.apache.commons.lang3.RandomStringUtils.randomAlphanumeric; | ||
|
||
|
||
/** | ||
* JCommune QA representation | ||
*/ | ||
|
||
public class QA extends Topic { | ||
private String content = randomAlphanumeric(50); | ||
|
||
public QA() { | ||
} | ||
|
||
public QA(String title, String content) { | ||
this.withTitle(title); | ||
this.content = content; | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
...ne-webdriver/src/main/java/org/jtalks/tests/jcommune/webdriver/entity/topic/Question.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package org.jtalks.tests.jcommune.webdriver.entity.topic; | ||
|
||
|
||
import com.google.common.base.Splitter; | ||
import org.jtalks.tests.jcommune.webdriver.entity.branch.Branch; | ||
import org.apache.commons.lang3.StringUtils; | ||
import java.util.List; | ||
|
||
import static org.apache.commons.lang3.RandomStringUtils.randomAlphanumeric; | ||
|
||
|
||
/** | ||
* JCommune QA representation | ||
*/ | ||
|
||
public class Question extends Topic { | ||
private String content = randomAlphanumeric(50); | ||
|
||
public Question() { | ||
} | ||
|
||
public Question(String title, String content) { | ||
this.withTitle(title); | ||
this.content = content; | ||
} | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm.. as I've mentioned - content is already present in
Topic