Create testing specific vite config, add multi font support, bugfixes
All checks were successful
/ check-changes (push) Successful in 18s
/ build (push) Successful in 3m49s

This commit is contained in:
Djuri 2024-12-30 00:50:33 +01:00
parent 48e585d4ec
commit 0041ec3d9a
12 changed files with 73 additions and 17 deletions

View file

@ -5,6 +5,7 @@
"scripts": { "scripts": {
"dev": "vite dev", "dev": "vite dev",
"build": "vite build", "build": "vite build",
"build:test": "vite build --config vite.config.test.ts",
"preview": "vite preview", "preview": "vite preview",
"check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json", "check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
"check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch", "check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch",

View file

@ -6,7 +6,7 @@ const config: PlaywrightTestConfig = {
timezoneId: 'Europe/Amsterdam' timezoneId: 'Europe/Amsterdam'
}, },
webServer: { webServer: {
command: 'npm run build && npm run preview', command: 'npm run build:test && npm run preview',
port: 4173 port: 4173
}, },
reporter: process.env.CI ? 'github' : 'list', reporter: process.env.CI ? 'github' : 'list',

View file

@ -20,14 +20,19 @@
const setTextColor = () => { const setTextColor = () => {
$settings.invertedColor = !$settings.invertedColor; $settings.invertedColor = !$settings.invertedColor;
$settings.fgColor = $settings.invertedColor ? 65535 : 0;
$settings.bgColor = $settings.invertedColor ? 0 : 65535;
}; };
const textColorOptions: [string, boolean][] = [ const textColorOptions: [string, boolean][] = [
[$_('colors.black') + ' on ' + $_('colors.white'), false], [$_('colors.black') + ' on ' + $_('colors.white'), false],
[$_('colors.white') + ' on ' + $_('colors.black'), true] [$_('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
]);
</script> </script>
<Row> <Row>
@ -45,6 +50,14 @@
on:change={setTextColor} on:change={setTextColor}
/> />
<SettingsSelect
id="fontName"
label={$_('section.settings.fontName')}
bind:value={$settings.fontName}
options={fontPreferenceOptions}
size={$uiSettings.inputSize}
/>
<SettingsInput <SettingsInput
id="timePerScreen" id="timePerScreen"
label={$_('section.settings.timePerScreen')} label={$_('section.settings.timePerScreen')}

View file

@ -67,7 +67,8 @@
"dataSource": { "dataSource": {
"nostr": "Nostr-Verlag", "nostr": "Nostr-Verlag",
"custom": "Benutzerdefinierter dataquelle" "custom": "Benutzerdefinierter dataquelle"
} },
"fontName": "Schriftart"
}, },
"control": { "control": {
"systemInfo": "Systeminfo", "systemInfo": "Systeminfo",

View file

@ -84,7 +84,8 @@
}, },
"thirdPartySource": "Use mempool.space/coincap.io", "thirdPartySource": "Use mempool.space/coincap.io",
"ceDisableSSL": "Disable SSL", "ceDisableSSL": "Disable SSL",
"ceEndpoint": "Endpoint hostname" "ceEndpoint": "Endpoint hostname",
"fontName": "Font"
}, },
"control": { "control": {
"systemInfo": "System info", "systemInfo": "System info",

View file

@ -66,7 +66,8 @@
"dataSource": { "dataSource": {
"nostr": "editorial nostr", "nostr": "editorial nostr",
"custom": "Punto final personalizado" "custom": "Punto final personalizado"
} },
"fontName": "Fuente"
}, },
"control": { "control": {
"turnOff": "Apagar", "turnOff": "Apagar",

View file

@ -58,7 +58,8 @@
"hideAll": "Alles verbergen", "hideAll": "Alles verbergen",
"flOffWhenDark": "Displaylicht uit als het donker is", "flOffWhenDark": "Displaylicht uit als het donker is",
"luxLightToggleText": "Stel in op 0 om uit te schakelen", "luxLightToggleText": "Stel in op 0 om uit te schakelen",
"verticalDesc": "Verticale schermbeschrijving" "verticalDesc": "Verticale schermbeschrijving",
"fontName": "Lettertype"
}, },
"control": { "control": {
"systemInfo": "Systeeminformatie", "systemInfo": "Systeeminformatie",

View file

@ -105,7 +105,6 @@
setupObserver(); setupObserver();
const connectEventSource = () => { const connectEventSource = () => {
console.log('Connecting to EventSource');
const evtSource = new EventSource(`${PUBLIC_BASE_URL}/events`); const evtSource = new EventSource(`${PUBLIC_BASE_URL}/events`);
evtSource.addEventListener('status', (e) => { evtSource.addEventListener('status', (e) => {

View file

@ -114,9 +114,13 @@
<CardHeader> <CardHeader>
<div class="float-end"> <div class="float-end">
<small> <small>
<button type="button" on:click={showAll}>{$_('section.settings.showAll')}</button> <button type="button" on:click={showAll} id="showAllBtn"
>{$_('section.settings.showAll')}</button
>
| |
<button type="button" on:click={hideAll}>{$_('section.settings.hideAll')}</button> <button type="button" on:click={hideAll} id="hideAllBtn"
>{$_('section.settings.hideAll')}</button
>
</small> </small>
</div> </div>
<CardTitle>{$_('section.settings.title')}</CardTitle> <CardTitle>{$_('section.settings.title')}</CardTitle>

View file

@ -158,7 +158,7 @@
<hr /> <hr />
{#if $status.data} {#if $status.data}
<section class={lightMode ? 'lightMode' : 'darkMode'} style="position: relative;"> <section class={lightMode ? 'lightMode' : 'darkMode'} style="position: relative;">
{#if $status.isUpdating === false && $status.isFake === false} {#if $status.isUpdating === false && ($status.isFake ?? false) === false}
<div class="connection-lost-overlay"> <div class="connection-lost-overlay">
<div class="overlay-content"> <div class="overlay-content">
<i class="bi bi-wifi-off"></i> <i class="bi bi-wifi-off"></i>

View file

@ -108,8 +108,10 @@ export const settingsJson = {
'ckpool', 'ckpool',
'eu_ckpool' 'eu_ckpool'
], ],
availableFonts: ['antonio', 'oswald'],
invertedColor: false, invertedColor: false,
isLoaded: true isLoaded: true,
isFake: true
}; };
export const latestReleaseFake = { export const latestReleaseFake = {
@ -167,16 +169,31 @@ export const initMock = async ({ page }) => {
await route.fulfill({ json: settingsJson }); await route.fulfill({ json: settingsJson });
}); });
await page.route('**/events', (route) => { await page.route('**/events', async (route) => {
const newStatus = statusJson; const newStatus = statusJson;
newStatus.data = ['BLOCK/HEIGHT', '8', '0', '0', '8', '1', '5']; newStatus.data = ['BLOCK/HEIGHT', '8', '0', '0', '8', '1', '5'];
newStatus.isUpdating = true; newStatus.isUpdating = true;
// Respond with a custom SSE message // Format the SSE message correctly
route.fulfill({ 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, status: 200,
contentType: 'text/event-stream', headers: {
json: `${JSON.stringify(newStatus)}\n\n` 'Content-Type': 'text/event-stream',
'Cache-Control': 'no-cache',
Connection: 'keep-alive'
},
body: stream
}); });
}); });

18
vite.config.test.ts Normal file
View file

@ -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}']
}
});