snapshot of https://github.com/zulip/zulip.git @ 48c69911c7dd4e03b20552eb3bd77ad8151c1357 (2026-09-15)
Some checks failed
Code scanning / CodeQL (push) Failing after 15s
Zulip production suite / Ubuntu 22.04 production build (push) Failing after 26s
Zulip production suite / Debian 12 production install with custom db name and user (push) Has been skipped
Zulip production suite / Ubuntu 22.04 production install and PostgreSQL upgrade with pgroonga (push) Has been skipped
Zulip production suite / Ubuntu 24.04 production install (push) Has been skipped
Zulip production suite / Ubuntu 26.04 production install (push) Has been skipped
Zulip production suite / Debian 13 production install (push) Has been skipped
Zulip production suite / 7.0 Version Upgrade (push) Has been skipped
Zulip production suite / 8.0 Version Upgrade (push) Has been skipped
Zulip production suite / 6.0 Version Upgrade (push) Has been skipped
Zulip production suite / 10.0 Version Upgrade (push) Has been skipped
Zulip production suite / 9.0 Version Upgrade (push) Has been skipped
Zulip production suite / 12.0 Version Upgrade (push) Has been skipped
Zulip production suite / 11.0 Version Upgrade (push) Has been skipped
GitHub Actions Security Analysis with zizmor / zizmor (push) Failing after 3s
Zulip CI / Debian 12 (Python 3.11, backend + documentation) (push) Failing after 26s
Zulip CI / Ubuntu 22.04 (Python 3.10, backend + frontend) (push) Failing after 3s
Zulip CI / Ubuntu 24.04 (Python 3.12, backend) (push) Failing after 25s
Zulip CI / Ubuntu 26.04 (Python 3.14, backend) (push) Failing after 25s
Zulip CI / Debian 13 (Python 3.13, backend) (push) Failing after 28s
Zulip production suite / Required jobs (push) Has been cancelled
Zulip CI / Required jobs (push) Has been cancelled
API Documentation Update Check / check-feature-level-updated (push) Has been cancelled
API Documentation Update Check / notify-if-api-docs-changed (push) Has been cancelled
Some checks failed
Code scanning / CodeQL (push) Failing after 15s
Zulip production suite / Ubuntu 22.04 production build (push) Failing after 26s
Zulip production suite / Debian 12 production install with custom db name and user (push) Has been skipped
Zulip production suite / Ubuntu 22.04 production install and PostgreSQL upgrade with pgroonga (push) Has been skipped
Zulip production suite / Ubuntu 24.04 production install (push) Has been skipped
Zulip production suite / Ubuntu 26.04 production install (push) Has been skipped
Zulip production suite / Debian 13 production install (push) Has been skipped
Zulip production suite / 7.0 Version Upgrade (push) Has been skipped
Zulip production suite / 8.0 Version Upgrade (push) Has been skipped
Zulip production suite / 6.0 Version Upgrade (push) Has been skipped
Zulip production suite / 10.0 Version Upgrade (push) Has been skipped
Zulip production suite / 9.0 Version Upgrade (push) Has been skipped
Zulip production suite / 12.0 Version Upgrade (push) Has been skipped
Zulip production suite / 11.0 Version Upgrade (push) Has been skipped
GitHub Actions Security Analysis with zizmor / zizmor (push) Failing after 3s
Zulip CI / Debian 12 (Python 3.11, backend + documentation) (push) Failing after 26s
Zulip CI / Ubuntu 22.04 (Python 3.10, backend + frontend) (push) Failing after 3s
Zulip CI / Ubuntu 24.04 (Python 3.12, backend) (push) Failing after 25s
Zulip CI / Ubuntu 26.04 (Python 3.14, backend) (push) Failing after 25s
Zulip CI / Debian 13 (Python 3.13, backend) (push) Failing after 28s
Zulip production suite / Required jobs (push) Has been cancelled
Zulip CI / Required jobs (push) Has been cancelled
API Documentation Update Check / check-feature-level-updated (push) Has been cancelled
API Documentation Update Check / notify-if-api-docs-changed (push) Has been cancelled
This commit is contained in:
109
web/e2e-tests/realm-playground.test.ts
Normal file
109
web/e2e-tests/realm-playground.test.ts
Normal file
@@ -0,0 +1,109 @@
|
||||
import assert from "node:assert/strict";
|
||||
|
||||
import type {Page} from "puppeteer";
|
||||
|
||||
import * as common from "./lib/common.ts";
|
||||
|
||||
type Playground = {
|
||||
playground_name: string;
|
||||
pygments_language: string;
|
||||
url_template: string;
|
||||
};
|
||||
|
||||
async function _add_playground_and_return_status(page: Page, payload: Playground): Promise<string> {
|
||||
await page.waitForSelector(".admin-playground-form", {visible: true});
|
||||
const admin_playground_status_selector = "div#admin-playground-status";
|
||||
|
||||
await common.select_item_via_typeahead(
|
||||
page,
|
||||
"#playground_pygments_language",
|
||||
payload.pygments_language,
|
||||
payload.pygments_language,
|
||||
);
|
||||
|
||||
// Now we can fill and click the submit button.
|
||||
await common.fill_form(page, "form.admin-playground-form", {
|
||||
playground_name: payload.playground_name,
|
||||
url_template: payload.url_template,
|
||||
});
|
||||
// Not sure why, but page.click() doesn't seem to always click the submit button.
|
||||
// So we resort to using eval with the button ID instead.
|
||||
await page.$eval("button#submit_playground_button", (el) => {
|
||||
el.click();
|
||||
});
|
||||
|
||||
// Wait for the request to complete by checking when the button is re-enabled.
|
||||
await page.waitForSelector("button#submit_playground_button:not([disabled])", {visible: true});
|
||||
|
||||
// We return the success/failure status message back to the caller.
|
||||
await page.waitForSelector(admin_playground_status_selector, {visible: true});
|
||||
const admin_playground_status = await common.get_text_from_selector(
|
||||
page,
|
||||
admin_playground_status_selector,
|
||||
);
|
||||
return admin_playground_status;
|
||||
}
|
||||
|
||||
async function test_successful_playground_creation(page: Page): Promise<void> {
|
||||
const payload = {
|
||||
pygments_language: "Python",
|
||||
playground_name: "Python3 playground",
|
||||
url_template: "https://python.example.com?code={code}",
|
||||
};
|
||||
const status = await _add_playground_and_return_status(page, payload);
|
||||
assert.strictEqual(status, "Custom playground added!");
|
||||
await page.waitForSelector(".playground_row", {visible: true});
|
||||
assert.strictEqual(
|
||||
await common.get_text_from_selector(
|
||||
page,
|
||||
".playground_row span.playground_pygments_language",
|
||||
),
|
||||
"Python",
|
||||
);
|
||||
assert.strictEqual(
|
||||
await common.get_text_from_selector(page, ".playground_row span.playground_name"),
|
||||
"Python3 playground",
|
||||
);
|
||||
assert.strictEqual(
|
||||
await common.get_text_from_selector(page, ".playground_row span.playground_url_template"),
|
||||
"https://python.example.com?code={code}",
|
||||
);
|
||||
}
|
||||
|
||||
async function test_invalid_playground_parameters(page: Page): Promise<void> {
|
||||
const payload = {
|
||||
pygments_language: "Python",
|
||||
playground_name: "Python3 playground",
|
||||
url_template: "not_a_url_template{",
|
||||
};
|
||||
let status = await _add_playground_and_return_status(page, payload);
|
||||
assert.strictEqual(status, "Failed: Invalid URL template.");
|
||||
|
||||
payload.url_template = "https://python.example.com?code={code}";
|
||||
payload.pygments_language = "py!@%&";
|
||||
status = await _add_playground_and_return_status(page, payload);
|
||||
assert.strictEqual(status, "Failed: Invalid character in language: !");
|
||||
}
|
||||
|
||||
async function test_successful_playground_deletion(page: Page): Promise<void> {
|
||||
await page.waitForSelector(".playground_row button.delete", {visible: true});
|
||||
await page.click(".playground_row button.delete");
|
||||
|
||||
await common.wait_for_micromodal_to_open(page);
|
||||
await page.click("#confirm_delete_code_playgrounds_modal .dialog_submit_button");
|
||||
await common.wait_for_micromodal_to_close(page);
|
||||
|
||||
await page.waitForSelector(".playground_row", {hidden: true});
|
||||
}
|
||||
|
||||
async function playground_test(page: Page): Promise<void> {
|
||||
await common.log_in(page);
|
||||
await common.manage_organization(page);
|
||||
await page.click("li[data-section='playground-settings']");
|
||||
|
||||
await test_successful_playground_creation(page);
|
||||
await test_invalid_playground_parameters(page);
|
||||
await test_successful_playground_deletion(page);
|
||||
}
|
||||
|
||||
await common.run_test(playground_test);
|
||||
Reference in New Issue
Block a user