diff --git a/tests/e2e/flat-files.setup.ts b/tests/e2e/flat-files.setup.ts index befe7d34b..39de2119b 100644 --- a/tests/e2e/flat-files.setup.ts +++ b/tests/e2e/flat-files.setup.ts @@ -4,7 +4,10 @@ setup('enable flat files', async ({ page }) => { const isMultisite = 'true' === process.env.WP_E2E_MULTISITE_MODE || '1' === process.env.WP_E2E_MULTISITE_MODE const wpAdminbase = isMultisite ? '/wp-admin/network' : '/wp-admin' - await page.goto(`${wpAdminbase}/admin.php?page=snippets-settings`) + // The flat files switch lives on the Running tab; the other tabs are hidden. + const settingsUrl = `${wpAdminbase}/admin.php?page=snippets-settings§ion=running` + + await page.goto(settingsUrl) await page.waitForSelector('#wpbody-content') // Await page.waitForSelector('form') @@ -29,7 +32,7 @@ setup('enable flat files', async ({ page }) => { ]) - await page.reload() + await page.goto(settingsUrl) await page.waitForSelector('input[name="code_snippets_settings[general][enable_flat_files]"]') await expect(page.locator('input[name="code_snippets_settings[general][enable_flat_files]"]')).toBeChecked() }) diff --git a/tests/e2e/settings-tabs.spec.ts b/tests/e2e/settings-tabs.spec.ts index d4821f793..9f40ada27 100644 --- a/tests/e2e/settings-tabs.spec.ts +++ b/tests/e2e/settings-tabs.spec.ts @@ -1,6 +1,6 @@ import { expect, test } from '@playwright/test' -const SETTINGS_URL = '/wp-admin/admin.php?page=snippets-settings§ion=general' +const SETTINGS_URL = '/wp-admin/admin.php?page=snippets-settings§ion=editing' const TABS = '#settings-sections-tabs' test.describe('Settings tabs', () => { @@ -8,28 +8,28 @@ test.describe('Settings tabs', () => { await page.goto(SETTINGS_URL) const wrap = page.locator('.wrap[data-active-tab]') - await expect(wrap).toHaveAttribute('data-active-tab', 'general') + await expect(wrap).toHaveAttribute('data-active-tab', 'editing') // Mark the document so a full navigation would be detectable below. await page.evaluate(() => { (> window).csSameDocument = true }) - await page.locator(`${TABS} [data-section="editor"]`).click() + await page.locator(`${TABS} [data-section="running"]`).click() - await expect(wrap).toHaveAttribute('data-active-tab', 'editor') - await expect(page.locator(`${TABS} [data-section="editor"]`)).toHaveClass(/active-type/) - await expect(page).toHaveURL(/section=editor/) + await expect(wrap).toHaveAttribute('data-active-tab', 'running') + await expect(page.locator(`${TABS} [data-section="running"]`)).toHaveClass(/active-type/) + await expect(page).toHaveURL(/section=running/) // Redirections after saving must lead back to the selected tab. - await expect(page.locator('input[name=_wp_http_referer]')).toHaveValue(/section=editor/) + await expect(page.locator('input[name=_wp_http_referer]')).toHaveValue(/section=running/) // The swap happens without reloading the page. expect(await page.evaluate(() => (> window).csSameDocument)).toBe(true) - await page.locator(`${TABS} [data-section="general"]`).click() - await expect(wrap).toHaveAttribute('data-active-tab', 'general') - await expect(page.locator(`${TABS} [data-section="general"]`)).toHaveClass(/active-type/) + await page.locator(`${TABS} [data-section="editing"]`).click() + await expect(wrap).toHaveAttribute('data-active-tab', 'editing') + await expect(page.locator(`${TABS} [data-section="editing"]`)).toHaveClass(/active-type/) }) })