From 8dfce21cfe560f8ae59c52c65b1f0f7d5d7d0e3d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Radan=20Skori=C4=87?= Date: Fri, 24 May 2024 16:33:13 +0200 Subject: [PATCH] Add a test that stream actions rendered into the HTML are executed As a consequence of the fundamental way in which Stream actions are implemented, they can also be executed by rendering them within any HTML that's included on the dom. Since this is already being used as the feature in the community, adding this test will ensure this keeps working. --- src/tests/functional/stream_tests.js | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/tests/functional/stream_tests.js b/src/tests/functional/stream_tests.js index 5c77016d8..0170f31c3 100644 --- a/src/tests/functional/stream_tests.js +++ b/src/tests/functional/stream_tests.js @@ -226,6 +226,25 @@ test("preventing a turbo:before-morph-element prevents the morph", async ({ page await expect(page.locator("#message_1")).toHaveText("Morph me") }) +test("rendering a stream message into the HTML executes it", async ({ page }) => { + await page.evaluate(() => { + document.body.insertAdjacentHTML( + "afterbegin", + ` + + + + ` + ) + }) + await nextBeat() + + const messages = await page.locator("#messages .message") + assert.deepEqual(await messages.allTextContents(), ["First", "Hello world!"]) +}) + async function getReadyState(page, id) { return page.evaluate((id) => { const element = document.getElementById(id)