-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add template resolver for a new location for uswds templates #400
Changes from 4 commits
5bfa581
5162f1d
8619f57
79d75fd
91beaaf
8494785
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<th:block th:fragment="headLinks"> | ||
<!-- CFA USWDS Links --> | ||
</th:block> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package formflow.library.config; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
import java.util.Objects; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.boot.autoconfigure.ImportAutoConfiguration; | ||
import org.springframework.boot.autoconfigure.thymeleaf.ThymeleafAutoConfiguration; | ||
import org.springframework.boot.test.context.SpringBootTest; | ||
import org.thymeleaf.TemplateEngine; | ||
import org.junit.jupiter.api.Test; | ||
|
||
@ImportAutoConfiguration(ThymeleafAutoConfiguration.class) | ||
@SpringBootTest(classes = {ThymeleafConfiguration.class}, properties = {"form-flow.design-system.name=cfa-uswds"}) | ||
public class ThymeleafConfigurationLoadedTest { | ||
|
||
@Autowired | ||
private TemplateEngine templateEngine; | ||
|
||
@Test | ||
void checkThatUSWDSTemplateResolverIsLoaded() { | ||
assertThat(templateEngine.getTemplateResolvers().size()).isEqualTo(2); | ||
var uswdsResolver = templateEngine.getTemplateResolvers().stream() | ||
.filter(x -> Objects.equals(x.getName(), "org.thymeleaf.templateresolver.ClassLoaderTemplateResolver")).findFirst(); | ||
assertThat(uswdsResolver).isPresent(); | ||
} | ||
} |
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I ran into this same issue when setting application properties with regards to whether or not to scan file uploads with ClamAV. I could not figure out a way to have different application properties on a test by test basis, even with nested classes. I hate that it has to be done this way as two seperate tests, and I hate even more that I have to ask: Do we want a third test that tests it defaults to Honeycrisp when no application property is set? |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package formflow.library.config; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
import java.util.Objects; | ||
import org.junit.jupiter.api.Test; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.boot.autoconfigure.ImportAutoConfiguration; | ||
import org.springframework.boot.autoconfigure.thymeleaf.ThymeleafAutoConfiguration; | ||
import org.springframework.boot.test.context.SpringBootTest; | ||
import org.thymeleaf.TemplateEngine; | ||
|
||
@ImportAutoConfiguration(ThymeleafAutoConfiguration.class) | ||
@SpringBootTest(classes = {ThymeleafConfiguration.class}, properties = {"form-flow.design-system.name=honeycrisp"}) | ||
public class ThymeleafConfigurationUnloadedTest { | ||
|
||
@Autowired | ||
private TemplateEngine templateEngine; | ||
|
||
@Test | ||
void checkThatUSWDSTemplateResolverIsLoaded() { | ||
assertThat(templateEngine.getTemplateResolvers().size()).isEqualTo(1); | ||
var uswdsResolver = templateEngine.getTemplateResolvers().stream() | ||
.filter(x -> Objects.equals(x.getName(), "org.thymeleaf.templateresolver.ClassLoaderTemplateResolver")).findFirst(); | ||
assertThat(uswdsResolver).isNotPresent(); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I might reword this. If I'm correct, it's actually setting the UWDS resolver to be used over the default, meaning that enabling it would turn on the USWDS resolver, but those templates will now replace the same ones from the Honeycrisp resolver? Meaning that turning this on will switch your application to using USWDS styles and components instead of Honeycrisp styles and components.