DEV: Load svg icons in dev-environment qunit tests (#24542)
Making the icons available generally in tests is tricky because they're generated dynamically by the rails server. However, if we restrict it to dev-mode (`/tests` in a browser) then it's possible to load them from the running rails server. This is purely a visual thing to make debugging easier - it should not affect test behavior.
This commit is contained in:
parent
46782a9f1c
commit
0253cba9be
|
@ -42,6 +42,8 @@
|
||||||
</style>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
<discourse-assets-icons></discourse-assets-icons>
|
||||||
|
|
||||||
{{content-for "body"}} {{content-for "test-body"}}
|
{{content-for "body"}} {{content-for "test-body"}}
|
||||||
|
|
||||||
<script src="/testem.js" integrity="" data-embroider-ignore></script>
|
<script src="/testem.js" integrity="" data-embroider-ignore></script>
|
||||||
|
|
|
@ -46,6 +46,7 @@ import { setDefaultOwner } from "discourse-common/lib/get-owner";
|
||||||
import { setupS3CDN, setupURL } from "discourse-common/lib/get-url";
|
import { setupS3CDN, setupURL } from "discourse-common/lib/get-url";
|
||||||
import { buildResolver } from "discourse-common/resolver";
|
import { buildResolver } from "discourse-common/resolver";
|
||||||
import Application from "../app";
|
import Application from "../app";
|
||||||
|
import { loadSprites } from "../lib/svg-sprite-loader";
|
||||||
|
|
||||||
const Plugin = $.fn.modal;
|
const Plugin = $.fn.modal;
|
||||||
const Modal = Plugin.Constructor;
|
const Modal = Plugin.Constructor;
|
||||||
|
@ -394,6 +395,14 @@ export default function setupTests(config) {
|
||||||
setupToolbar();
|
setupToolbar();
|
||||||
reportMemoryUsageAfterTests();
|
reportMemoryUsageAfterTests();
|
||||||
patchFailedAssertion();
|
patchFailedAssertion();
|
||||||
|
if (!window.Testem) {
|
||||||
|
// Running in a dev server - svg sprites are available
|
||||||
|
// Using a fake 40-char version hash will redirect to the current one
|
||||||
|
loadSprites(
|
||||||
|
"/svg-sprite/localhost/svg--aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.js",
|
||||||
|
"fontawesome"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
if (!hasPluginJs && !hasThemeJs) {
|
if (!hasPluginJs && !hasThemeJs) {
|
||||||
configureRaiseOnDeprecation();
|
configureRaiseOnDeprecation();
|
||||||
|
|
Loading…
Reference in New Issue