Skip to content
This repository has been archived by the owner on Dec 27, 2022. It is now read-only.

Added Question and Answers functionality and basic tests #87

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

SergSam
Copy link
Contributor

@SergSam SergSam commented Mar 3, 2019

No description provided.



@Test(groups = "ui-tests")
public void createQuestionWithTitleAndBody_ShouldPass() throws Exception {
Copy link
Member

@ctapobep ctapobep Apr 4, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ShouldPass sounds unnatural here. What should pass? I'd call it something like canCreateQuestionWithValidTitleAndBody or createdQuestion_showsUpInBranch or even ifCreateQuestionPermissionsGrantedInBranch_canCreateQuestion. Though I don't see granting permissions, so the latter may be not applicable.

What about validation failure tests like whenCreatingQuestion_emptyTitleAndBody_resultInValidationErrors (don't need many of these though for each field, maybe just this one for body & title).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The method will be renamed. Regarding to validation failure tests - since the creation of Q&A based on topic's form and we already have such methods for Topic, I decided do not duplicate code.

public class QuestionAndAnswersPage extends TopicPage {
private String commentContent = randomAlphanumeric(100);

public static final String deleteCommentWarning = "(Are you sure you want to delete this comment?)" +
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We've been writing tests only for English i18n as far as I remember.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The topic page was taken as an example - there are two languages used.

}

@Override
public void clickAnswerToTopicButton() throws PermissionsDeniedException {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do you override these methods?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This button belongs to Topic page, I decided to use already existed method to avoid duplicating .

}

@Step
public static String fillCommentToOwnQuestion(QuestionAndAnswers question, String comment)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is it important that it's "your own" question?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When a user answers to own question he/she gets a warning pop up, which skiped for other users. But I'll try to adjust the method for all cases by adding an additional condition.

Actions actions = new Actions(driver);
for (WebElement comment : getCommentFields()) {
actions.moveToElement(comment);
actions.click();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can call addComment() from this place instead of duplicating the code.

return question;
}

public void findProperComment (String comment) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just findComment(), "proper" doesn't sound right.

}

@Step
public void checkingEnabledPlugins() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ensurePlugingEnabled()

}

@Step
public static String EditOwnCommentToQuestion(QuestionAndAnswers question, String comment)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

editOwnCommentToQuestion


// QuestionAndAnswers methods

public static QuestionAndAnswers createQuestionAndAnswers(QuestionAndAnswers questionAndAnswers)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can move these methods into a separate class.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants