Skip to content

Commit

Permalink
Prevent override of bye completed match
Browse files Browse the repository at this point in the history
  • Loading branch information
Drarig29 committed Jul 11, 2023
1 parent f4f184a commit 0dc87c1
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -677,7 +677,7 @@ export function isMatchByeCompleted(match: DeepPartial<MatchResults>): boolean {
* @param match The match to check.
*/
export function isMatchUpdateLocked(match: MatchResults): boolean {
return match.status === Status.Locked || match.status === Status.Waiting || match.status === Status.Archived;
return match.status === Status.Locked || match.status === Status.Waiting || match.status === Status.Archived || isMatchByeCompleted(match);
}

/**
Expand Down
6 changes: 6 additions & 0 deletions test/double-elimination.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,12 @@ describe('Previous and next match update in double elimination stage', () => {
loserId,
);

await assert.isRejected(manager.update.match({
id: 3, // First match of LB round 1
opponent1: { score: 16, result: 'win' },
opponent2: { score: 12 },
}), 'The match is locked.');

await manager.reset.matchResults(1); // Second match of WB round 1

matchSemiLB = await storage.select('match', 3);
Expand Down

0 comments on commit 0dc87c1

Please sign in to comment.