From cae0dbcfae24028f5b8c0a93f5fb2e8b2b822373 Mon Sep 17 00:00:00 2001 From: uo287545 Date: Sun, 7 Apr 2024 16:27:09 +0200 Subject: [PATCH] Fixed an error between unit tests and Selenium tests --- .../com/uniovi/services/InsertSampleDataService.java | 10 +++++++--- src/test/java/com/uniovi/steps/GameStep.java | 1 + 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/uniovi/services/InsertSampleDataService.java b/src/main/java/com/uniovi/services/InsertSampleDataService.java index f7596821..40b12549 100644 --- a/src/main/java/com/uniovi/services/InsertSampleDataService.java +++ b/src/main/java/com/uniovi/services/InsertSampleDataService.java @@ -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 questionsTest = questionService.testQuestions(4); - questionsTest.forEach(questionService::addNewQuestion); return; } generateSampleData(); } + @Transactional + public void generateTestQuestions() { + questionRepository.deleteAll(); + List questionsTest = questionService.testQuestions(4); + questionsTest.forEach(questionService::addNewQuestion); + } + @Transactional public void generateSampleData() throws InterruptedException { diff --git a/src/test/java/com/uniovi/steps/GameStep.java b/src/test/java/com/uniovi/steps/GameStep.java index a46cb0b5..15d7bff0 100644 --- a/src/test/java/com/uniovi/steps/GameStep.java +++ b/src/test/java/com/uniovi/steps/GameStep.java @@ -19,6 +19,7 @@ public class GameStep extends Wiq_IntegrationTests { @When("I press Play") public void iPressPlay() { + dataService.generateTestQuestions(); List elems = SeleniumUtils.waitLoadElementsBy(driver, "free", "//*[@href=\"/game\"]", 5); elems.get(0).click(); }