Skip to content

Commit 5e80fc4

Browse files
committed
chore: adjust to type changes
1 parent 7389f42 commit 5e80fc4

File tree

9 files changed

+31
-21
lines changed

9 files changed

+31
-21
lines changed

bun.lockb

-40 Bytes
Binary file not shown.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
"wildcard-match": "^5.1.3"
5555
},
5656
"peerDependencies": {
57-
"@league-of-foundry-developers/foundry-vtt-types": "github:League-of-Foundry-Developers/foundry-vtt-types#e787013319b46f7465cce2c71263083abba70ce8"
57+
"fvtt-types": "github:League-of-Foundry-Developers/foundry-vtt-types#main"
5858
},
5959
"devDependencies": {
6060
"@biomejs/biome": "^1.9.0",

src/module/apps/quench-results.ts

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import * as Diff from "diff";
22

3+
import type { AnyObject } from "fvtt-types/utils";
4+
35
import type { Quench, QuenchBatchKey } from "../quench";
46
import { type RUNNABLE_STATE, getBatchKey } from "../utils/quench-utils";
57

@@ -20,14 +22,13 @@ import { pause } from "../utils/user-utils";
2022

2123
import ApplicationV2 = foundry.applications.api.ApplicationV2;
2224
import HandlebarsApplicationMixin = foundry.applications.api.HandlebarsApplicationMixin;
23-
// const { HandlebarsApplicationMixin, ApplicationV2 } = foundry.applications.api;
2425

2526
/**
2627
* The visual UI for representing Quench test batches and the tests results thereof.
2728
*
2829
* @internal
2930
*/
30-
export class QuenchResults extends HandlebarsApplicationMixin(ApplicationV2) {
31+
export class QuenchResults extends HandlebarsApplicationMixin(ApplicationV2<QuenchResultData>) {
3132
/** The `Quench` instance this `Application` is used by */
3233
quench: Quench;
3334

@@ -97,9 +98,11 @@ export class QuenchResults extends HandlebarsApplicationMixin(ApplicationV2) {
9798
/* -------------------------------------------- */
9899

99100
/** @inheritDoc */
100-
override async _prepareContext(): Promise<QuenchResultData> {
101+
override async _prepareContext(_options: ApplicationV2.RenderOptions): Promise<QuenchResultData> {
101102
const filterSetting = getFilterSetting();
102-
const preselected = this.quench._filterBatches(filterSetting, { preSelectedOnly: true });
103+
const preselected = this.quench._filterBatches(filterSetting, {
104+
preSelectedOnly: true,
105+
});
103106
return {
104107
anyBatches: this.quench._testBatches.size > 0,
105108
batches: this.quench._testBatches.map((batchData) => {
@@ -113,10 +116,7 @@ export class QuenchResults extends HandlebarsApplicationMixin(ApplicationV2) {
113116
}
114117

115118
/** @inheritDoc */
116-
override _onRender(
117-
context: QuenchResultData,
118-
options: foundry.applications.types.ApplicationRenderOptions,
119-
) {
119+
override _onRender(context: QuenchResultData, options: ApplicationV2.RenderOptions) {
120120
super._onRender(context, options);
121121
this.#searchFilter.bind(this.element);
122122
}
@@ -449,7 +449,10 @@ export class QuenchResults extends HandlebarsApplicationMixin(ApplicationV2) {
449449
}
450450
}
451451

452-
private static _getErrorDiff(error: { actual: unknown; expected: unknown }): HTMLElement {
452+
private static _getErrorDiff(error: {
453+
actual: unknown;
454+
expected: unknown;
455+
}): HTMLElement {
453456
const diffNode = createNode("div", { attr: { class: "diff" } });
454457

455458
const expected =
@@ -511,7 +514,9 @@ export class QuenchResults extends HandlebarsApplicationMixin(ApplicationV2) {
511514
}
512515

513516
return createNode("span", {
514-
attr: { class: part.removed ? "expected" : part.added ? "actual" : "unchanged" },
517+
attr: {
518+
class: part.removed ? "expected" : part.added ? "actual" : "unchanged",
519+
},
515520
children: part.value,
516521
});
517522
})
@@ -671,7 +676,9 @@ export class QuenchResults extends HandlebarsApplicationMixin(ApplicationV2) {
671676

672677
if (!batchKey || !isBatchRoot) return;
673678

674-
const errorTitle = localize("ERROR.Hook", { hook: hook.title.replace("_root", "") });
679+
const errorTitle = localize("ERROR.Hook", {
680+
hook: hook.title.replace("_root", ""),
681+
});
675682
const hookId = hook.id as string;
676683

677684
const batchLi = this.element.querySelector(`li.test-batch[data-batch="${batchKey}"]`);
@@ -739,7 +746,7 @@ export class QuenchResults extends HandlebarsApplicationMixin(ApplicationV2) {
739746
}
740747
}
741748

742-
interface QuenchResultData extends foundry.applications.api.ApplicationV2.RenderContext {
749+
interface QuenchResultData extends AnyObject {
743750
anyBatches: boolean;
744751
batches: { name: string; displayName: string; selected: boolean }[];
745752
}

src/module/quench-tests/nonsense-tests.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,9 @@ function registerBasicFailingTestBatch(quench: Quench) {
6666
expect(1).to.equal(2);
6767
});
6868
it("Another Failing Test", function () {
69-
expect({ foo: "bar", baz: "bam", kel: { tok: "zam" } }).to.equal({ foo: { bar: "baz" } });
69+
expect({ foo: "bar", baz: "bam", kel: { tok: "zam" } }).to.equal({
70+
foo: { bar: "baz" },
71+
});
7072
});
7173
it("A Failing Test Using Assert", function () {
7274
assert.ok(false);
@@ -174,7 +176,8 @@ function registerSnapshotTestBatch(quench: Quench) {
174176
"Some Test ¯\\_(ツ)_/¯".should.matchSnapshot();
175177
});
176178
it("Passing Test using temporary actor", function () {
177-
const type = Object.keys(game.system?.documentTypes.Actor ?? { base: "" })[0];
179+
const type = Object.keys(Actor.TYPES[0] ?? { base: "" })[0];
180+
if (!type) throw new Error("No type found");
178181
// @ts-expect-error -- Some type has to exist
179182
const actor = new Actor({ name: "Test Actor", type });
180183
expect(actor).to.matchSnapshot();

src/module/quench.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ export class Quench {
179179
const { displayName, snapBaseDir, preSelected } = context;
180180
const [packageName] = getBatchNameParts(key);
181181

182-
if (![...getGame().modules.keys(), getGame().system.id].includes(packageName)) {
182+
if (![...(game.modules?.keys() ?? []), game.system?.id || ""].includes(packageName)) {
183183
ui?.notifications?.error(localize("ERROR.InvalidPackageName", { key, packageName }));
184184
}
185185
if (this._testBatches.has(key)) {

src/module/settings.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ declare global {
1717
* Registers all settings
1818
*/
1919
export function registerSettings(): void {
20-
const game = getGame();
20+
if (!(game instanceof Game)) throw new Error("Game is not initialized");
2121

2222
game.settings.register(MODULE_ID, "logTestDetails", {
2323
name: "QUENCH.LogTestDetailsLabel",

src/module/utils/quench-utils.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ export const MODULE_ID = "quench" as const;
119119
/** Ensures {@link game} is initialized, either returning the {@link Game} instance or throwing an error. */
120120
export function getGame() {
121121
if (!(game instanceof Game)) throw new Error("Game is not initialized yet!");
122-
return game as ReadyGame;
122+
return game;
123123
}
124124

125125
/**
@@ -152,7 +152,7 @@ export function enforce(value: unknown, message?: string | Error): asserts value
152152
* @returns The localized string
153153
*/
154154
export function localize(key: string, data?: Record<string, unknown>): string {
155-
return getGame().i18n.format(`QUENCH.${key}`, data);
155+
return game.i18n?.format(`QUENCH.${key}`, data) ?? key;
156156
}
157157

158158
/**

src/styles/quench.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@
155155
margin-left: 0.4rem;
156156
}
157157

158-
#quench-results li>.summary>.status-icon:not(".fa-sync") {
158+
#quench-results li>.summary>.status-icon:not(.fa-sync) {
159159
font-weight: normal;
160160
}
161161

tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"exactOptionalPropertyTypes": true,
1010
"strict": true,
1111
"lib": ["DOM", "DOM.Iterable", "ES2023"],
12-
"skipLibCheck": true,
12+
"skipLibCheck": false,
1313
"noEmit": true
1414
},
1515
"exclude": ["dist", "foundry"],

0 commit comments

Comments
 (0)