diff --git a/packages/svelte/tests/runtime-runes/samples/set-and-flushsync-conditionally-rendered-state/_config.js b/packages/svelte/tests/runtime-runes/samples/set-and-flushsync-conditionally-rendered-state/_config.js new file mode 100644 index 0000000000..66018e0b39 --- /dev/null +++ b/packages/svelte/tests/runtime-runes/samples/set-and-flushsync-conditionally-rendered-state/_config.js @@ -0,0 +1,33 @@ +import { flushSync } from 'svelte'; +import { test } from '../../test'; + +// This test does not fail when the fix is removed, some jsdom/nodejs quirk, this requires browser mode to be tested +export default test({ + html: `
flag : true
`, + + test({ assert, target }) { + const button = target.querySelector('button'); + + // Verify initial state - only first div visible + assert.htmlEqual( + target.innerHTML, + ` + +
flag : true
+ ` + ); + + // Click the button + flushSync(() => button?.click()); + + // Verify after click - both divs should be visible + assert.htmlEqual( + target.innerHTML, + ` + +
flag : false
+
boolElText : false
+ ` + ); + } +}); diff --git a/packages/svelte/tests/runtime-runes/samples/set-and-flushsync-conditionally-rendered-state/main.svelte b/packages/svelte/tests/runtime-runes/samples/set-and-flushsync-conditionally-rendered-state/main.svelte new file mode 100644 index 0000000000..6cf3f74188 --- /dev/null +++ b/packages/svelte/tests/runtime-runes/samples/set-and-flushsync-conditionally-rendered-state/main.svelte @@ -0,0 +1,22 @@ + + + + +
flag : {flag}
+ +{#if !flag} +
boolElText : {boolElText}
+{/if}