Complete player stats inventory and Control content editors
This commit is contained in:
@@ -0,0 +1,63 @@
|
||||
import { test, expect } from '@playwright/test';
|
||||
|
||||
test('Control publishes title and equipment requirements, formulas and audit', async ({ page }) => {
|
||||
const errors:string[]=[];page.on('pageerror',e=>errors.push(e.message));
|
||||
const origin='http://127.0.0.1:18089';
|
||||
expect((await page.request.get('/api/control/catalog')).status()).toBe(401);
|
||||
await page.request.post('/auth/dev',{data:{},headers:{Origin:origin}});
|
||||
const initial=(await (await page.request.get('/api/control/catalog')).json()).catalog.version;
|
||||
await page.goto('/control');await page.getByRole('button',{name:'Content',exact:true}).click();
|
||||
await page.getByRole('button',{name:'Create title',exact:true}).click();
|
||||
const form=page.locator('.catalog-form');
|
||||
await form.getByLabel('Permanent ID',{exact:true}).fill('control_trial');
|
||||
await form.getByLabel('Name',{exact:true}).fill('Control Trial');
|
||||
await form.getByLabel('Description',{exact:true}).fill('A test of authored requirements and effects.');
|
||||
await form.getByLabel('Award scope').selectOption('global');
|
||||
await form.getByLabel('At least').fill('9999');
|
||||
await form.getByRole('button',{name:'Add modifier',exact:true}).click();
|
||||
await form.getByRole('combobox',{name:'Stat',exact:true}).selectOption('strength');
|
||||
await form.getByLabel('Flat change',{exact:true}).fill('3');
|
||||
await form.getByLabel('Percent change (%)',{exact:true}).fill('-10');
|
||||
await form.getByLabel('Reason for change').fill('Browser authoring verification');
|
||||
await page.setViewportSize({width:390,height:844});
|
||||
expect(await page.evaluate(()=>document.documentElement.scrollWidth<=innerWidth)).toBe(true);
|
||||
await page.screenshot({path:'test-results/content-title-mobile.png',fullPage:true});
|
||||
await form.getByRole('button',{name:'Publish changes'}).click();
|
||||
await expect(page.locator('.catalog-heading')).toContainText(`Catalog version ${initial+1}`);
|
||||
let catalog=(await (await page.request.get('/api/control/catalog')).json()).catalog;
|
||||
expect(catalog.titles.find(t=>t.id==='control_trial')).toMatchObject({scope:'global',requirements:[{metric:'level',atLeast:9999}],effects:{modifiers:[{stat:'strength',flat:3,percent:-10}]}});
|
||||
await page.locator('.catalog-tabs').getByRole('button',{name:'Equipment',exact:true}).click();
|
||||
await page.getByRole('button',{name:'Create equipment',exact:true}).click();
|
||||
await form.getByLabel('Permanent ID',{exact:true}).fill('control_ring');
|
||||
await form.getByLabel('Name',{exact:true}).fill('Control Ring');
|
||||
await form.getByLabel('Equipment slot').selectOption('ring');
|
||||
await form.getByLabel('Required level').fill('2');
|
||||
await form.getByRole('button',{name:'Add required stat'}).click();
|
||||
await form.getByRole('combobox',{name:'Stat',exact:true}).selectOption('strength');
|
||||
await form.getByLabel('Minimum value').fill('3');
|
||||
await form.getByLabel('Control Trial',{exact:true}).check();
|
||||
await form.getByRole('button',{name:'Add modifier',exact:true}).click();
|
||||
const modifier=form.locator('fieldset').filter({has:page.locator('legend',{hasText:'Modifiers'})});
|
||||
await modifier.getByRole('combobox',{name:'Stat',exact:true}).selectOption('luck');
|
||||
await modifier.getByLabel('Flat change').fill('2');
|
||||
await modifier.getByLabel('Percent change (%)').fill('25');
|
||||
await form.getByLabel('Reason for change').fill('Equipment authoring verification');
|
||||
await form.getByRole('button',{name:'Publish changes'}).click();
|
||||
await expect(page.locator('.catalog-heading')).toContainText(`Catalog version ${initial+2}`);
|
||||
catalog=(await (await page.request.get('/api/control/catalog')).json()).catalog;
|
||||
expect(catalog.items.find(i=>i.id==='control_ring')).toMatchObject({slot:'ring',requirements:{level:2,stats:{strength:3},titles:['control_trial']},modifiers:[{stat:'luck',flat:2,percent:25}]});
|
||||
await page.locator('.catalog-tabs').getByRole('button',{name:'Stat formulas',exact:true}).click();
|
||||
await page.getByRole('button',{name:'Edit stat formulas',exact:true}).click();
|
||||
await form.getByLabel('Charisma base',{exact:true}).fill('1');
|
||||
await form.getByLabel('Reason for change').fill('Formula editor verification');
|
||||
await form.getByRole('button',{name:'Publish changes'}).click();
|
||||
await expect(page.locator('.catalog-heading')).toContainText(`Catalog version ${initial+3}`);
|
||||
await page.locator('.catalog-tabs').getByRole('button',{name:'Content audit',exact:true}).click();
|
||||
await expect(page.locator('.catalog-list')).toContainText('Formula editor verification');
|
||||
await expect(page.locator('.catalog-list')).toContainText('control_ring');
|
||||
await page.setViewportSize({width:1440,height:1000});
|
||||
await page.screenshot({path:'test-results/content-audit-desktop.png',fullPage:true});
|
||||
await expect.poll(async()=>((await (await page.request.get('/api/control')).json()).worlds[0].catalogVersion)).toBe(initial+3);
|
||||
expect((await page.request.post('/api/control/catalog',{data:{},headers:{Origin:'https://evil.example'}})).status()).toBe(403);
|
||||
expect(errors).toEqual([]);
|
||||
});
|
||||
@@ -28,7 +28,7 @@ test('admin actions are audited and death permits a distinct replacement', async
|
||||
await page.getByRole('button', { name: 'Characters', exact: true }).click();
|
||||
await expect(page.locator('#view-title')).toHaveText('Characters');
|
||||
await page.getByRole('searchbox', { name: 'Search records' }).fill('Portal life');
|
||||
await expect(page.locator('tbody tr')).toHaveCount(1);
|
||||
await expect(page.locator('#records tbody tr')).toHaveCount(1);
|
||||
await page.getByRole('button', { name: 'Portal life', exact: true }).click();
|
||||
await expect(page.locator('#character-dialog')).toBeVisible();
|
||||
await expect(page.locator('#character-detail')).toContainText(old.entity.id);
|
||||
@@ -40,7 +40,7 @@ test('admin actions are audited and death permits a distinct replacement', async
|
||||
await expect.poll(async () => (await (await page.request.get('/api/account')).json()).active?.name).toBe('Portal renamed');
|
||||
await page.getByRole('searchbox', { name: 'Search records' }).fill('Portal renamed');
|
||||
await page.getByRole('button', { name: 'Refresh', exact: true }).click();
|
||||
await expect(page.locator('tbody tr')).toHaveCount(1);
|
||||
await expect(page.locator('#records tbody tr')).toHaveCount(1);
|
||||
await page.screenshot({ path: 'test-results/control-desktop.png', fullPage: true });
|
||||
await page.getByLabel(`Action for ${old.entity.id}`).selectOption('retire');
|
||||
await page.getByLabel('Reason', { exact: true }).fill('Permanent death verification');
|
||||
@@ -60,7 +60,7 @@ test('admin actions are audited and death permits a distinct replacement', async
|
||||
expect(account.characters.find(c => c.id === old.entity.id).state).toBe('dead');
|
||||
expect(account.characters.find(c => c.id === old.entity.id).character.deathReason).toContain('Permanent death verification');
|
||||
await page.goto('/control'); await page.getByRole('button', { name: 'Audit log', exact: true }).click();
|
||||
await expect(page.locator('tbody')).toContainText('Permanent death verification');
|
||||
await expect(page.locator('#records tbody')).toContainText('Permanent death verification');
|
||||
await page.setViewportSize({ width: 390, height: 844 });
|
||||
expect(await page.evaluate(() => document.documentElement.scrollWidth <= innerWidth)).toBe(true);
|
||||
await page.screenshot({ path: 'test-results/control-mobile.png', fullPage: true });
|
||||
|
||||
@@ -5,9 +5,12 @@ test('progression and signed permanent titles render in game, account, and admin
|
||||
const errors: string[] = []; page.on('pageerror', error => errors.push(error.message));
|
||||
const character: Character = {
|
||||
entity: { id: 'progression-fixture', kind: 'player', name: 'Title bearer', state: 'alive', hp: 100, maxHp: 100, position: { x: 0, y: 0, z: 0 } },
|
||||
inventory: { knife: 1 }, skills: { combat: 2 }, kills: 2, ack: 0, hasKeystone: false,
|
||||
inventory: { wood: 1 }, skills: { combat: 2 }, kills: 2, ack: 0, hasKeystone: false,
|
||||
allocatedStats: {}, pendingVitalChoices: 1, healthChoices: 0, manaChoices: 0, mana: 50, stamina: 105, carryWeight: 3,
|
||||
stats: { strength: { base: 2, flat: 2, percent: 50, final: 6 }, healthPoints: { base: 100, flat: 0, percent: 0, final: 100 }, manaPoints: { base: 50, flat: 0, percent: 0, final: 50 }, stamina: { base: 105, flat: 0, percent: 0, final: 105 }, carryCapacity: { base: 130, flat: 0, percent: 0, final: 130 } },
|
||||
equipment: {}, items: [{ id: 'ring-fixture', definitionId: 'ring-trial', name: 'Trial Ring', description: 'An earned tool.', slot: 'ring', weight: 2, requirements: { level: 1, stats: {}, titles: [] }, modifiers: [{ stat: 'luck', flat: 2, percent: -5 }], equippable: true, requirementMessage: '' }],
|
||||
playedSeconds: 120, remainingSeconds: 7080, level: 2, experience: 40, experienceToNextLevel: 150, statPoints: 5,
|
||||
titles: [{ id: 'first-hunter-fixture', name: 'The First Hunter', description: 'Power comes with a heavier step.', scope: 'global', worldId: 'e2e', earnedAt: '2026-09-06T12:00:00Z', effects: { damage: 3, moveSpeed: -0.5 } }],
|
||||
titles: [{ id: 'first-hunter-fixture', name: 'The First Hunter', description: 'Power comes with a heavier step.', scope: 'global', worldId: 'e2e', earnedAt: '2026-09-06T12:00:00Z', effects: { damage: 3, moveSpeed: -0.5, modifiers: [{ stat: 'strength', flat: 2, percent: 50 }] } }],
|
||||
};
|
||||
const record = { id: character.entity.id, account: 'fixture-account', worldId: 'e2e', name: character.entity.name, state: 'alive', character: { view: character, bornAt: '2026-09-06T11:00:00Z', dailySeconds: 120 } };
|
||||
const worlds = await (await request.get('/api/worlds')).json();
|
||||
@@ -16,7 +19,9 @@ test('progression and signed permanent titles render in game, account, and admin
|
||||
await page.route('**/api/account', route => route.fulfill({ json: { active: record, characters: [record], admin: true } }));
|
||||
await page.route('**/api/control?*', route => route.fulfill({ json: { worlds, characters: [record], commands: [], provisioningEnabled: false, characterLimit: 500, auditLimit: 100 } }));
|
||||
let sendSnapshot: () => void = () => {};
|
||||
const intents: { op: string; target: string; slot: string }[] = [];
|
||||
await page.routeWebSocket('**/ws', socket => {
|
||||
socket.onMessage(raw => { const intent = JSON.parse(String(raw)); if (intent.op !== 'move') intents.push(intent); });
|
||||
sendSnapshot = () => {
|
||||
const snapshot: Snapshot = { type: 'snapshot', version: 1, tick: 1, self: character, chunks, chunkKeys: chunks.map(c => c.key), entities: [], unavailableResources: [], message: '',
|
||||
world: { id: 'e2e', seed: 1, phase: 'gathering', ageSeconds: 120, bossInSeconds: 3600, collapseInSeconds: 5400, safeRadius: 1024, radius: 1024, online: 1, capacity: 100, bossHp: 1200, bossMaxHp: 1200 } };
|
||||
@@ -30,6 +35,23 @@ test('progression and signed permanent titles render in game, account, and admin
|
||||
await expect(page.locator('#character-experience')).toHaveText('40 / 150 XP');
|
||||
await expect(page.locator('#stat-point-bank')).toHaveText('5 stat points saved');
|
||||
await page.getByRole('button', { name: 'Inventory and crafting' }).click();
|
||||
await page.getByLabel('Ring slot for Trial Ring').selectOption('ring8');
|
||||
sendSnapshot();
|
||||
await expect(page.getByLabel('Ring slot for Trial Ring')).toHaveValue('ring8');
|
||||
await page.locator('[data-focus-key="equip-ring-fixture"]').click();
|
||||
await expect.poll(() => intents.at(-1)).toMatchObject({ op: 'equip', target: 'ring-fixture', slot: 'ring8' });
|
||||
character.equipment.ring8 = 'ring-fixture'; sendSnapshot();
|
||||
await page.locator('.character-sections').getByRole('button', { name: 'Equipment', exact: true }).click();
|
||||
await expect(page.locator('.equipment-slot')).toHaveCount(21);
|
||||
await page.locator('[data-focus-key="unequip-ring8"]').click();
|
||||
await expect.poll(() => intents.at(-1)).toMatchObject({ op: 'unequip', target: 'ring8' });
|
||||
await page.locator('.character-sections').getByRole('button', { name: 'Character', exact: true }).click();
|
||||
await page.getByRole('button', { name: 'Allocate one point to Constitution' }).click();
|
||||
await expect.poll(() => intents.at(-1)).toMatchObject({ op: 'allocate-stat', target: 'constitution' });
|
||||
await page.getByRole('button', { name: '+5 mana', exact: true }).click();
|
||||
await expect.poll(() => intents.at(-1)).toMatchObject({ op: 'choose-vital', target: 'mana' });
|
||||
await page.getByText('Inspect all stats', { exact: true }).click();
|
||||
await expect(page.locator('.stat-table tbody tr').filter({ hasText: 'Strength' })).toContainText('50%');
|
||||
await expect(page.locator('#earned-titles')).toContainText('+3 damage');
|
||||
await expect(page.locator('#earned-titles')).toContainText('-0.5 movement speed');
|
||||
await expect(page.locator('#earned-titles')).toContainText('First ever');
|
||||
@@ -53,6 +75,8 @@ test('progression and signed permanent titles render in game, account, and admin
|
||||
await expect(page.locator('#character-detail')).toContainText('Level 1000');
|
||||
await expect(page.locator('#character-detail')).toContainText('+3 damage');
|
||||
await expect(page.locator('#character-detail')).toContainText('-0.5 movement speed');
|
||||
await expect(page.locator('#character-detail .stat-table tbody tr').filter({ hasText: 'Strength' })).toHaveText('Strength2+2+50%6');
|
||||
await expect(page.locator('#character-detail')).toContainText('Trial Ring');
|
||||
await page.screenshot({ path: 'test-results/progression-control.png' });
|
||||
expect(errors).toEqual([]);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user