From f8dee7e25f8816d913b0e1e7da54f13c57e728d5 Mon Sep 17 00:00:00 2001 From: Marc-Andre Ferland Date: Thu, 8 Dec 2022 00:27:50 -0500 Subject: [PATCH] Add test sample to one of the plugin. (#626) * Added test example from a plugin. * Only load style if #news was created. --- ui/plugins/ui/release-notes.plugin.js | 31 ++++++++++++++++++--------- 1 file changed, 21 insertions(+), 10 deletions(-) diff --git a/ui/plugins/ui/release-notes.plugin.js b/ui/plugins/ui/release-notes.plugin.js index 9cd07659..cfe2b338 100644 --- a/ui/plugins/ui/release-notes.plugin.js +++ b/ui/plugins/ui/release-notes.plugin.js @@ -1,4 +1,14 @@ (function() { + // Register selftests when loaded by jasmine. + if (typeof PLUGINS?.SELFTEST === 'object') { + PLUGINS.SELFTEST["release-notes"] = function() { + it('should be able to fetch CHANGES.md', async function() { + let releaseNotes = await fetch(`https://raw.githubusercontent.com/cmdr2/stable-diffusion-ui/main/CHANGES.md`) + expect(releaseNotes.status).toBe(200) + }) + } + } + document.querySelector('#tab-container')?.insertAdjacentHTML('beforeend', ` What's new? @@ -13,7 +23,17 @@ `) - document.querySelector('body')?.insertAdjacentHTML('beforeend', ` + const tabNews = document.querySelector('#tab-news') + if (tabNews) { + linkTabContents(tabNews) + } + const news = document.querySelector('#news') + if (!news) { + // news tab not found, dont exec plugin code. + return + } + + document.querySelector('body').insertAdjacentHTML('beforeend', ` `) - const tabNews = document.querySelector('#tab-news') - if (tabNews) { - linkTabContents(tabNews) - } - const news = document.querySelector('#news') - if (!news) { - return - } - const markedScript = document.createElement('script') markedScript.src = '/media/js/marked.min.js'