-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Fix functional tests pt 2 #9713
Merged
+36
−58
Merged
Changes from all commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
5f5e7b5
tests
freddyaboulton 7fc2e92
fix race condition
freddyaboulton 1348c36
fix test
freddyaboulton 0ed3a30
try again
freddyaboulton 9faed6e
revert changes
freddyaboulton 34db9fc
🤞
freddyaboulton 1a135a1
see failure
freddyaboulton 3d109e5
add changeset
gradio-pr-bot 5589460
add changeset
gradio-pr-bot ee6e9ee
Fix
freddyaboulton f57bb1f
Fix
freddyaboulton 15da4be
Merge branch 'main' into fix-functional-tests
freddyaboulton c8bc932
make apply pass
freddyaboulton 2ceb011
try
freddyaboulton 55503a2
check
freddyaboulton 041da20
remove first
freddyaboulton ada299e
fix code
freddyaboulton 2264c2d
delete changeset
gradio-pr-bot afde264
fix reload test
freddyaboulton f7ef389
Merge branch 'main' into fix-functional-tests
freddyaboulton f0f19a7
Merge branch 'main' into fix-functional-tests
freddyaboulton 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 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,61 +9,44 @@ test("upload events work as expected", async ({ page }) => { | |
}); | ||
|
||
test("change events work as expected", async ({ page }) => { | ||
await page.getByLabel("Upload button").first().click(); | ||
const uploader = page.locator("input[type=file]").first(); | ||
await uploader.setInputFiles(["./test/files/cheetah1.jpg"]); | ||
|
||
const change_text = page.locator("#change h2"); | ||
await expect(change_text).toContainText("1"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. split up the tests here because playwright was being weird. Coverage is the same now though. |
||
|
||
await page.getByLabel("Draw button").first().click(); | ||
const canvas = page.locator("#image_editor canvas").first(); | ||
await canvas.click({ position: { x: 100, y: 100 } }); | ||
await expect(change_text).toContainText("2"); | ||
|
||
await page.getByLabel("Erase button").first().click(); | ||
await page.getByLabel("Draw button").click(); | ||
await page.getByLabel("Draw button").click(); | ||
const canvas = page.locator("canvas"); | ||
await canvas.click({ position: { x: 100, y: 100 } }); | ||
await expect(change_text).toContainText("3"); | ||
|
||
await page.getByLabel("Clear canvas").first().click(); | ||
await expect(change_text).toContainText("4"); | ||
await expect(change_text).toContainText("1"); | ||
}); | ||
|
||
test("input events work as expected", async ({ page }) => { | ||
await page.getByLabel("Upload button").first().click(); | ||
const uploader = page.locator("input[type=file]").first(); | ||
await uploader.setInputFiles(["./test/files/cheetah1.jpg"]); | ||
|
||
const input_text = page.locator("#input h2"); | ||
await expect(input_text).toContainText("1"); | ||
|
||
await page.getByLabel("Draw button").first().click(); | ||
const canvas = page.locator("#image_editor canvas").first(); | ||
await page.getByLabel("Draw button").click(); | ||
await page.getByLabel("Draw button").click(); | ||
const canvas = page.locator("canvas"); | ||
await canvas.click({ position: { x: 100, y: 100 } }); | ||
await expect(input_text).toContainText("2"); | ||
await expect(input_text).toContainText("1"); | ||
}); | ||
|
||
await page.getByLabel("Erase button").first().click(); | ||
await canvas.click({ position: { x: 100, y: 100 } }); | ||
await expect(input_text).toContainText("3"); | ||
test("erase triggers change and input events", async ({ page }) => { | ||
const canvas = page.locator("canvas"); | ||
const input_text = page.locator("#input h2"); | ||
const change_text = page.locator("#change h2"); | ||
|
||
await page.getByLabel("Clear canvas").first().click(); | ||
await expect(input_text).toContainText("4"); | ||
await page.getByLabel("Erase button").click(); | ||
await canvas.click({ position: { x: 50, y: 50 } }); | ||
await expect(input_text).toContainText("1"); | ||
await expect(change_text).toContainText("1"); | ||
}); | ||
|
||
test("apply events work as expected", async ({ page }) => { | ||
const apply_text = page.locator("#apply h2"); | ||
const apply_button = page.getByLabel("Save changes").first(); | ||
|
||
await page.getByLabel("Draw button").first().click(); | ||
const canvas = page.locator("#image_editor canvas").first(); | ||
await page.getByLabel("Draw button").first().click(); | ||
const canvas = page.locator("canvas").first(); | ||
await canvas.click({ position: { x: 100, y: 100 } }); | ||
await apply_button.click(); | ||
await expect(apply_text).toContainText("1"); | ||
|
||
await page.getByLabel("Erase button").first().click(); | ||
await canvas.click({ position: { x: 100, y: 100 } }); | ||
|
||
await page.getByLabel("Clear canvas").first().click(); | ||
await apply_button.click(); | ||
await expect(apply_text).toContainText("2"); | ||
}); |
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 |
---|---|---|
|
@@ -10,13 +10,13 @@ test.beforeAll(() => { | |
const demo = ` | ||
import gradio as gr | ||
def greet(msg, history): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The indentation was messed up |
||
return "Hello" | ||
def greet(msg, history): | ||
return "Hello" | ||
demo = gr.ChatInterface(fn=greet) | ||
demo = gr.ChatInterface(fn=greet) | ||
if __name__ == "__main__": | ||
demo.launch() | ||
if __name__ == "__main__": | ||
demo.launch() | ||
`; | ||
// write contents of demo to a local 'run.py' file | ||
spawnSync(`echo '${demo}' > ${join(process.cwd(), demo_file)}`, { | ||
|
@@ -55,15 +55,15 @@ test("gradio dev mode correctly reloads a stateful ChatInterface demo", async ({ | |
_process = server_process; | ||
console.log("Connected to port", port); | ||
const demo = ` | ||
import gradio as gr | ||
import gradio as gr | ||
def greet(msg, history): | ||
return f"You typed: {msg}" | ||
def greet(msg, history): | ||
return f"You typed: {msg}" | ||
demo = gr.ChatInterface(fn=greet, textbox=gr.Textbox(label="foo", placeholder="Type a message...")) | ||
demo = gr.ChatInterface(fn=greet, textbox=gr.Textbox(label="foo", placeholder="Type a message...")) | ||
if __name__ == "__main__": | ||
demo.launch() | ||
if __name__ == "__main__": | ||
demo.launch() | ||
`; | ||
// write contents of demo to a local 'run.py' file | ||
await page.goto(`http://localhost:${port}`); | ||
|
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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The case changed in #9670