-
Notifications
You must be signed in to change notification settings - Fork 980
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix[gen2-sdks]: able to edit and preview when we have no content (#3726)
## Description Jira https://builder-io.atlassian.net/browse/PLAN-338 Fixes #3653 _Screenshot_ If relevant, add a screenshot or two of the changes you made.
- Loading branch information
1 parent
f37a36f
commit ebfd876
Showing
7 changed files
with
76 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
--- | ||
"@builder.io/sdk-qwik": patch | ||
"@builder.io/sdk-svelte": patch | ||
"@builder.io/sdk-vue": patch | ||
--- | ||
|
||
Fix: allow previewing and visual editing when content is null |
38 changes: 38 additions & 0 deletions
38
packages/sdks-tests/src/e2e-tests/editing-empty-content.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import { expect } from '@playwright/test'; | ||
import { test } from '../helpers/index.js'; | ||
import { launchEmbedderAndWaitForSdk, sendContentUpdateMessage } from '../helpers/visual-editor.js'; | ||
import { CONTENT } from '../specs/text-block.js'; | ||
import type { Sdk } from '../helpers/sdk.js'; | ||
|
||
test.describe('Editing empty content', () => { | ||
/** | ||
* We are ignoring hydration warnings here because this occurs in a specific scenario where we are either editing or previewing | ||
* and `content` provided is `null`. In this case, the `div` for `EnableEditor` is only attached on the client. | ||
*/ | ||
test.use({ ignoreHydrationErrors: true }); | ||
|
||
test('should be able to edit when content prop is not provided', async ({ | ||
page, | ||
sdk, | ||
basePort, | ||
}) => { | ||
const sdksUsingElementRefApproach = ['svelte', 'vue', 'qwik'] as Sdk[]; | ||
test.skip(!sdksUsingElementRefApproach.includes(sdk)); | ||
|
||
await launchEmbedderAndWaitForSdk({ | ||
// special page added only in nuxt e2e that doesn't pass `content` | ||
path: '/editing-empty-content-element-ref', | ||
page, | ||
sdk, | ||
basePort, | ||
}); | ||
|
||
await sendContentUpdateMessage({ | ||
page, | ||
newContent: CONTENT, | ||
model: 'page', | ||
}); | ||
|
||
await expect(page.frameLocator('iframe').getByText('Start of text box.')).toBeVisible(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters