|
| 1 | +package com.openelements.content; |
| 2 | + |
| 3 | +import static org.assertj.core.api.Assertions.assertThat; |
| 4 | + |
| 5 | +import java.util.Map; |
| 6 | +import java.util.function.Function; |
| 7 | +import java.util.stream.Collectors; |
| 8 | +import org.junit.jupiter.api.DisplayName; |
| 9 | +import org.junit.jupiter.api.Test; |
| 10 | +import org.springframework.beans.factory.annotation.Autowired; |
| 11 | +import org.springframework.boot.test.context.SpringBootTest; |
| 12 | + |
| 13 | +/** |
| 14 | + * Verifies that the website sources are bound from {@code application.yaml} with no code — the point |
| 15 | + * of spec 015 (hiero.org/blog and Support & Care are added purely as configuration). |
| 16 | + * |
| 17 | + * <p>Shares the application context of the other {@code api-key.enabled=false} tests. The actual crawl |
| 18 | + * and extraction against the live sites are verified manually against a dev index. |
| 19 | + */ |
| 20 | +@SpringBootTest(properties = "openelements.mcp.auth.api-key.enabled=false") |
| 21 | +@DisplayName("Configured website sources") |
| 22 | +class ConfiguredSourcesTest { |
| 23 | + |
| 24 | + @Autowired |
| 25 | + private ContentSourceProperties properties; |
| 26 | + |
| 27 | + private Map<String, ContentSource> sourcesById() { |
| 28 | + return properties.sources().stream() |
| 29 | + .collect(Collectors.toMap(ContentSource::id, Function.identity())); |
| 30 | + } |
| 31 | + |
| 32 | + @Test |
| 33 | + @DisplayName("open-elements, hiero and support-and-care are all configured") |
| 34 | + void allSourcesAreConfigured() { |
| 35 | + assertThat(sourcesById()).containsKeys("open-elements", "hiero", "support-and-care"); |
| 36 | + } |
| 37 | + |
| 38 | + @Test |
| 39 | + @DisplayName("the hiero source targets /blog via the sitemap with the article selector") |
| 40 | + void hieroSourceIsConfigured() { |
| 41 | + ContentSource hiero = sourcesById().get("hiero"); |
| 42 | + assertThat(hiero.type()).isEqualTo(SourceType.WEBSITE); |
| 43 | + assertThat(hiero.baseUrl()).isEqualTo("https://hiero.org"); |
| 44 | + assertThat(hiero.sitemaps()).containsExactly("/sitemap.xml"); |
| 45 | + assertThat(hiero.urlInclude()).containsExactly("/blog/**"); |
| 46 | + assertThat(hiero.contentSelector()).isEqualTo("main article"); |
| 47 | + assertThat(hiero.enabled()).isTrue(); |
| 48 | + } |
| 49 | + |
| 50 | + @Test |
| 51 | + @DisplayName("the support-and-care source scopes to the /en/support-care pages with body + excludes") |
| 52 | + void supportAndCareSourceIsConfigured() { |
| 53 | + ContentSource support = sourcesById().get("support-and-care"); |
| 54 | + assertThat(support.baseUrl()).isEqualTo("https://open-elements.com"); |
| 55 | + assertThat(support.urlInclude()).contains("/en/support-care*"); |
| 56 | + assertThat(support.contentSelector()).isEqualTo("body"); |
| 57 | + assertThat(support.contentExclude()).contains("nav", "header", "footer", ".cookie-banner"); |
| 58 | + } |
| 59 | +} |
0 commit comments