Skip to content

Commit 388b144

Browse files
Clarify content page progress detection
Agent-Logs-Url: https://github.com/IntelliTect/EssentialCSharp.Web/sessions/f5be1600-71fd-4098-a682-ac672e0cd2d8 Co-authored-by: BenjaminMichaelis <22186029+BenjaminMichaelis@users.noreply.github.com>
1 parent e6d22c0 commit 388b144

2 files changed

Lines changed: 16 additions & 2 deletions

File tree

EssentialCSharp.Web.Tests/FunctionalTests.cs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,19 @@ public async Task WhenPagesAreAccessed_TheyReturnHtml(string relativeUrl)
4444
await Assert.That(content).Contains("<html", StringComparison.OrdinalIgnoreCase);
4545
}
4646

47+
[Test]
48+
[Arguments("/guidelines", "window.PERCENT_COMPLETE = null;")]
49+
public async Task WhenPagesAreRendered_LayoutIncludesExpectedPercentCompleteValue(string relativeUrl, string expectedSnippet)
50+
{
51+
HttpClient client = factory.CreateClient();
52+
using HttpResponseMessage response = await client.GetAsync(relativeUrl);
53+
54+
await Assert.That(response.StatusCode).IsEqualTo(HttpStatusCode.OK);
55+
56+
string content = await response.Content.ReadAsStringAsync();
57+
await Assert.That(content).Contains(expectedSnippet);
58+
}
59+
4760
[Test]
4861
public async Task WhenTheApplicationStarts_NonExistingPage_GivesCorrectStatusCode()
4962
{
@@ -52,4 +65,4 @@ public async Task WhenTheApplicationStarts_NonExistingPage_GivesCorrectStatusCod
5265

5366
await Assert.That(response.StatusCode).IsEqualTo(HttpStatusCode.NotFound);
5467
}
55-
}
68+
}

EssentialCSharp.Web/src/composables/useSiteShell.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { computed, nextTick, onMounted, onUnmounted, reactive, ref, watch } from
22
import { useWindowSize } from "./useWindowSize.js";
33

44
const SMALL_SCREEN_SIZE = 768;
5+
const NON_CONTENT_PERCENT_COMPLETE_VALUES = [null, "0.00"];
56

67
/**
78
* Find the path of TOC entries that lead to the current page.
@@ -71,7 +72,7 @@ export function useSiteShell() {
7172
const smallScreen = computed(() => (windowWidth.value || 0) < SMALL_SCREEN_SIZE);
7273
const currentPage = findCurrentPage([], tocData) ?? [];
7374
const chapterParentPage = currentPage.find((parent) => parent.level === 0) ?? null;
74-
const isContentPage = computed(() => percentComplete.value !== null);
75+
const isContentPage = computed(() => !NON_CONTENT_PERCENT_COMPLETE_VALUES.includes(percentComplete.value));
7576

7677
for (const item of currentPage) {
7778
expandedTocs.add(item.key);

0 commit comments

Comments
 (0)