Skip to content

Commit 311a211

Browse files
committed
PR_26171_013 Game Journey completion insights
1 parent e9587e1 commit 311a211

2 files changed

Lines changed: 50 additions & 0 deletions

File tree

tests/playwright/tools/GameJourneyTool.spec.mjs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,13 @@ test("Game Journey progress dashboard summarizes completion metrics", async ({ p
282282
await expect(page.locator("[data-journey-most-complete-areas] li").first()).toHaveText("Idea: 0% complete (0 of 4)");
283283
await expect(page.locator("[data-journey-least-complete-areas] li")).toHaveCount(3);
284284
await expect(page.locator("[data-journey-least-complete-areas] li").first()).toHaveText("Idea: 0% complete (0 of 4)");
285+
await expect(page.locator("[data-journey-completion-insights] li")).toHaveText([
286+
"Completion is low because no planned items are complete yet.",
287+
"4 sections are inactive, so they are visible as planning context but not active focus areas.",
288+
"Idea is one of the most complete areas with 0 of 4 planned items complete.",
289+
"Idea needs attention with 0 of 4 planned items complete.",
290+
"Mark a section item complete to move overall progress above 0%.",
291+
]);
285292
await expect(page.locator("[data-journey-recommended-target]")).toHaveCount(4);
286293
await expect(page.locator("[data-journey-recommended-target='heroes'] td").nth(0)).toHaveText("Heroes");
287294
await expect(page.locator("[data-journey-recommended-target='heroes'] td").nth(1)).toHaveText("Objects");

toolbox/game-journey/game-journey.js

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -811,6 +811,13 @@ function renderCompletionMetrics() {
811811
}));
812812
});
813813

814+
const insightHeading = createElement("h3", { text: "Completion Insights" });
815+
const insightList = createElement("ul");
816+
insightList.dataset.journeyCompletionInsights = "";
817+
completionInsightMessages(completionMetricsSnapshot, records, mostComplete, leastComplete).forEach((message) => {
818+
insightList.append(createElement("li", { text: message }));
819+
});
820+
814821
dashboard.append(
815822
summary,
816823
overallHeading,
@@ -821,6 +828,8 @@ function renderCompletionMetrics() {
821828
mostList,
822829
leastHeading,
823830
leastList,
831+
insightHeading,
832+
insightList,
824833
);
825834
completionMetrics.append(dashboard);
826835
}
@@ -833,6 +842,40 @@ function normalizeTargetCount(value) {
833842
return Math.max(0, Math.trunc(parsed));
834843
}
835844

845+
function completionInsightMessages(snapshot, records, mostComplete, leastComplete) {
846+
const messages = [];
847+
if (!snapshot?.plannedCount) {
848+
messages.push("Completion is low because no planned section targets are available yet.");
849+
return messages;
850+
}
851+
852+
if (snapshot.percentComplete === 0) {
853+
messages.push("Completion is low because no planned items are complete yet.");
854+
} else if (snapshot.percentComplete < 50) {
855+
messages.push("Completion is low because fewer than half of the planned items are complete.");
856+
} else if (snapshot.percentComplete >= 80) {
857+
messages.push("Completion is high because most planned items are already complete.");
858+
} else {
859+
messages.push("Completion is growing because completed items are catching up to planned items.");
860+
}
861+
862+
if (snapshot.inactiveCount > 0) {
863+
messages.push(`${snapshot.inactiveCount} section${snapshot.inactiveCount === 1 ? "" : "s"} are inactive, so they are visible as planning context but not active focus areas.`);
864+
}
865+
const strongest = mostComplete[0];
866+
if (strongest) {
867+
messages.push(`${strongest.bucketName} is one of the most complete areas with ${strongest.completedCount} of ${strongest.plannedCount} planned items complete.`);
868+
}
869+
const weakest = leastComplete.find((metric) => metric.plannedCount > 0);
870+
if (weakest) {
871+
messages.push(`${weakest.bucketName} needs attention with ${weakest.completedCount} of ${weakest.plannedCount} planned items complete.`);
872+
}
873+
if (records.every((metric) => metric.completedCount === 0)) {
874+
messages.push("Mark a section item complete to move overall progress above 0%.");
875+
}
876+
return messages;
877+
}
878+
836879
function renderRecommendedTargets() {
837880
if (!recommendedTargets) {
838881
return;

0 commit comments

Comments
 (0)