Skip to content

Commit

Permalink
Fixed an error between unit tests and Selenium tests
Browse files Browse the repository at this point in the history
  • Loading branch information
uo287545 committed Apr 7, 2024
1 parent fee2a89 commit cae0dbc
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/main/java/com/uniovi/services/InsertSampleDataService.java
Original file line number Diff line number Diff line change
Expand Up @@ -61,15 +61,19 @@ public void insertSampleQuestions() throws InterruptedException {

if (Arrays.stream(environment.getActiveProfiles()).anyMatch(env -> (env.equalsIgnoreCase("test")))) {
log.info("Test profile active, skipping sample data insertion");
questionRepository.deleteAll();
List<Question> questionsTest = questionService.testQuestions(4);
questionsTest.forEach(questionService::addNewQuestion);
return;
}

generateSampleData();
}

@Transactional
public void generateTestQuestions() {
questionRepository.deleteAll();
List<Question> questionsTest = questionService.testQuestions(4);
questionsTest.forEach(questionService::addNewQuestion);
}

@Transactional
public void generateSampleData() throws InterruptedException {

Expand Down
1 change: 1 addition & 0 deletions src/test/java/com/uniovi/steps/GameStep.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ public class GameStep extends Wiq_IntegrationTests {

@When("I press Play")
public void iPressPlay() {
dataService.generateTestQuestions();
List<WebElement> elems = SeleniumUtils.waitLoadElementsBy(driver, "free", "//*[@href=\"/game\"]", 5);
elems.get(0).click();
}
Expand Down

0 comments on commit cae0dbc

Please sign in to comment.