From c836d65f445bd02bf2a0e40a7c705be37e40fb23 Mon Sep 17 00:00:00 2001 From: Ticktock Depbot Date: Sun, 29 Dec 2024 13:22:16 +0000 Subject: [PATCH 1/3] Update fontsource monorepo to v5.1.1 --- yarn.lock | 19 +------------------ 1 file changed, 1 insertion(+), 18 deletions(-) diff --git a/yarn.lock b/yarn.lock index 185197e..3224779 100644 --- a/yarn.lock +++ b/yarn.lock @@ -334,24 +334,7 @@ levn "^0.4.1" "@fontsource/antonio@^5.1.0": - version "5.1.0" - resolved "https://registry.yarnpkg.com/@fontsource/antonio/-/antonio-5.1.0.tgz#e3159a104d364629852ffc5170764f619a8c5754" - integrity sha512-5FHPDnNXhLg/ccgTSOzqL0v8TqUIYw+HXYXVKsA97dYXm+SpkypXW/R/bTe8eNHVarnNRfYkhYyZq6dKA9/vGQ== - -"@fontsource/oswald@^5.1.0": - version "5.1.0" - resolved "https://registry.yarnpkg.com/@fontsource/oswald/-/oswald-5.1.0.tgz#00fdbe5ab911bfb261ec26e565eb51d02cb95095" - integrity sha512-MwHMRCNCeTvaUWk15AHVfUi84T4TB4dshJrCOcfBYqUkY0V8IxKEwqFzSgGBG7zIfTZ0Diu+/CKpiktKqo5Gkg== - -"@fontsource/ubuntu@^5.1.0": - version "5.1.0" - resolved "https://registry.yarnpkg.com/@fontsource/ubuntu/-/ubuntu-5.1.0.tgz#aad73a6540659e1005e181029cb3f5efd06a438f" - integrity sha512-0XG/HrFsfP1q3phf4QN8IO7tetd0zOZKHZSHcTnBuVoQedoo1wS/hXxY2FMZuqoG+mVfrXh+Q614MDVmQPJq2w== - -"@formatjs/ecma402-abstract@2.2.0": - version "2.2.0" - resolved "https://registry.yarnpkg.com/@formatjs/ecma402-abstract/-/ecma402-abstract-2.2.0.tgz#36f5bc0dac4ca77ca429fe44bd95b32d5ccd98dd" - integrity sha512-IpM+ev1E4QLtstniOE29W1rqH9eTdx5hQdNL8pzrflMj/gogfaoONZqL83LUeQScHAvyMbpqP5C9MzNf+fFwhQ== + version "5.1.1" dependencies: "@formatjs/fast-memoize" "2.2.1" "@formatjs/intl-localematcher" "0.5.5" From 0041ec3d9a174955383836bba02caf79f3961072 Mon Sep 17 00:00:00 2001 From: Djuri Baars Date: Mon, 30 Dec 2024 00:50:33 +0100 Subject: [PATCH 2/3] Create testing specific vite config, add multi font support, bugfixes --- package.json | 1 + playwright.config.ts | 2 +- .../settings/DisplaySettings.svelte | 17 +++++++++-- src/lib/locales/de.json | 3 +- src/lib/locales/en.json | 3 +- src/lib/locales/es.json | 3 +- src/lib/locales/nl.json | 3 +- src/routes/+page.svelte | 1 - src/routes/Settings.svelte | 8 +++-- src/routes/Status.svelte | 2 +- tests/shared.ts | 29 +++++++++++++++---- vite.config.test.ts | 18 ++++++++++++ 12 files changed, 73 insertions(+), 17 deletions(-) create mode 100644 vite.config.test.ts diff --git a/package.json b/package.json index f8893ae..f2bd1b0 100644 --- a/package.json +++ b/package.json @@ -5,6 +5,7 @@ "scripts": { "dev": "vite dev", "build": "vite build", + "build:test": "vite build --config vite.config.test.ts", "preview": "vite preview", "check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json", "check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch", diff --git a/playwright.config.ts b/playwright.config.ts index bf148ce..461f3c2 100644 --- a/playwright.config.ts +++ b/playwright.config.ts @@ -6,7 +6,7 @@ const config: PlaywrightTestConfig = { timezoneId: 'Europe/Amsterdam' }, webServer: { - command: 'npm run build && npm run preview', + command: 'npm run build:test && npm run preview', port: 4173 }, reporter: process.env.CI ? 'github' : 'list', diff --git a/src/lib/components/settings/DisplaySettings.svelte b/src/lib/components/settings/DisplaySettings.svelte index e391a8c..7653298 100644 --- a/src/lib/components/settings/DisplaySettings.svelte +++ b/src/lib/components/settings/DisplaySettings.svelte @@ -20,14 +20,19 @@ const setTextColor = () => { $settings.invertedColor = !$settings.invertedColor; - $settings.fgColor = $settings.invertedColor ? 65535 : 0; - $settings.bgColor = $settings.invertedColor ? 0 : 65535; }; const textColorOptions: [string, boolean][] = [ [$_('colors.black') + ' on ' + $_('colors.white'), false], [$_('colors.white') + ' on ' + $_('colors.black'), true] ]; + + const fontPreferenceOptions: [string, string][] = $settings.availableFonts?.map((font) => [ + $_(`fonts.${font}`) !== `fonts.${font}` + ? $_(`fonts.${font}`) + : font.charAt(0).toUpperCase() + font.slice(1), + font + ]); @@ -45,6 +50,14 @@ on:change={setTextColor} /> + + { - console.log('Connecting to EventSource'); const evtSource = new EventSource(`${PUBLIC_BASE_URL}/events`); evtSource.addEventListener('status', (e) => { diff --git a/src/routes/Settings.svelte b/src/routes/Settings.svelte index 17a5df1..6d9b932 100644 --- a/src/routes/Settings.svelte +++ b/src/routes/Settings.svelte @@ -114,9 +114,13 @@
- + | - +
{$_('section.settings.title')} diff --git a/src/routes/Status.svelte b/src/routes/Status.svelte index c2ce212..e889a0b 100644 --- a/src/routes/Status.svelte +++ b/src/routes/Status.svelte @@ -158,7 +158,7 @@
{#if $status.data}
- {#if $status.isUpdating === false && $status.isFake === false} + {#if $status.isUpdating === false && ($status.isFake ?? false) === false}
diff --git a/tests/shared.ts b/tests/shared.ts index 9239f2e..821f202 100644 --- a/tests/shared.ts +++ b/tests/shared.ts @@ -108,8 +108,10 @@ export const settingsJson = { 'ckpool', 'eu_ckpool' ], + availableFonts: ['antonio', 'oswald'], invertedColor: false, - isLoaded: true + isLoaded: true, + isFake: true }; export const latestReleaseFake = { @@ -167,16 +169,31 @@ export const initMock = async ({ page }) => { await route.fulfill({ json: settingsJson }); }); - await page.route('**/events', (route) => { + await page.route('**/events', async (route) => { const newStatus = statusJson; newStatus.data = ['BLOCK/HEIGHT', '8', '0', '0', '8', '1', '5']; newStatus.isUpdating = true; - // Respond with a custom SSE message - route.fulfill({ + // Format the SSE message correctly + const sseMessage = `data: ${JSON.stringify(newStatus)}\n\n`; + + // Create a readable stream for SSE + const stream = new ReadableStream({ + start(controller) { + controller.enqueue(new TextEncoder().encode(sseMessage)); + // Keep the connection open + // controller.close(); // Don't close if you want to send more events + } + }); + + await route.fulfill({ status: 200, - contentType: 'text/event-stream', - json: `${JSON.stringify(newStatus)}\n\n` + headers: { + 'Content-Type': 'text/event-stream', + 'Cache-Control': 'no-cache', + Connection: 'keep-alive' + }, + body: stream }); }); diff --git a/vite.config.test.ts b/vite.config.test.ts new file mode 100644 index 0000000..3e03c63 --- /dev/null +++ b/vite.config.test.ts @@ -0,0 +1,18 @@ +import { sveltekit } from '@sveltejs/kit/vite'; +import { defineConfig } from 'vite'; + +export default defineConfig({ + plugins: [sveltekit()], + build: { + sourcemap: true, + minify: false, + rollupOptions: { + output: { + manualChunks: undefined // Disable code splitting + } + } + }, + test: { + include: ['tests/**/*.{test,spec}.{js,ts}'] + } +}); From b05ff916ca0099fe1369027f7779dc5770123cb8 Mon Sep 17 00:00:00 2001 From: Ticktock Depbot Date: Sun, 29 Dec 2024 23:52:09 +0000 Subject: [PATCH 3/3] Update fontsource monorepo to v5.1.1 --- yarn.lock | 19 +------------------ 1 file changed, 1 insertion(+), 18 deletions(-) diff --git a/yarn.lock b/yarn.lock index 185197e..3224779 100644 --- a/yarn.lock +++ b/yarn.lock @@ -334,24 +334,7 @@ levn "^0.4.1" "@fontsource/antonio@^5.1.0": - version "5.1.0" - resolved "https://registry.yarnpkg.com/@fontsource/antonio/-/antonio-5.1.0.tgz#e3159a104d364629852ffc5170764f619a8c5754" - integrity sha512-5FHPDnNXhLg/ccgTSOzqL0v8TqUIYw+HXYXVKsA97dYXm+SpkypXW/R/bTe8eNHVarnNRfYkhYyZq6dKA9/vGQ== - -"@fontsource/oswald@^5.1.0": - version "5.1.0" - resolved "https://registry.yarnpkg.com/@fontsource/oswald/-/oswald-5.1.0.tgz#00fdbe5ab911bfb261ec26e565eb51d02cb95095" - integrity sha512-MwHMRCNCeTvaUWk15AHVfUi84T4TB4dshJrCOcfBYqUkY0V8IxKEwqFzSgGBG7zIfTZ0Diu+/CKpiktKqo5Gkg== - -"@fontsource/ubuntu@^5.1.0": - version "5.1.0" - resolved "https://registry.yarnpkg.com/@fontsource/ubuntu/-/ubuntu-5.1.0.tgz#aad73a6540659e1005e181029cb3f5efd06a438f" - integrity sha512-0XG/HrFsfP1q3phf4QN8IO7tetd0zOZKHZSHcTnBuVoQedoo1wS/hXxY2FMZuqoG+mVfrXh+Q614MDVmQPJq2w== - -"@formatjs/ecma402-abstract@2.2.0": - version "2.2.0" - resolved "https://registry.yarnpkg.com/@formatjs/ecma402-abstract/-/ecma402-abstract-2.2.0.tgz#36f5bc0dac4ca77ca429fe44bd95b32d5ccd98dd" - integrity sha512-IpM+ev1E4QLtstniOE29W1rqH9eTdx5hQdNL8pzrflMj/gogfaoONZqL83LUeQScHAvyMbpqP5C9MzNf+fFwhQ== + version "5.1.1" dependencies: "@formatjs/fast-memoize" "2.2.1" "@formatjs/intl-localematcher" "0.5.5"