Skip to content
This repository was archived by the owner on Dec 27, 2022. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
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);
}

}


Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ public void registrationValid_shouldPass() throws Exception {
Users.signUp(user);
}

@Test(expectedExceptions = ValidationException.class)
@Test(groups = "ui-tests", expectedExceptions = ValidationException.class,
expectedExceptionsMessageRegExp = SignUpPage.EMPTY_LOGIN_ERROR + SignUpPage.EMPTY_EMAIL_ERROR + SignUpPage.EMPTY_PASSWORD_ERROR )
public void dataEmpty_shouldFail() throws Exception {
UserForRegistration user = new UserForRegistration();
user.setUsername("");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,7 @@
import org.jtalks.tests.jcommune.assertion.Existence;
import org.jtalks.tests.jcommune.webdriver.JCommuneSeleniumConfig;
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.Post;
import org.jtalks.tests.jcommune.webdriver.entity.topic.Topic;
import org.jtalks.tests.jcommune.webdriver.entity.topic.*;
import org.jtalks.tests.jcommune.webdriver.entity.user.User;
import org.jtalks.tests.jcommune.webdriver.exceptions.CouldNotOpenPageException;
import org.jtalks.tests.jcommune.webdriver.exceptions.PermissionsDeniedException;
Expand Down Expand Up @@ -244,44 +241,28 @@ public static boolean isCreated(Topic topic) {
return actualTitle.equals(expectedTitle);
}

public static void editPost (Topic topic, Integer indexNumberOfPostInTopic) {
throw new UnsupportedOperationException();
}

public static void deleteByUser(Topic topic, User user) {
throw new UnsupportedOperationException();
}

public static void deleteTopic(Topic topic) {
throw new UnsupportedOperationException();
}

public static void moveTopic(Topic topic, String branchTitleWhereTopicMoves) {
public static void subscribe(Topic topic, User user) {
throw new UnsupportedOperationException();
}

public static void subscribe(Topic topic) {
throw new UnsupportedOperationException();
}

public static void unsubscribe(Topic topic) {
public static void moveByUser(Topic topic, User user) {
throw new UnsupportedOperationException();
}

public static void moveByUser(Topic topic, User user) {
public static void moveTopic(Topic topic, String branchTitleWhereTopicMoves) {
throw new UnsupportedOperationException();
}

public static void deleteAnswer(Topic topic, Post selectedPost) {
throw new UnsupportedOperationException();
}

public static void assertHasNewMessages(Topic newTopic, User userThatWantsToSeeNewMessages) {
throw new UnsupportedOperationException();
}

public static void assertHasNoNewMessages(Topic newTopic, User userThatWantsToSeeNewMessages) {
throw new UnsupportedOperationException();
}

// Code review methods
Expand All @@ -307,32 +288,12 @@ public static CodeReview createCodeReview(CodeReview codeReview)
return codeReview;
}

public static void leaveCodeReviewComment(CodeReview codeReview, CodeReviewComment codeReviewComment)
public static void leaveCodeReviewComment(CodeReviewComment codeReviewComment)
throws PermissionsDeniedException, ValidationException {
topicPage.clickLineInCodeReviewForComment(codeReviewComment.getCommentedLineNumber());
topicPage.fillCodeReviewCommentBody(codeReviewComment);
topicPage.clickAddCommentToCodeReviewButton();
assertCodeReviewFormValid();
}

public static void assertIsSubscribed(Topic topic){
throw new UnsupportedOperationException("To be implemented");
}

public static void editCodeReviewComment(CodeReview codeReview, CodeReviewComment codeReviewComment){
throw new UnsupportedOperationException("To be implemented");
}

public static void leaveCodeReviewComment(CodeReview codeReview){
throw new UnsupportedOperationException("To be implemented");
}

//overloaded method below was added to avoid compilation errors
public static void leaveCodeReviewComment(CodeReviewComment codeReviewComment){
throw new UnsupportedOperationException("To be implemented");
}

public static void deleteCodeReviewComment(CodeReview codeReview, CodeReviewComment codeReviewComment){
throw new UnsupportedOperationException("To be implemented");
}
}