feat(web): show Renown instead of Level in the Topbar, remove the XP display
This commit is contained in:
@@ -4,7 +4,7 @@
|
|||||||
@if (character(); as character) {
|
@if (character(); as character) {
|
||||||
<div class="top-bar__identity">
|
<div class="top-bar__identity">
|
||||||
<span class="top-bar__name">{{ character.name }}</span>
|
<span class="top-bar__name">{{ character.name }}</span>
|
||||||
<span class="top-bar__level">Stufe {{ character.level }}</span>
|
<span class="top-bar__level">Renown {{ character.renown }}</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="top-bar__health" aria-label="Lebenspunkte">
|
<div class="top-bar__health" aria-label="Lebenspunkte">
|
||||||
<span>{{ character.currentHp }} / {{ character.maxHp }}</span>
|
<span>{{ character.currentHp }} / {{ character.maxHp }}</span>
|
||||||
@@ -20,10 +20,6 @@
|
|||||||
<dt>Silber</dt>
|
<dt>Silber</dt>
|
||||||
<dd>{{ character.silver }}</dd>
|
<dd>{{ character.silver }}</dd>
|
||||||
</div>
|
</div>
|
||||||
<div class="top-bar__resource" data-top-bar-experience>
|
|
||||||
<dt>XP</dt>
|
|
||||||
<dd>{{ character.experience }}</dd>
|
|
||||||
</div>
|
|
||||||
</dl>
|
</dl>
|
||||||
} @else {
|
} @else {
|
||||||
<span class="top-bar__loading">Charakterdaten werden geladen</span>
|
<span class="top-bar__loading">Charakterdaten werden geladen</span>
|
||||||
|
|||||||
52
apps/web/src/app/layout/top-bar/top-bar.component.spec.ts
Normal file
52
apps/web/src/app/layout/top-bar/top-bar.component.spec.ts
Normal file
@@ -0,0 +1,52 @@
|
|||||||
|
import { TestBed } from '@angular/core/testing';
|
||||||
|
import type { CharacterResponse } from '../../core/api/game-api.models';
|
||||||
|
import { TopBarComponent } from './top-bar.component';
|
||||||
|
|
||||||
|
function characterFixture(overrides: Partial<CharacterResponse> = {}): CharacterResponse {
|
||||||
|
return {
|
||||||
|
id: 'character-1',
|
||||||
|
name: 'Aric Duskwalker',
|
||||||
|
renown: 3,
|
||||||
|
silver: 120,
|
||||||
|
currentHp: 80,
|
||||||
|
maxHp: 100,
|
||||||
|
attack: 10,
|
||||||
|
currentLocation: { id: 'location-1', key: 'aschenfelder', name: 'Aschenfelder' },
|
||||||
|
...overrides,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
async function render(character: CharacterResponse | null): Promise<HTMLElement> {
|
||||||
|
await TestBed.configureTestingModule({
|
||||||
|
imports: [TopBarComponent],
|
||||||
|
}).compileComponents();
|
||||||
|
|
||||||
|
const fixture = TestBed.createComponent(TopBarComponent);
|
||||||
|
fixture.componentRef.setInput('character', character);
|
||||||
|
fixture.detectChanges();
|
||||||
|
|
||||||
|
return fixture.nativeElement as HTMLElement;
|
||||||
|
}
|
||||||
|
|
||||||
|
describe('TopBarComponent', () => {
|
||||||
|
it('shows the character name, HP and silver', async () => {
|
||||||
|
const element = await render(characterFixture({ name: 'Aric Duskwalker', currentHp: 80, maxHp: 100, silver: 120 }));
|
||||||
|
|
||||||
|
expect(element.textContent).toContain('Aric Duskwalker');
|
||||||
|
expect(element.textContent).toContain('80 / 100');
|
||||||
|
expect(element.querySelector('[data-top-bar-silver]')?.textContent).toContain('120');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('shows Renown instead of Level, and displays no XP value', async () => {
|
||||||
|
const element = await render(characterFixture({ renown: 3 }));
|
||||||
|
|
||||||
|
expect(element.textContent).toContain('Renown 3');
|
||||||
|
expect(element.querySelector('[data-top-bar-experience]')).toBeNull();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('shows a loading message when no character is available yet', async () => {
|
||||||
|
const element = await render(null);
|
||||||
|
|
||||||
|
expect(element.textContent).toContain('Charakterdaten werden geladen');
|
||||||
|
});
|
||||||
|
});
|
||||||
Reference in New Issue
Block a user