Skip to content

Commit

Permalink
More tests, and some fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Pelayori committed Apr 27, 2024
1 parent 6ee27e1 commit 6802453
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 11 deletions.
11 changes: 0 additions & 11 deletions src/main/java/com/uniovi/controllers/GameController.java
Original file line number Diff line number Diff line change
Expand Up @@ -253,17 +253,6 @@ public String updateGame(Model model, HttpSession session, Principal principal)
return "game/fragments/gameFrame";
}

@GetMapping("/game/finished/{points}")
public String finishGame(@PathVariable int points, Model model, HttpSession session) {
GameSession gameSession = (GameSession) session.getAttribute(GAMESESSION_STR);
if (gameSession != null) {
gameSessionService.endGame(gameSession);
session.removeAttribute(GAMESESSION_STR);
}
model.addAttribute("score", points);
return "game/gameFinished";
}

@GetMapping("/game/points")
@ResponseBody
public String getPoints(HttpSession session) {
Expand Down
8 changes: 8 additions & 0 deletions src/test/java/com/uniovi/steps/GameStep.java
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ public void iPressPlayWithFriends() throws IOException, InterruptedException {
public void iCreateACode() {
List<WebElement> elems = SeleniumUtils.waitLoadElementsBy(driver, "id", "createBtn", 5);
elems.get(0).click();
SeleniumUtils.waitSeconds(driver, 5);
}

@And("I press start")
Expand All @@ -94,12 +95,19 @@ public void iFillInTheSavedCode() {
elems.get(0).sendKeys(code);
elems = SeleniumUtils.waitLoadElementsBy(driver, "id", "joinBtn", 5);
elems.get(0).click();
SeleniumUtils.waitSeconds(driver, 5);
}

@And("I see the multiplayer results")
public void iSeeTheMultiplayerResults() {
List<WebElement> elems = SeleniumUtils.waitLoadElementsBy(driver, "id", "createBtn", 5);
Assertions.assertEquals(1, elems.size());
elems.get(0).click();
SeleniumUtils.waitSeconds(driver, 5);
}

@And("I reload the page")
public void iReloadThePage() {
driver.navigate().refresh();
}
}
1 change: 1 addition & 0 deletions src/test/resources/features/Game.feature
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ Feature: I try to play a normal game
And I press the register button
And I go to the home page
When I press Play
And I reload the page
Then I should start playing until I see message "game.finish"
2 changes: 2 additions & 0 deletions src/test/resources/features/MultiplayerGame.feature
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ Feature: I play a multiplayer game
And I create a code
And I press start
Then I should start playing until I see message "multi.finished"
And I see the multiplayer results

Scenario: I start a multiplayer game
Given I am not registered or logged in
Expand All @@ -28,5 +29,6 @@ Feature: I play a multiplayer game
And I press Play With Friends
And I fill in the saved code
And I press start
And I reload the page
Then I should start playing until I see message "multi.finished"
And I see the multiplayer results

0 comments on commit 6802453

Please sign in to comment.