feat: enhance auction interactions and player statistics UI
This commit is contained in:
1 parent
6c582ba3cf
commit
be4de61bb7
115 files changed
+13292
-2871
No files matched your search
@@ -8,6 +8,15 @@ jest.mock('../auth/jwt.service', () => ({
|
||||
import { AuctionGateway } from './auction.gateway';
|
||||
|
||||
describe('AuctionGateway', () => {
|
||||
beforeEach(() => {
|
||||
jest.replaceProperty(process, 'env', { ...process.env });
|
||||
delete process.env.AUCTION_REQUIRE_CAPTAIN_AUTH;
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
jest.restoreAllMocks();
|
||||
});
|
||||
|
||||
it('signals pending initial state so the client can retry privately after recovery', async () => {
|
||||
const matchId = new mongoose.Types.ObjectId().toString();
|
||||
const gateway = new AuctionGateway(
|
||||
@@ -114,7 +123,8 @@ describe('AuctionGateway', () => {
|
||||
};
|
||||
}
|
||||
|
||||
it('requires an authenticated user before forwarding a bid', async () => {
|
||||
it('requires an authenticated user when captain authentication is enabled', async () => {
|
||||
process.env.AUCTION_REQUIRE_CAPTAIN_AUTH = 'true';
|
||||
const matchId = new mongoose.Types.ObjectId().toString();
|
||||
const { gateway, auctionService } = createGateway();
|
||||
const ack = jest.fn();
|
||||
@@ -131,6 +141,49 @@ describe('AuctionGateway', () => {
|
||||
);
|
||||
});
|
||||
|
||||
it.each([undefined, bidderUserId])(
|
||||
'accepts the selected team in temporary mode for user %s',
|
||||
async (userId) => {
|
||||
const matchId = new mongoose.Types.ObjectId().toString();
|
||||
const placeBidDelta = jest.fn().mockResolvedValue({
|
||||
auctionBidHistoryEntry: {
|
||||
bidderTeamIndex: 2,
|
||||
bidderUserId: new mongoose.Types.ObjectId().toString(),
|
||||
bidPointAmount: 120,
|
||||
bidPlacedAtTimestampMS: 1780000000000,
|
||||
},
|
||||
currentHighestBidderTeamIndex: 2,
|
||||
currentHighestBidPointAmount: 120,
|
||||
currentServerTimestampMS: 1780000000000,
|
||||
revision: 9,
|
||||
});
|
||||
const { gateway, emit } = createGateway({ placeBidDelta });
|
||||
const ack = jest.fn();
|
||||
|
||||
await gateway.handleBid(
|
||||
{
|
||||
data: { matchId, user: userId ? { _id: userId } : undefined },
|
||||
emit: jest.fn(),
|
||||
} as never,
|
||||
{ bidderTeamIndex: 2, bidPointAmount: 120 },
|
||||
ack,
|
||||
);
|
||||
|
||||
expect(placeBidDelta).toHaveBeenCalledWith(
|
||||
expect.objectContaining({
|
||||
teamIndex: 2,
|
||||
amount: 120,
|
||||
bidderUserId: userId,
|
||||
}),
|
||||
);
|
||||
expect(ack).toHaveBeenCalledWith(expect.objectContaining({ ok: true }));
|
||||
expect(emit).toHaveBeenCalledWith(
|
||||
'bid',
|
||||
expect.objectContaining({ currentHighestBidderTeamIndex: 2 }),
|
||||
);
|
||||
},
|
||||
);
|
||||
|
||||
it('broadcasts a bid delta and acknowledges the matching bid request', async () => {
|
||||
const matchId = new mongoose.Types.ObjectId().toString();
|
||||
const auctionBidHistoryEntry = {
|
||||
|
||||
Reference in new issue
Block a user