Restore output attribute of py-script tags, add py-script exec lifecycle hooks (#1063)

* Add beforePyScriptExec, afterPyScriptExec lifecycle hooks

* Add stdiodirector plugin for `output`, `stderr` attributes of py-script tag

* Add docs on `output` and `stderr` attributes of py-script tag

* Tests

* Removed output deprecation warning for `output` attribute

* Add createSingularWarning(), with createDeprecationWarning as alias
This commit is contained in:
Jeff Glass
2023-01-10 13:00:29 -06:00
committed by GitHub
parent e1b4415193
commit 470c3489dd
15 changed files with 748 additions and 33 deletions

View File

@@ -1,5 +1,5 @@
import { beforeEach, expect, describe, it } from "@jest/globals"
import { ensureUniqueId, joinPaths} from "../../src/utils"
import { ensureUniqueId, joinPaths, createSingularWarning} from "../../src/utils"
describe("Utils", () => {
@@ -51,4 +51,23 @@ describe("JoinPaths", () => {
const joinedPath = joinPaths(paths);
expect(joinedPath).toStrictEqual('hhh/ll/pp/kkk');
})
describe("createSingularBanner", () => {
it("should create one and new banner containing the sentinel text, and not duplicate it", () => {
//One warning banner with the desired text should be created
createSingularWarning("A unique error message", "unique")
expect(document.getElementsByClassName("alert-banner")?.length).toEqual(1)
expect(document.getElementsByClassName("alert-banner")[0].textContent).toEqual(expect.stringContaining("A unique error message"))
//Should still only be one banner, since the second uses the existing sentinel value "unique"
createSingularWarning("This banner should not appear", "unique")
expect(document.getElementsByClassName("alert-banner")?.length).toEqual(1)
expect(document.getElementsByClassName("alert-banner")[0].textContent).toEqual(expect.stringContaining("A unique error message"))
//If the sentinel value is not provided, the entire msg is used as the sentinel
createSingularWarning("A unique error message", null)
expect(document.getElementsByClassName("alert-banner")?.length).toEqual(1)
expect(document.getElementsByClassName("alert-banner")[0].textContent).toEqual(expect.stringContaining("A unique error message"))
})
})
})