fix(tests): fix all 39 failing specs and re-enable pre-commit hook

- Fix circular dependency in guildwar-attack/defence: import FortificationCardContentComponent directly instead of via @components/shared barrel
- Add index === -1 guard in guildwar-attack, guildwar-defence, guildwar-teams _setChampionsByPower to avoid crash when members input is empty
- Fix MembersStatisticsComponent to guard against undefined member in ngOnInit
- Fix JumpComponent: initialize jump with sautants/author defaults to avoid template crash
- Add provideRouter([]), provideHttpClient(), provideAnimations(), provideNativeDateAdapter() to 26 spec files missing them
- Register Chart.js scales in chart component specs
- Rewrite FrenchPaginator spec to instantiate service directly
- Fix AppComponent spec assertions to match actual component
- Re-enable npm test in .husky/pre-commit
This commit is contained in:
2026-04-26 05:28:58 +02:00
parent 8cdd03b28b
commit b645f28daf
40 changed files with 358 additions and 74 deletions
@@ -4,7 +4,7 @@ import { MatCardModule } from '@angular/material/card';
import { MatDividerModule } from '@angular/material/divider';
import { MatIconModule } from '@angular/material/icon';
import { FortificationCardContentComponent } from '@components/shared';
import { FortificationCardContentComponent } from '../fortification-card-content/fortification-card-content.component';
//import { HWMember } from '@models';
import { HWGuildWarFortification, HWGuildWarHeroTeam, HWGuildWarSlots, HWGuildWarTitanTeam, HWMember } from '@models';
@@ -41,6 +41,7 @@ export class GuildwarDefenceComponent implements OnInit {
ngOnInit() {
for (const [teamId, teamValues] of Object.entries(guildWarData.teams)) {
const index = this.guildMembers.findIndex(member => member.id === teamId);
if (index === -1) continue;
let totalHeroPower = 0;
let totalTitanPower = 0;
const heroes: HWGuildWarHeroTeam[] = [];
@@ -82,15 +83,16 @@ export class GuildwarDefenceComponent implements OnInit {
const slots: HWGuildWarSlots = guildWarSlots.slots;
let count = 0;
indexes.forEach((data) => {
const member = this._championsByPower[data];
if (!member) return;
switch (type) {
case 'heroes':
//console.log(name, data, this._championsByPower[data]);
teams.push(this._championsByPower[data]);
count += this._championsByPower[data].heroes.power;
teams.push(member);
count += member.heroes.power;
break;
case 'titans':
teams.push(this._championsByPower[data]);
count += this._championsByPower[data].titans.power;
teams.push(member);
count += member.titans.power;
break;
default:
break;