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
e2e test for file_uploader on_change bug #4390
Changes from all commits
d02b7da
4d825ff
78159eb
59eec46
3631122
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -393,4 +393,51 @@ describe("st.file_uploader", () => { | |
); | ||
}); | ||
}); | ||
|
||
// regression test for https://github.com/streamlit/streamlit/issues/4256 bug | ||
it("does not call a callback when not changed", () => { | ||
const fileName1 = "file1.txt"; | ||
const uploaderIndex = 4; | ||
|
||
cy.fixture(fileName1).then(file1 => { | ||
const files = [ | ||
{ fileContent: file1, fileName: fileName1, mimeType: "text/plain" } | ||
]; | ||
|
||
// Script contains counter variable stored in session_state with | ||
// default value 0. We increment counter inside file_uploader callback | ||
// Since callback did not called at this moment, counter value should | ||
// be equal 0 | ||
cy.getIndexed("[data-testid='stText']", uploaderIndex).should( | ||
"contain.text", | ||
"0" | ||
); | ||
|
||
// Uploading file, should invoke on_change call and counter increment | ||
cy.getIndexed( | ||
"[data-testid='stFileUploadDropzone']", | ||
uploaderIndex | ||
).attachFile(files[0], { | ||
force: true, | ||
subjectType: "drag-n-drop", | ||
events: ["dragenter", "drop"] | ||
}); | ||
|
||
// Make sure callback called | ||
cy.getIndexed("[data-testid='stText']", uploaderIndex).should( | ||
"contain.text", | ||
"1" | ||
); | ||
|
||
// On rerun, make sure callback is not called, since file not changed | ||
cy.get("body").type("r"); | ||
cy.wait(1000); | ||
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. Not necessarily something to stop the PR for, but I wonder if there's a more deterministic way to wait for the rerun to happen than 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. +1 The newly-added 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. Good! I'd like to mergde these changes as they are, as the And come back to using Thank you for your comments! |
||
|
||
// Counter should be still equal 1 | ||
cy.getIndexed("[data-testid='stText']", uploaderIndex).should( | ||
"contain.text", | ||
"1" | ||
); | ||
}); | ||
}); | ||
}); |
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.
I assume this
if
line is here because we run e2e tests in "bare Python mode" as part of our Python tests, and this test doesn't work in that circumstance? Can you add a comment here explaining that?