Skip to content

Lazy Loading: Integration Tests #139

Description

@JeremyCaney

Unit tests already demonstrates that lazy loading works in isolation, but nothing yet demonstrates that it works a real web request: Routing, controller, view-model mapping, and response caching all working together. This adds a test that requests an actual page whose view renders lazily-loaded child pages, and confirms the child data shows up correctly in the response.

Tasks

  • Create a small seed dataset representing a page with lazily-loaded children (StubLazyLoadingTopicRepositoryBuilder)
  • Add a test view model with a Children collection and a matching view
    • New LazyContainerTopicViewModel in the Host's Models/,
    • New LazyContainer.cshtml in the Host's Views/LazyContainer/
    • Deliberately don't use a Body attribute for the proof; reading it doesn't reliably trigger the lazy fill, so a passing test could be a false negative
  • Add the integration test: Request the page, assert both children render, plus a "canary" assertion on the page's own title (new LazyLoadingPipelineTest, OnTopic.AspNetCore.Mvc.IntegrationTests)
  • (Optional) Add a fetch-count spy to independently confirm the data loaded exactly once (StubLazyLoadingTopicRepository.GetFetchCount())
  • Add the equivalent test for extended attribute (e.g., Body) content (dependent on Preload TopicPayload as part of MapAsync() #133)
  • Confirm the existing integration suite still passes unchanged

Metadata

Metadata

Assignees

Labels

Area: MappingRelates to one of the `ITopicMappingService` interfaces or implementations.Area: RepositoriesRelates to the `ITopicRepository` interface or one of its implementations.Priority: 1Severity 2: MajorStatus 2: ScheduledPlanned for an upcoming release.Type: ImprovementImproves the functionality or interface of an existing feature.

Type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions