nuvoleweb / ui_patterns

[NOTE] Development has moved to https://drupal.org/project/ui_patterns
https://drupal.org/project/ui_patterns
GNU General Public License v2.0
85 stars 56 forks source link

Support Multi-theme Sites #310

Closed WidgetsBurritos closed 2 years ago

WidgetsBurritos commented 3 years ago

Per issue in #308, this PR attempts to resolve the case where multiple themes are used on a site.

I created a separate test-only PR in #309 to demonstrate the issue.

Crossing my fingers that the tests pass here as I couldn't get the tests to run inside of my docker container due to some chrome issues, but really I'm just reusing existing tests, but starting off with a different default theme, and switching to the other theme after the fact.

WidgetsBurritos commented 3 years ago

I ended up killing the test for now. I got docker working locally but there's something strange going on I need to dig into. I also swapped the order of the path declarations:

   protected function getDirectories() {
     return $this->themeHandler->getThemeDirectories() + $this->moduleHandler->getModuleDirectories();
   }

Instead of

   protected function getDirectories() {
     return $this->moduleHandler->getModuleDirectories() + $this->themeHandler->getThemeDirectories();
   }

This seems to prevent the failure on the UiPatternsLibraryOverviewTest we got in the first run. I want to confirm everything works here now, and will sort out the theme switching test in a bit.

kp77 commented 3 years ago

Hi @WidgetsBurritos,

I debugged the failing test in UiPatternsLibraryOverviewTest with the original order for the union of the path arrays:

   protected function getDirectories() {
     return $this->moduleHandler->getModuleDirectories() + $this->themeHandler->getThemeDirectories();
   }

I found that the issue is that the order of the displayed patterns in the overview test is different when using the module paths + theme paths version. This can be fixed by moving the 3 theme patterns (simple, _withvariants and _with_custom_themehook) to the bottom of the file in modules/ui_patterns_library/tests/fixtures/overview-page-patterns.yml

By making this change in the fixture I could run all the tests without failures.