From c446435f544b4308e63c93ee0029b5f233a3f009 Mon Sep 17 00:00:00 2001 From: Anders Kaseorg Date: Mon, 7 Jun 2021 19:57:40 -0700 Subject: [PATCH] puppeteer_tests: Use assert.match. Signed-off-by: Anders Kaseorg --- frontend_tests/puppeteer_lib/common.ts | 2 +- frontend_tests/puppeteer_tests/settings.ts | 13 +++++++------ 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/frontend_tests/puppeteer_lib/common.ts b/frontend_tests/puppeteer_lib/common.ts index 7bc9b09720..64c5c5e893 100644 --- a/frontend_tests/puppeteer_lib/common.ts +++ b/frontend_tests/puppeteer_lib/common.ts @@ -466,7 +466,7 @@ class CommonUtils { await page.waitForSelector("#settings_overlay_container.show", {visible: true}); const url = await this.page_url_with_fragment(page); - assert(/^http:\/\/[^/]+\/#organization/.test(url), "Unexpected manage organization URL"); + assert.match(url, /^http:\/\/[^/]+\/#organization/, "Unexpected manage organization URL"); const organization_settings_data_section = "li[data-section='organization-settings']"; await page.click(organization_settings_data_section); diff --git a/frontend_tests/puppeteer_tests/settings.ts b/frontend_tests/puppeteer_tests/settings.ts index 102937ac04..183e402947 100644 --- a/frontend_tests/puppeteer_tests/settings.ts +++ b/frontend_tests/puppeteer_tests/settings.ts @@ -90,12 +90,12 @@ async function test_get_api_key(page: Page): Promise { await page.waitForSelector("#show_api_key", {visible: true}); const api_key = await common.get_text_from_selector(page, "#api_key_value"); - assert(/[\dA-Za-z]{32}/.test(api_key), "Incorrect API key format."); + assert.match(api_key, /[\dA-Za-z]{32}/, "Incorrect API key format."); const download_zuliprc_selector = "#download_zuliprc"; await page.click(download_zuliprc_selector); const zuliprc_decoded_url = await get_decoded_url_in_selector(page, download_zuliprc_selector); - assert(zuliprc_regex.test(zuliprc_decoded_url), "Incorrect zuliprc file"); + assert.match(zuliprc_decoded_url, zuliprc_regex, "Incorrect zuliprc file"); await page.click("#api_key_modal .close"); await common.wait_for_modal_to_close(page); } @@ -121,8 +121,9 @@ async function test_webhook_bot_creation(page: Page): Promise { await page.click(download_zuliprc_selector); const zuliprc_decoded_url = await get_decoded_url_in_selector(page, download_zuliprc_selector); - assert( - outgoing_webhook_zuliprc_regex.test(zuliprc_decoded_url), + assert.match( + zuliprc_decoded_url, + outgoing_webhook_zuliprc_regex, "Incorrect outgoing webhook bot zulirc format", ); } @@ -147,7 +148,7 @@ async function test_normal_bot_creation(page: Page): Promise { await page.waitForSelector(download_zuliprc_selector, {visible: true}); await page.click(download_zuliprc_selector); const zuliprc_decoded_url = await get_decoded_url_in_selector(page, download_zuliprc_selector); - assert(zuliprc_regex.test(zuliprc_decoded_url), "Incorrect zuliprc format for bot."); + assert.match(zuliprc_decoded_url, zuliprc_regex, "Incorrect zuliprc format for bot."); } async function test_botserverrc(page: Page): Promise { @@ -159,7 +160,7 @@ async function test_botserverrc(page: Page): Promise { ); const botserverrc_regex = /^data:application\/octet-stream;charset=utf-8,\[]\nemail=.+\nkey=.+\nsite=.+\ntoken=.+\n$/; - assert(botserverrc_regex.test(botserverrc_decoded_url), "Incorrect botserverrc format."); + assert.match(botserverrc_decoded_url, botserverrc_regex, "Incorrect botserverrc format."); } async function test_edit_bot_form(page: Page): Promise {