Skip to content

Commit

Permalink
Merge pull request #1783 from zb3/fix-expectOutput
Browse files Browse the repository at this point in the history
  • Loading branch information
a3957273 committed Apr 7, 2024
2 parents 33a473c + a23e47d commit 8c283c7
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
12 changes: 8 additions & 4 deletions tests/browser/01_io.js
Original file line number Diff line number Diff line change
Expand Up @@ -383,13 +383,17 @@ module.exports = {
utils.setInput(browser, CHINESE_CHARS, false);
utils.setChrEnc(browser, "input", "UTF-8");
utils.bake(browser);
utils.expectOutput(browser, "\u00E4\u00B8\u008D\u00E8\u00A6\u0081\u00E6\u0081\u0090\u00E6\u0085\u008C\u00E3\u0080\u0082");

/* Changing output to match input works as expected */
utils.setChrEnc(browser, "output", "UTF-8");
utils.bake(browser);
/* Output encoding should be autodetected */
browser
.waitForElementVisible("#snackbar-container .snackbar-content", 5000)
.expect.element("#snackbar-container .snackbar-content").text.to.equal("Output character encoding has been detected and changed to UTF-8");

utils.expectOutput(browser, CHINESE_CHARS);

/* Change the output encoding manually to test for URL presence */
utils.setChrEnc(browser, "output", "UTF-8");

/* Encodings appear in the URL */
browser.assert.urlContains("ienc=65001");
browser.assert.urlContains("oenc=65001");
Expand Down
9 changes: 5 additions & 4 deletions tests/browser/browserUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -176,13 +176,14 @@ function loadRecipe(browser, opName, input, args) {
*/
function expectOutput(browser, expected) {
browser.execute(expected => {
const output = window.app.manager.output.outputEditorView.state.doc.toString();
return window.app.manager.output.outputEditorView.state.doc.toString();
}, [expected], function({value}) {
if (expected instanceof RegExp) {
return expected.test(output);
browser.expect(value).match(expected);
} else {
return expected === output;
browser.expect(value).to.be.equal(expected);
}
}, [expected]);
});
}

/** @function
Expand Down

0 comments on commit 8c283c7

Please sign in to comment.