Skip to content

Commit

Permalink
Merge pull request #127 from Lukasdotcom/bug-fix
Browse files Browse the repository at this point in the history
Fixes bug that allows player to be moved to the bench during purchase
  • Loading branch information
Lukasdotcom authored Aug 18, 2022
2 parents 9381f03 + 6794679 commit 7ff76d0
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
19 changes: 13 additions & 6 deletions cypress/e2e/invite.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,9 @@ describe("Invite User into league and change some league Settings and run throug
cy.contains("Move to Field").click();
cy.contains("Star").click();
cy.contains("Move to Bench").click();
// Makes sure the player can be moved back to the bench
cy.contains("Move to Field").click();
cy.contains("Star").click();
cy.contains("Buying");
// Switches to user 2
cy.contains("Standings")
Expand All @@ -110,13 +113,17 @@ describe("Invite User into league and change some league Settings and run throug
cy.contains("You need 19.3 M");
cy.contains("Money left: 13.4M");
// Moves the squad slightly
cy.intercept("/api/player/87963521baf120631131").as("loadNkunku");
cy.contains("Squad").click();
cy.contains("Christopher Nkunku")
.parent()
.parent()
.children(".playerButton")
.children("button")
.click();
cy.wait("@loadNkunku").then(() =>
cy
.contains("Christopher Nkunku")
.parent()
.parent()
.children(".playerButton")
.children("button")
.click()
);
cy.contains("Buying");
// Starts the matchday
cy.exec("export NODE_ENV=test; node cypress/e2e/invite2.mjs").then(() => {
Expand Down
3 changes: 1 addition & 2 deletions pages/api/squad/[league].js
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,6 @@ export default async function handler(req, res) {
[league, user, e]
)
);
console.log(e);
// Checks if the player is owned by the user
if (position.length > 0) {
// Checks what position the player is
Expand Down Expand Up @@ -289,7 +288,7 @@ export default async function handler(req, res) {
[league, user, e]
);
connection.query(
"UPDATE transfers SET position='bench', starred=0 WHERE leagueID=? and user=? and playeruid=?",
"UPDATE transfers SET position='bench', starred=0 WHERE leagueID=? and buyer=? and playeruid=?",
[league, user, e]
);
console.log(`User ${user} moved player ${e} to bench`);
Expand Down

0 comments on commit 7ff76d0

Please sign in to comment.