Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion EssentialCSharp.Web.Tests/FunctionalTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,19 @@ public async Task WhenPagesAreAccessed_TheyReturnHtml(string relativeUrl)
await Assert.That(content).Contains("<html", StringComparison.OrdinalIgnoreCase);
}

[Test]
[Arguments("/guidelines", "window.PERCENT_COMPLETE = null;")]
public async Task WhenNonContentPageIsRendered_LayoutIncludesNullPercentComplete(string relativeUrl, string expectedSnippet)
{
HttpClient client = factory.CreateClient();
using HttpResponseMessage response = await client.GetAsync(relativeUrl);

await Assert.That(response.StatusCode).IsEqualTo(HttpStatusCode.OK);

string content = await response.Content.ReadAsStringAsync();
await Assert.That(content).Contains(expectedSnippet);
}

[Test]
public async Task WhenTheApplicationStarts_NonExistingPage_GivesCorrectStatusCode()
{
Expand All @@ -52,4 +65,4 @@ public async Task WhenTheApplicationStarts_NonExistingPage_GivesCorrectStatusCod

await Assert.That(response.StatusCode).IsEqualTo(HttpStatusCode.NotFound);
}
}
}
3 changes: 2 additions & 1 deletion EssentialCSharp.Web/src/composables/useSiteShell.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { computed, nextTick, onMounted, onUnmounted, reactive, ref, watch } from
import { useWindowSize } from "./useWindowSize.js";

const SMALL_SCREEN_SIZE = 768;
const NON_CONTENT_PERCENT_COMPLETE_VALUES = [null, "0.00"];

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

for (const item of currentPage) {
expandedTocs.add(item.key);
Expand Down
Loading