fix: close competition cutover integrity gaps
This commit is contained in:
1 parent
7ea2002975
commit
683d602d63
57 files changed
+4805
-1582
No files matched your search
@@ -0,0 +1,57 @@
|
||||
import assert from "node:assert/strict";
|
||||
import test from "node:test";
|
||||
import {
|
||||
getTeamProgressErrorContent,
|
||||
isConsistentTeamProgressSnapshot,
|
||||
} from "../src/pages/match-team-progress-state.ts";
|
||||
|
||||
test("only accepts Competition and team snapshots with the same revision", () => {
|
||||
assert.equal(
|
||||
isConsistentTeamProgressSnapshot({ revision: 7 }, { revision: 7 }),
|
||||
true,
|
||||
);
|
||||
assert.equal(
|
||||
isConsistentTeamProgressSnapshot({ revision: 7 }, { revision: 8 }),
|
||||
false,
|
||||
);
|
||||
assert.equal(isConsistentTeamProgressSnapshot(undefined, { revision: 7 }), false);
|
||||
});
|
||||
|
||||
test("describes a 401 response as an authentication error", () => {
|
||||
assert.equal(
|
||||
getTeamProgressErrorContent([{ status: 401 }]).kind,
|
||||
"unauthorized",
|
||||
);
|
||||
});
|
||||
|
||||
test("describes a 403 response as a team access error", () => {
|
||||
assert.equal(
|
||||
getTeamProgressErrorContent([{ status: 403 }]).kind,
|
||||
"forbidden",
|
||||
);
|
||||
});
|
||||
|
||||
test("describes a 404 response as missing Competition data", () => {
|
||||
assert.equal(getTeamProgressErrorContent([{ status: 404 }]).kind, "not-found");
|
||||
});
|
||||
|
||||
test("describes a 5xx response as a server error", () => {
|
||||
assert.equal(getTeamProgressErrorContent([{ status: 503 }]).kind, "server");
|
||||
});
|
||||
|
||||
test("describes a failed fetch as a network error", () => {
|
||||
assert.equal(
|
||||
getTeamProgressErrorContent([new TypeError("Failed to fetch")]).kind,
|
||||
"network",
|
||||
);
|
||||
});
|
||||
|
||||
test("prioritizes authentication and authorization errors from either query", () => {
|
||||
assert.equal(
|
||||
getTeamProgressErrorContent([
|
||||
new TypeError("Failed to fetch"),
|
||||
{ status: 403 },
|
||||
]).kind,
|
||||
"forbidden",
|
||||
);
|
||||
});
|
||||
Reference in new issue
Block a user