From fd4c3e3d8f5ea84e3ecfec9ad088b5c7ce91c56d Mon Sep 17 00:00:00 2001 From: Julien Loizelet Date: Mon, 19 Dec 2022 17:10:16 +0900 Subject: [PATCH] test(end-to-end): Remove useless witForNavigation --- tests/e2e-ddev/__tests__/1-activate-plugin.js | 2 -- tests/e2e-ddev/__tests__/4-live-mode-cache.js | 3 --- tests/e2e-ddev/__tests__/5-stream-mode.js | 3 --- tests/e2e-ddev/utils/helpers.js | 11 ----------- 4 files changed, 19 deletions(-) diff --git a/tests/e2e-ddev/__tests__/1-activate-plugin.js b/tests/e2e-ddev/__tests__/1-activate-plugin.js index 1a840b6c..88f4e88b 100644 --- a/tests/e2e-ddev/__tests__/1-activate-plugin.js +++ b/tests/e2e-ddev/__tests__/1-activate-plugin.js @@ -9,7 +9,6 @@ const { } = require("../utils/constants"); const { - waitForNavigation, goToAdmin, onLoginPageLoginAsAdmin, wait, @@ -32,7 +31,6 @@ describe(`Setup CrowdSec plugin`, () => { await page.click('[aria-label="Activate CrowdSec"]'); } - await waitForNavigation; await expect(page).toHaveText("#message", "Plugin activated."); }); }); diff --git a/tests/e2e-ddev/__tests__/4-live-mode-cache.js b/tests/e2e-ddev/__tests__/4-live-mode-cache.js index ff1b0ba0..e42649cc 100644 --- a/tests/e2e-ddev/__tests__/4-live-mode-cache.js +++ b/tests/e2e-ddev/__tests__/4-live-mode-cache.js @@ -1,7 +1,6 @@ /* eslint-disable no-undef */ const { wait, - waitForNavigation, goToAdmin, onAdminGoToAdvancedPage, onAdminSaveSettings, @@ -29,7 +28,6 @@ describe(`Run in Live mode`, () => { await goToAdmin(); await onAdminGoToAdvancedPage(); await page.click("#crowdsec_prune_cache"); - await waitForNavigation; await expect(page).toHaveText( "#wpbody-content > div.wrap > div.notice.notice-success", @@ -56,7 +54,6 @@ describe(`Run in Live mode`, () => { await dialog.accept(); }); await page.click("#crowdsec_clear_cache"); - await waitForNavigation; await expect(page).toHaveText( "#wpbody-content > div.wrap > div.notice.notice-success", diff --git a/tests/e2e-ddev/__tests__/5-stream-mode.js b/tests/e2e-ddev/__tests__/5-stream-mode.js index c63a2972..77c6f590 100644 --- a/tests/e2e-ddev/__tests__/5-stream-mode.js +++ b/tests/e2e-ddev/__tests__/5-stream-mode.js @@ -1,6 +1,5 @@ /* eslint-disable no-undef */ const { - waitForNavigation, goToAdmin, onAdminGoToAdvancedPage, onAdminGoToSettingsPage, @@ -49,7 +48,6 @@ describe(`Run in Stream mode`, () => { await goToAdmin(); await onAdminGoToAdvancedPage(); await page.click("#crowdsec_refresh_cache"); - await waitForNavigation; await expect(page).toHaveText( "#wpbody-content > div.wrap > div.notice.notice-success", @@ -80,7 +78,6 @@ describe(`Run in Stream mode`, () => { await goToAdmin(); await onAdminGoToAdvancedPage(); await page.click("#crowdsec_refresh_cache"); - await waitForNavigation; await expect(page).toHaveText( "#wpbody-content > div.wrap > div.notice.notice-success", diff --git a/tests/e2e-ddev/utils/helpers.js b/tests/e2e-ddev/utils/helpers.js index 41ec4c35..f1879271 100644 --- a/tests/e2e-ddev/utils/helpers.js +++ b/tests/e2e-ddev/utils/helpers.js @@ -16,16 +16,12 @@ const wait = (ms) => new Promise((resolve) => setTimeout(resolve, ms)); jest.setTimeout(TIMEOUT); -const waitForNavigation = page.waitForNavigation(); - const goToAdmin = async () => { await page.goto(ADMIN_URL); - await waitForNavigation; }; const goToPublicPage = async () => { await page.goto(`${BASE_URL}`); - await waitForNavigation; }; const onAdminGoToSettingsPage = async () => { @@ -33,7 +29,6 @@ const onAdminGoToSettingsPage = async () => { await page.click( "#adminmenuwrap > #adminmenu > #toplevel_page_crowdsec_plugin > .wp-has-submenu > .wp-menu-name", ); - await waitForNavigation; }; const onAdminGoToAdvancedPage = async () => { @@ -42,7 +37,6 @@ const onAdminGoToAdvancedPage = async () => { await page.click( "#toplevel_page_crowdsec_plugin > ul > li:nth-child(4) > a", ); - await waitForNavigation; await wait(1000); await expect(page).toMatchTitle(/Advanced/); }; @@ -53,7 +47,6 @@ const onAdminGoToThemePage = async () => { await page.click( "#toplevel_page_crowdsec_plugin > ul > li:nth-child(3) > a", ); - await waitForNavigation; await wait(1000); await expect(page).toMatchTitle(/Theme customization/); @@ -64,12 +57,10 @@ const onLoginPageLoginAsAdmin = async () => { await page.fill("#user_pass", ADMIN_PASSWORD); await page.waitForSelector("#wp-submit"); await page.click("#wp-submit"); - await waitForNavigation; }; const onAdminSaveSettings = async (check = true) => { await page.click("[type=submit]"); - await waitForNavigation; if (check) { await expect(page).toHaveText( @@ -201,7 +192,6 @@ const removeAllDecisions = async () => { const onCaptchaPageRefreshCaptchaImage = async () => { await page.click("#refresh_link"); - await waitForNavigation; }; const forceCronRun = async () => { @@ -251,7 +241,6 @@ const setDefaultConfig = async () => { module.exports = { addDecision, wait, - waitForNavigation, goToAdmin, goToPublicPage, onAdminGoToSettingsPage,