-
Notifications
You must be signed in to change notification settings - Fork 90
feat: sync files from WebContainer to editor #334
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 8 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
e1c74e2
feat: sync files from WebContainer to editor
Nemikolh 88ed116
chore(e2e): add e2e test
Nemikolh 609a103
fix: unit test
Nemikolh a7eb0d3
chore: update docs
Nemikolh 627c989
chore: add test for file in nested folder
Nemikolh f554f6f
Merge remote-tracking branch 'origin/main' into joan/sync-files-from-fs
Nemikolh 2a6b5d1
fix: lint issues
Nemikolh bf3b2f4
refactor: syncChanges -> watch
Nemikolh a33f2e6
Apply suggestions from code review
Nemikolh a865a1d
fix: code review
Nemikolh 21a87d3
fix: add test that it does not watch anything if not configured
Nemikolh c716577
Merge branch 'main' into joan/sync-files-from-fs
Nemikolh File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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
1 change: 1 addition & 0 deletions
1
e2e/src/content/tutorial/tests/filesystem-sync/happy-path/_files/a/b/baz.txt
This file contains hidden or 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 @@ | ||
Baz | ||
Nemikolh marked this conversation as resolved.
Show resolved
Hide resolved
|
1 change: 1 addition & 0 deletions
1
e2e/src/content/tutorial/tests/filesystem-sync/happy-path/_files/bar.txt
This file contains hidden or 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 @@ | ||
Initial content |
12 changes: 12 additions & 0 deletions
12
e2e/src/content/tutorial/tests/filesystem-sync/happy-path/content.mdx
This file contains hidden or 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,12 @@ | ||
--- | ||
type: lesson | ||
title: Happy path | ||
focus: /bar.txt | ||
--- | ||
|
||
import { ButtonWriteToFile } from '@components/ButtonWriteToFile'; | ||
|
||
# Happy path filesystem test | ||
|
||
<ButtonWriteToFile client:load filePath="/bar.txt" newContent='Something else' useWebcontainer /> | ||
<ButtonWriteToFile client:load filePath="/a/b/baz.txt" newContent='Foo' useWebcontainer testId='write-to-file-in-subfolder' /> |
This file contains hidden or 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,6 @@ | ||
--- | ||
type: chapter | ||
title: filesystem.watch | ||
filesystem: | ||
watch: true | ||
--- |
This file contains hidden or 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,35 @@ | ||
import { test, expect } from '@playwright/test'; | ||
|
||
const BASE_URL = '/tests/filesystem-sync'; | ||
|
||
test('editor should reflect changes made from webcontainer', async ({ page }) => { | ||
const testCase = 'happy-path'; | ||
await page.goto(`${BASE_URL}/${testCase}`); | ||
|
||
await expect(page.getByRole('textbox', { name: 'Editor' })).toHaveText('Initial content\n', { | ||
useInnerText: true, | ||
}); | ||
|
||
await page.getByTestId('write-to-file').click(); | ||
|
||
await expect(page.getByRole('textbox', { name: 'Editor' })).toHaveText('Something else', { | ||
useInnerText: true, | ||
}); | ||
}); | ||
|
||
test('editor should reflect changes made from webcontainer in file in nested folder', async ({ page }) => { | ||
const testCase = 'happy-path'; | ||
await page.goto(`${BASE_URL}/${testCase}`); | ||
|
||
await page.getByRole('button', { name: 'baz.txt' }).click(); | ||
|
||
await expect(page.getByRole('textbox', { name: 'Editor' })).toHaveText('Baz', { | ||
useInnerText: true, | ||
}); | ||
|
||
await page.getByTestId('write-to-file-in-subfolder').click(); | ||
|
||
await expect(page.getByRole('textbox', { name: 'Editor' })).toHaveText('Foo', { | ||
useInnerText: true, | ||
}); | ||
}); |
This file contains hidden or 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 hidden or 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 hidden or 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 |
---|---|---|
@@ -1,5 +1,3 @@ | ||
export { LessonFilesFetcher } from './lesson-files.js'; | ||
export { TutorialRunner } from './tutorial-runner.js'; | ||
export type { Command, Commands, PreviewInfo, Step, Steps } from './webcontainer/index.js'; | ||
export { safeBoot } from './webcontainer/index.js'; | ||
export { TutorialStore } from './store/index.js'; |
This file contains hidden or 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 hidden or 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 hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.