ui improvements
This commit is contained in:
332
tests/utils/test-data.ts
Normal file
332
tests/utils/test-data.ts
Normal file
@@ -0,0 +1,332 @@
|
||||
import { CRIMES } from '@/lib/dp2-rules';
|
||||
|
||||
// Test data interfaces
|
||||
export interface TestPlayer {
|
||||
name: string;
|
||||
currentPoints: number;
|
||||
}
|
||||
|
||||
export interface TestOffense {
|
||||
crimeId: string;
|
||||
itemDetails?: Array<{ type: string; quantity: number }>;
|
||||
blockCount?: number;
|
||||
entityCount?: number;
|
||||
isSPP?: boolean;
|
||||
specialItems?: {
|
||||
elytra: number;
|
||||
netherStar: number;
|
||||
beacon: number;
|
||||
netheriteBlock: number;
|
||||
diamondBlock: number;
|
||||
};
|
||||
}
|
||||
|
||||
export interface TestScenario {
|
||||
player: TestPlayer;
|
||||
offense: TestOffense;
|
||||
expected: {
|
||||
basePoints: number;
|
||||
totalPoints: number;
|
||||
punishmentLevel: string;
|
||||
hasCommands: boolean;
|
||||
};
|
||||
}
|
||||
|
||||
// Test data factories
|
||||
export class TestDataFactory {
|
||||
// Item Offenses Test Scenarios
|
||||
static getItemOffenseScenarios(): TestScenario[] {
|
||||
return [
|
||||
// Theft - Minor (< 50 item points)
|
||||
{
|
||||
player: { name: 'TestPlayer1', currentPoints: 0 },
|
||||
offense: {
|
||||
crimeId: 'theft',
|
||||
specialItems: { elytra: 0, netherStar: 0, beacon: 0, netheriteBlock: 0, diamondBlock: 0 },
|
||||
itemDetails: [{ type: 'diamond', quantity: 2 }] // 2 * 5 = 10 points
|
||||
},
|
||||
expected: { basePoints: 11, totalPoints: 11, punishmentLevel: 'warning', hasCommands: true }
|
||||
},
|
||||
// Theft - Moderate (50-500 item points)
|
||||
{
|
||||
player: { name: 'TestPlayer2', currentPoints: 0 },
|
||||
offense: {
|
||||
crimeId: 'theft',
|
||||
specialItems: { elytra: 1, netherStar: 0, beacon: 0, netheriteBlock: 0, diamondBlock: 0 }, // 20 points
|
||||
itemDetails: [{ type: 'diamond', quantity: 10 }] // 10 * 5 = 50 points, total 70
|
||||
},
|
||||
expected: { basePoints: 72, totalPoints: 72, punishmentLevel: 'warning', hasCommands: true }
|
||||
},
|
||||
// Theft - Severe (> 500 item points)
|
||||
{
|
||||
player: { name: 'TestPlayer3', currentPoints: 0 },
|
||||
offense: {
|
||||
crimeId: 'theft',
|
||||
specialItems: { elytra: 1, netherStar: 1, beacon: 1, netheriteBlock: 0, diamondBlock: 0 }, // 60 points
|
||||
itemDetails: [{ type: 'diamond_block', quantity: 50 }] // 50 * 10 = 500 points, total 560
|
||||
},
|
||||
expected: { basePoints: 563, totalPoints: 563, punishmentLevel: 'warning', hasCommands: true }
|
||||
},
|
||||
// Unconsensual Killing
|
||||
{
|
||||
player: { name: 'TestPlayer4', currentPoints: 0 },
|
||||
offense: { crimeId: 'unconsensual_killing' },
|
||||
expected: { basePoints: 2, totalPoints: 2, punishmentLevel: 'warning', hasCommands: true }
|
||||
},
|
||||
// Illegal Item Use
|
||||
{
|
||||
player: { name: 'TestPlayer5', currentPoints: 0 },
|
||||
offense: { crimeId: 'illegal_item_use' },
|
||||
expected: { basePoints: 1, totalPoints: 1, punishmentLevel: 'warning', hasCommands: true }
|
||||
},
|
||||
// Inappropriate Item Names
|
||||
{
|
||||
player: { name: 'TestPlayer6', currentPoints: 0 },
|
||||
offense: { crimeId: 'inappropriate_item_names' },
|
||||
expected: { basePoints: 1, totalPoints: 1, punishmentLevel: 'warning', hasCommands: true }
|
||||
},
|
||||
// Inappropriate Book Contents
|
||||
{
|
||||
player: { name: 'TestPlayer7', currentPoints: 0 },
|
||||
offense: { crimeId: 'inappropriate_book_contents' },
|
||||
expected: { basePoints: 1, totalPoints: 1, punishmentLevel: 'warning', hasCommands: true }
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
// Block Offenses Test Scenarios
|
||||
static getBlockOffenseScenarios(): TestScenario[] {
|
||||
return [
|
||||
// Vandalism (< 10 blocks)
|
||||
{
|
||||
player: { name: 'TestPlayer8', currentPoints: 0 },
|
||||
offense: {
|
||||
crimeId: 'vandalism',
|
||||
blockCount: 5,
|
||||
entityCount: 2
|
||||
},
|
||||
expected: { basePoints: 1, totalPoints: 1, punishmentLevel: 'warning', hasCommands: true }
|
||||
},
|
||||
// Grief - Minor (< 100 blocks)
|
||||
{
|
||||
player: { name: 'TestPlayer9', currentPoints: 0 },
|
||||
offense: {
|
||||
crimeId: 'grief',
|
||||
blockCount: 50,
|
||||
entityCount: 0
|
||||
},
|
||||
expected: { basePoints: 1, totalPoints: 1, punishmentLevel: 'warning', hasCommands: true }
|
||||
},
|
||||
// Grief - Moderate (100-1000 blocks)
|
||||
{
|
||||
player: { name: 'TestPlayer10', currentPoints: 0 },
|
||||
offense: {
|
||||
crimeId: 'grief',
|
||||
blockCount: 500,
|
||||
entityCount: 0
|
||||
},
|
||||
expected: { basePoints: 1, totalPoints: 1, punishmentLevel: 'warning', hasCommands: true }
|
||||
},
|
||||
// Grief - Large (1000-100000 blocks)
|
||||
{
|
||||
player: { name: 'TestPlayer11', currentPoints: 0 },
|
||||
offense: {
|
||||
crimeId: 'grief',
|
||||
blockCount: 50000,
|
||||
entityCount: 0
|
||||
},
|
||||
expected: { basePoints: 1, totalPoints: 1, punishmentLevel: 'warning', hasCommands: true }
|
||||
},
|
||||
// Grief - Massive (> 100000 blocks)
|
||||
{
|
||||
player: { name: 'TestPlayer12', currentPoints: 0 },
|
||||
offense: {
|
||||
crimeId: 'grief',
|
||||
blockCount: 200000,
|
||||
entityCount: 0
|
||||
},
|
||||
expected: { basePoints: 1, totalPoints: 1, punishmentLevel: 'warning', hasCommands: true }
|
||||
},
|
||||
// Theft-Grief
|
||||
{
|
||||
player: { name: 'TestPlayer13', currentPoints: 0 },
|
||||
offense: {
|
||||
crimeId: 'theft_grief',
|
||||
blockCount: 50
|
||||
},
|
||||
expected: { basePoints: 2, totalPoints: 2, punishmentLevel: 'warning', hasCommands: true }
|
||||
},
|
||||
// Vandalism of Infrastructure
|
||||
{
|
||||
player: { name: 'TestPlayer14', currentPoints: 0 },
|
||||
offense: {
|
||||
crimeId: 'vandalism_infrastructure',
|
||||
blockCount: 10
|
||||
},
|
||||
expected: { basePoints: 6, totalPoints: 6, punishmentLevel: 'warning', hasCommands: true }
|
||||
},
|
||||
// Trespassing
|
||||
{
|
||||
player: { name: 'TestPlayer15', currentPoints: 0 },
|
||||
offense: { crimeId: 'trespassing' },
|
||||
expected: { basePoints: 1, totalPoints: 1, punishmentLevel: 'warning', hasCommands: true }
|
||||
},
|
||||
// Trespassing on Staff/SPP Land
|
||||
{
|
||||
player: { name: 'TestPlayer16', currentPoints: 0 },
|
||||
offense: {
|
||||
crimeId: 'trespassing_staff',
|
||||
isSPP: true
|
||||
},
|
||||
expected: { basePoints: 3, totalPoints: 3, punishmentLevel: 'warning', hasCommands: true }
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
// Hacking Offenses Test Scenarios
|
||||
static getHackingOffenseScenarios(): TestScenario[] {
|
||||
return [
|
||||
// X-Raying
|
||||
{
|
||||
player: { name: 'TestPlayer17', currentPoints: 0 },
|
||||
offense: { crimeId: 'x_raying' },
|
||||
expected: { basePoints: 1, totalPoints: 1, punishmentLevel: 'warning', hasCommands: true }
|
||||
},
|
||||
// Hacking Client
|
||||
{
|
||||
player: { name: 'TestPlayer18', currentPoints: 0 },
|
||||
offense: { crimeId: 'hacking_client' },
|
||||
expected: { basePoints: 5, totalPoints: 5, punishmentLevel: 'kick', hasCommands: true }
|
||||
},
|
||||
// Lagging Server
|
||||
{
|
||||
player: { name: 'TestPlayer19', currentPoints: 0 },
|
||||
offense: { crimeId: 'lagging_server' },
|
||||
expected: { basePoints: 5, totalPoints: 5, punishmentLevel: 'warning', hasCommands: true }
|
||||
},
|
||||
// Worldedit Misuse
|
||||
{
|
||||
player: { name: 'TestPlayer20', currentPoints: 0 },
|
||||
offense: { crimeId: 'worldedit_misuse' },
|
||||
expected: { basePoints: 5, totalPoints: 5, punishmentLevel: 'warning', hasCommands: true }
|
||||
},
|
||||
// Exploit Abuse
|
||||
{
|
||||
player: { name: 'TestPlayer21', currentPoints: 0 },
|
||||
offense: { crimeId: 'exploit_abuse' },
|
||||
expected: { basePoints: 10, totalPoints: 10, punishmentLevel: 'warning', hasCommands: true }
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
// Communication Offenses Test Scenarios
|
||||
static getCommunicationOffenseScenarios(): TestScenario[] {
|
||||
return [
|
||||
// Abusive Chat
|
||||
{
|
||||
player: { name: 'TestPlayer22', currentPoints: 0 },
|
||||
offense: { crimeId: 'abusive_chat' },
|
||||
expected: { basePoints: 1, totalPoints: 1, punishmentLevel: 'warning', hasCommands: true }
|
||||
},
|
||||
// Inciting Verbal Conflict
|
||||
{
|
||||
player: { name: 'TestPlayer23', currentPoints: 0 },
|
||||
offense: { crimeId: 'inciting_verbal_conflict' },
|
||||
expected: { basePoints: 2, totalPoints: 2, punishmentLevel: 'warning', hasCommands: true }
|
||||
},
|
||||
// Abusive VC Language
|
||||
{
|
||||
player: { name: 'TestPlayer24', currentPoints: 0 },
|
||||
offense: { crimeId: 'abusive_vc' },
|
||||
expected: { basePoints: 1, totalPoints: 1, punishmentLevel: 'warning', hasCommands: true }
|
||||
},
|
||||
// Lying to Staff
|
||||
{
|
||||
player: { name: 'TestPlayer25', currentPoints: 0 },
|
||||
offense: { crimeId: 'lying_to_staff' },
|
||||
expected: { basePoints: 1, totalPoints: 1, punishmentLevel: 'warning', hasCommands: true }
|
||||
},
|
||||
// Manipulation
|
||||
{
|
||||
player: { name: 'TestPlayer26', currentPoints: 0 },
|
||||
offense: { crimeId: 'manipulation' },
|
||||
expected: { basePoints: 5, totalPoints: 5, punishmentLevel: 'warning', hasCommands: true }
|
||||
},
|
||||
// Grand Manipulation
|
||||
{
|
||||
player: { name: 'TestPlayer27', currentPoints: 0 },
|
||||
offense: { crimeId: 'grand_manipulation' },
|
||||
expected: { basePoints: 20, totalPoints: 20, punishmentLevel: 'permanent_ban', hasCommands: true }
|
||||
},
|
||||
// Slander (Against SPP)
|
||||
{
|
||||
player: { name: 'TestPlayer28', currentPoints: 0 },
|
||||
offense: {
|
||||
crimeId: 'slander',
|
||||
isSPP: true
|
||||
},
|
||||
expected: { basePoints: 3, totalPoints: 3, punishmentLevel: 'warning', hasCommands: true }
|
||||
},
|
||||
// Violation of NCA
|
||||
{
|
||||
player: { name: 'TestPlayer29', currentPoints: 0 },
|
||||
offense: { crimeId: 'violation_nca' },
|
||||
expected: { basePoints: 2, totalPoints: 2, punishmentLevel: 'warning', hasCommands: true }
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
// Point Decay Test Scenarios
|
||||
static getPointDecayScenarios(): TestScenario[] {
|
||||
return [
|
||||
// Points decay after 1 week
|
||||
{
|
||||
player: { name: 'DecayTest1', currentPoints: 10 },
|
||||
offense: { crimeId: 'abusive_chat' },
|
||||
expected: { basePoints: 1, totalPoints: 11, punishmentLevel: 'warning', hasCommands: true }
|
||||
},
|
||||
// Points decay after multiple weeks
|
||||
{
|
||||
player: { name: 'DecayTest2', currentPoints: 20 },
|
||||
offense: { crimeId: 'abusive_chat' },
|
||||
expected: { basePoints: 1, totalPoints: 21, punishmentLevel: 'warning', hasCommands: true }
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
// Edge Cases
|
||||
static getEdgeCaseScenarios(): TestScenario[] {
|
||||
return [
|
||||
// Zero points player
|
||||
{
|
||||
player: { name: 'EdgeCase1', currentPoints: 0 },
|
||||
offense: { crimeId: 'abusive_chat' },
|
||||
expected: { basePoints: 1, totalPoints: 1, punishmentLevel: 'warning', hasCommands: true }
|
||||
},
|
||||
// High point player
|
||||
{
|
||||
player: { name: 'EdgeCase2', currentPoints: 50 },
|
||||
offense: { crimeId: 'abusive_chat' },
|
||||
expected: { basePoints: 1, totalPoints: 51, punishmentLevel: 'warning', hasCommands: true }
|
||||
},
|
||||
// Empty form validation
|
||||
{
|
||||
player: { name: '', currentPoints: 0 },
|
||||
offense: { crimeId: '' },
|
||||
expected: { basePoints: 0, totalPoints: 0, punishmentLevel: '', hasCommands: false }
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
// Get all test scenarios
|
||||
static getAllScenarios(): TestScenario[] {
|
||||
return [
|
||||
...this.getItemOffenseScenarios(),
|
||||
...this.getBlockOffenseScenarios(),
|
||||
...this.getHackingOffenseScenarios(),
|
||||
...this.getCommunicationOffenseScenarios(),
|
||||
...this.getPointDecayScenarios(),
|
||||
...this.getEdgeCaseScenarios(),
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user