Merge pull request #1783 from zb3/fix-expectOutput

This commit is contained in:
a3957273 2024-04-07 21:59:30 +01:00 committed by GitHub
commit 8c283c7b19
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 13 additions and 8 deletions

View File

@ -383,13 +383,17 @@ module.exports = {
utils.setInput(browser, CHINESE_CHARS, false); utils.setInput(browser, CHINESE_CHARS, false);
utils.setChrEnc(browser, "input", "UTF-8"); utils.setChrEnc(browser, "input", "UTF-8");
utils.bake(browser); 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 */ /* Output encoding should be autodetected */
utils.setChrEnc(browser, "output", "UTF-8"); browser
utils.bake(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); 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 */ /* Encodings appear in the URL */
browser.assert.urlContains("ienc=65001"); browser.assert.urlContains("ienc=65001");
browser.assert.urlContains("oenc=65001"); browser.assert.urlContains("oenc=65001");

View File

@ -176,13 +176,14 @@ function loadRecipe(browser, opName, input, args) {
*/ */
function expectOutput(browser, expected) { function expectOutput(browser, expected) {
browser.execute(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) { if (expected instanceof RegExp) {
return expected.test(output); browser.expect(value).match(expected);
} else { } else {
return expected === output; browser.expect(value).to.be.equal(expected);
} }
}, [expected]); });
} }
/** @function /** @function