Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions tests/e2e/admin-screen-headings.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@ import { URLS } from './helpers/constants'

const EXPECTED_H1_HEADING_COUNT = 1

const SCREENS = [
{ name: 'Manage Snippets', url: URLS.SNIPPETS_ADMIN },
const SCREENS: { name: string; url: string }[] = [
{ name: 'Add Snippet', url: URLS.ADD_SNIPPET_ADMIN },
{ name: 'Community Cloud', url: URLS.COMMUNITY_CLOUD_ADMIN },
{ name: 'Blueprints', url: URLS.BLUEPRINTS_ADMIN },
{ name: 'Manage Snippets', url: URLS.SNIPPETS_ADMIN },
{ name: 'Cloud Community', url: URLS.CLOUD_COMMUNITY_ADMIN },
Comment thread
coderabbitai[bot] marked this conversation as resolved.
{ name: 'Cloud Library', url: URLS.CLOUD_LIBRARY_ADMIN },
{ name: 'Blueprints', url: URLS.BLUEPRINTS_ADMIN },
{ name: 'AI Agent', url: URLS.AI_AGENT_ADMIN },
{ name: 'Insights', url: URLS.INSIGHTS_ADMIN },
{ name: 'Import', url: URLS.IMPORT_SNIPPETS_ADMIN },
{ name: 'Import', url: URLS.IMPORT_ADMIN },
{ name: 'Settings', url: URLS.SETTINGS_ADMIN },
{ name: 'Welcome', url: URLS.WELCOME_SCREEN_ADMIN }
{ name: 'Welcome', url: URLS.WELCOME_ADMIN }
]

test.describe('Admin screen headings', () => {
Expand Down
15 changes: 7 additions & 8 deletions tests/e2e/ai-agent-demo.spec.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import { expect, test } from '@playwright/test'
import { TIMEOUTS } from './helpers/constants'
import { TIMEOUTS, URLS } from './helpers/constants'
import { measureCalloutSteps } from './helpers/demoPacing'
import { wpCli } from './helpers/wpCli'

const DEMO_URL = '/wp-admin/admin.php?page=snippets&subpage=ai-agent'
const DEMO_NAMES = "'Welcome banner', 'Welcome banner styles'"

const countDemoSnippets = async (): Promise<number> => {
Expand All @@ -22,7 +21,7 @@ test.describe('AI Agent demo', () => {
test.afterAll(forgetDemos)

test('the tab is reachable from the toolbar and highlighted as new', async ({ page }) => {
await page.goto('/wp-admin/admin.php?page=snippets')
await page.goto(URLS.SNIPPETS_ADMIN)

const link = page.locator('.code-snippets-toolbar-lower a.ai-agent-link')
await expect(link).toBeVisible()
Expand All @@ -36,7 +35,7 @@ test.describe('AI Agent demo', () => {
})

test('the page opens on the agent\u2019s own layout, with its starter prompts and sidebar', async ({ page }) => {
await page.goto(DEMO_URL)
await page.goto(URLS.AI_AGENT_ADMIN)

await expect(page.locator('.ai-agent-empty__chip')).toHaveCount(5)
await expect(page.locator('.ai-agent-layout__main > .ai-agent-prompt')).toBeVisible()
Expand All @@ -50,7 +49,7 @@ test.describe('AI Agent demo', () => {
})

test('playing the walkthrough plans, builds and refines without touching the site', async ({ page }) => {
await page.goto(DEMO_URL)
await page.goto(URLS.AI_AGENT_ADMIN)
expect(await countDemoSnippets()).toBe(0)

await page.locator('.demo-play').click()
Expand All @@ -75,7 +74,7 @@ test.describe('AI Agent demo', () => {
})

test('the walkthrough never writes a snippet, however many times it runs', async ({ page }) => {
await page.goto(DEMO_URL)
await page.goto(URLS.AI_AGENT_ADMIN)

await page.locator('.demo-play').click()
await page.getByRole('button', { name: 'Skip animation' }).click()
Expand All @@ -93,7 +92,7 @@ test.describe('AI Agent demo', () => {

test('the walkthrough ends with the closing panel below the agent, scrolled into view', async ({ page }) => {
await page.setViewportSize({ width: 1280, height: 800 })
await page.goto(DEMO_URL)
await page.goto(URLS.AI_AGENT_ADMIN)

await page.locator('.demo-play').click()
await page.getByRole('button', { name: 'Skip animation' }).click()
Expand All @@ -106,7 +105,7 @@ test.describe('AI Agent demo', () => {
})

test('the walkthrough holds each step long enough to be read', async ({ page }) => {
await page.goto(DEMO_URL)
await page.goto(URLS.AI_AGENT_ADMIN)
await page.locator('.demo-play').click()

const steps = await measureCalloutSteps(page)
Expand Down
3 changes: 2 additions & 1 deletion tests/e2e/auth.setup.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { join } from 'path'
import { expect, test as setup } from '@playwright/test'
import { wpCli } from './helpers/wpCli'
import { URLS } from './helpers/constants'

const authFile = join(__dirname, '.auth/user.json')
const AUTH_SETUP_TIMEOUT_MS = 120000
Expand Down Expand Up @@ -34,7 +35,7 @@ setup('authenticate', async ({ page }) => {
])
}

await page.goto('/wp-login.php')
await page.goto(URLS.WP_LOGIN)
await page.waitForSelector('#user_login')

await page.fill('#user_login', 'admin')
Expand Down
27 changes: 13 additions & 14 deletions tests/e2e/blueprints-demo.spec.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import { expect, test } from '@playwright/test'
import { TIMEOUTS } from './helpers/constants'
import { TIMEOUTS, URLS } from './helpers/constants'
import { measureCalloutSteps } from './helpers/demoPacing'
import { wpCli } from './helpers/wpCli'
import type { Page } from '@playwright/test'

const DEMO_URL = '/wp-admin/admin.php?page=snippets&subpage=blueprints'
const SECTIONS = ['General', 'Attributes', 'Output']

const forgetDemos = () => wpCli(['option', 'delete', 'code_snippets_demos_seen'])
Expand All @@ -17,7 +16,7 @@ test.describe('Blueprints demo', () => {
test.afterAll(forgetDemos)

test('the tab is reachable from the toolbar and highlighted as new', async ({ page }) => {
await page.goto('/wp-admin/admin.php?page=snippets')
await page.goto(URLS.SNIPPETS_ADMIN)

const link = page.locator('.code-snippets-toolbar-lower a.blueprints-link')
await expect(link).toBeVisible()
Expand All @@ -31,7 +30,7 @@ test.describe('Blueprints demo', () => {
})

test('the blueprint is shown prepopulated before play', async ({ page }) => {
await page.goto(DEMO_URL)
await page.goto(URLS.BLUEPRINTS_ADMIN)

await expect(page.locator('.blueprint-detail__header h2')).toHaveText('Create a Shortcode')
await expect(page.locator('.blueprint-form-content h3')).toHaveText('General')
Expand All @@ -44,7 +43,7 @@ test.describe('Blueprints demo', () => {
})

test('playing steps through every section and confirms a generated snippet', async ({ page }) => {
await page.goto(DEMO_URL)
await page.goto(URLS.BLUEPRINTS_ADMIN)
await page.locator('.demo-play').click()

for (const section of SECTIONS) {
Expand All @@ -65,7 +64,7 @@ test.describe('Blueprints demo', () => {
})

test('sections become browsable once the walkthrough finishes', async ({ page }) => {
await page.goto(DEMO_URL)
await page.goto(URLS.BLUEPRINTS_ADMIN)

await expect(page.locator('.blueprint-form-sidebar__item').first()).toBeDisabled()

Expand All @@ -82,7 +81,7 @@ test.describe('Blueprints demo', () => {

test('every section is the same height', async ({ page }) => {
await page.setViewportSize({ width: 1600, height: 950 })
await page.goto(DEMO_URL)
await page.goto(URLS.BLUEPRINTS_ADMIN)

await page.locator('.demo-play').click()
await page.getByRole('button', { name: 'Skip animation' }).click()
Expand All @@ -104,7 +103,7 @@ test.describe('Blueprints demo', () => {
})

test('the toolbar badge softens to Demo once the walkthrough has been watched', async ({ page }) => {
await page.goto(DEMO_URL)
await page.goto(URLS.BLUEPRINTS_ADMIN)
await expect(page.locator('.code-snippets-toolbar-lower a.blueprints-link .new-chip')).toBeVisible()

await page.locator('.demo-play').click()
Expand All @@ -115,15 +114,15 @@ test.describe('Blueprints demo', () => {
await expect.poll(async () =>
(await wpCli(['option', 'get', 'code_snippets_demos_seen'])).includes('blueprints')).toBe(true)

await page.goto(DEMO_URL)
await page.goto(URLS.BLUEPRINTS_ADMIN)

const link = page.locator('.code-snippets-toolbar-lower a.blueprints-link')
await expect(link.locator('.demo-chip')).toHaveText('Demo')
await expect(link.locator('.new-chip')).toHaveCount(0)
})

test('the demo-reset URL puts the badge back to New', async ({ page }) => {
await page.goto(DEMO_URL)
await page.goto(URLS.BLUEPRINTS_ADMIN)
await page.locator('.demo-play').click()
await page.getByRole('button', { name: 'Skip animation' }).click()
await expect(page.locator('.demo-upsell')).toBeVisible()
Expand All @@ -132,7 +131,7 @@ test.describe('Blueprints demo', () => {
(await wpCli(['option', 'get', 'code_snippets_demos_seen'])).includes('blueprints')).toBe(true)

const link = page.locator('.code-snippets-toolbar-lower a.blueprints-link')
await page.goto(DEMO_URL)
await page.goto(URLS.BLUEPRINTS_ADMIN)
await expect(link.locator('.demo-chip')).toBeVisible()

// The reset is nonce-protected, so the signed address is taken from the
Expand All @@ -145,13 +144,13 @@ test.describe('Blueprints demo', () => {
await expect(page).toHaveURL(/page=snippets/)
await expect(page).not.toHaveURL(/demo-reset/)

await page.goto(DEMO_URL)
await page.goto(URLS.BLUEPRINTS_ADMIN)
await expect(link.locator('.new-chip')).toHaveText('New')
await expect(link.locator('.demo-chip')).toHaveCount(0)
})

test('replaying restarts from the first section', async ({ page }) => {
await page.goto(DEMO_URL)
await page.goto(URLS.BLUEPRINTS_ADMIN)
await page.locator('.demo-play').click()
await page.getByRole('button', { name: 'Skip animation' }).click()

Expand All @@ -163,7 +162,7 @@ test.describe('Blueprints demo', () => {
})

test('the walkthrough holds each step long enough to be read', async ({ page }) => {
await page.goto(DEMO_URL)
await page.goto(URLS.BLUEPRINTS_ADMIN)
await page.locator('.demo-play').click()

const steps = await measureCalloutSteps(page)
Expand Down
2 changes: 1 addition & 1 deletion tests/e2e/cloud-download-eligibility.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ const routeCloudSnippets = (page: Page, state: CloudRoutesState) =>
})

const openCommunityCloud = async (page: Page, view: 'table' | 'card') => {
await page.goto(URLS.COMMUNITY_CLOUD_ADMIN)
await page.goto(URLS.CLOUD_COMMUNITY_ADMIN)
await expect(page.locator('.cloud-search')).toBeVisible()
await page.getByTitle(`Switch to ${view} view`).click()
}
Expand Down
19 changes: 9 additions & 10 deletions tests/e2e/cloud-library-demo.spec.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import { expect, test } from '@playwright/test'
import { TIMEOUTS } from './helpers/constants'
import { TIMEOUTS, URLS } from './helpers/constants'
import { measureCalloutSteps } from './helpers/demoPacing'

const DEMO_URL = '/wp-admin/admin.php?page=snippets&subpage=cloud-library'
const FEATURED_ROW = '.cloud-library-snippets tbody tr.demo-featured-row'

test.describe('Cloud Library demo', () => {
test('the tab carries a demo badge rather than announcing itself as new', async ({ page }) => {
await page.goto('/wp-admin/admin.php?page=snippets')
await page.goto(URLS.SNIPPETS_ADMIN)

const link = page.locator('.code-snippets-toolbar-lower a.cloud-library-link')
await expect(link).toBeVisible()
Expand All @@ -21,7 +20,7 @@ test.describe('Cloud Library demo', () => {
})

test('the library is shown as a table on its own before play', async ({ page }) => {
await page.goto(DEMO_URL)
await page.goto(URLS.CLOUD_LIBRARY_ADMIN)

// Deliberately a short library, so the closing panel is reachable.
await expect(page.locator('.cloud-library-snippets tbody tr')).toHaveCount(4)
Expand All @@ -36,7 +35,7 @@ test.describe('Cloud Library demo', () => {
})

test('playing previews, downloads, and leaves the snippet synced', async ({ page }) => {
await page.goto(DEMO_URL)
await page.goto(URLS.CLOUD_LIBRARY_ADMIN)
await page.locator('.demo-play').click()

// The code preview opens on its own, then closes before the download.
Expand All @@ -58,7 +57,7 @@ test.describe('Cloud Library demo', () => {

test('the preview step keeps its callout in place, over the modal overlay', async ({ page }) => {
await page.setViewportSize({ width: 1600, height: 900 })
await page.goto(DEMO_URL)
await page.goto(URLS.CLOUD_LIBRARY_ADMIN)
await page.locator('.demo-play').click()

const modal = page.locator('.code-snippets-preview-modal')
Expand Down Expand Up @@ -90,7 +89,7 @@ test.describe('Cloud Library demo', () => {
})

test('each step marks the click and spotlights what it describes', async ({ page }) => {
await page.goto(DEMO_URL)
await page.goto(URLS.CLOUD_LIBRARY_ADMIN)
await page.locator('.demo-play').click()

const spotlight = page.locator('.demo-spotlight')
Expand All @@ -115,7 +114,7 @@ test.describe('Cloud Library demo', () => {

test('the walkthrough ends scrolled to the closing panel', async ({ page }) => {
await page.setViewportSize({ width: 1280, height: 800 })
await page.goto(DEMO_URL)
await page.goto(URLS.CLOUD_LIBRARY_ADMIN)

await page.locator('.demo-play').click()
await page.getByRole('button', { name: 'Skip animation' }).click()
Expand All @@ -131,7 +130,7 @@ test.describe('Cloud Library demo', () => {
})

test('replaying returns the snippet to its undownloaded state', async ({ page }) => {
await page.goto(DEMO_URL)
await page.goto(URLS.CLOUD_LIBRARY_ADMIN)
await page.locator('.demo-play').click()
await page.getByRole('button', { name: 'Skip animation' }).click()

Expand All @@ -144,7 +143,7 @@ test.describe('Cloud Library demo', () => {
})

test('the walkthrough holds each step long enough to be read', async ({ page }) => {
await page.goto(DEMO_URL)
await page.goto(URLS.CLOUD_LIBRARY_ADMIN)
await page.locator('.demo-play').click()

const steps = await measureCalloutSteps(page)
Expand Down
2 changes: 1 addition & 1 deletion tests/e2e/code-snippets-community-featured.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const closePreviewIfOpen = async (page: Page) => {
}

const openCommunityCloud = async (page: Page) => {
await page.goto(URLS.COMMUNITY_CLOUD_ADMIN)
await page.goto(URLS.CLOUD_COMMUNITY_ADMIN)
await page.waitForLoadState('domcontentloaded')
}

Expand Down
8 changes: 4 additions & 4 deletions tests/e2e/code-snippets-evaluation.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { expect, test } from '@playwright/test'
import { DEFAULT_E2E_SNIPPET_BASE_NAME, SnippetsTestHelper } from './helpers/SnippetsTestHelper'
import { SELECTORS } from './helpers/constants'
import { SELECTORS, URLS } from './helpers/constants'
import { wpCli } from './helpers/wpCli'
import type { Page } from '@playwright/test'

Expand Down Expand Up @@ -113,7 +113,7 @@ test.describe('Code Snippets Evaluation', () => {
code: BODY_CLASS_TEST_CODE
})

await page.goto('/wp-admin/')
await page.goto(URLS.WP_ADMIN)
await expect(page.locator('body')).toHaveClass(/custom-admin-class/)

await helper.navigateToFrontend()
Expand All @@ -127,7 +127,7 @@ test.describe('Code Snippets Evaluation', () => {
code: BODY_CLASS_TEST_CODE
})

await page.goto('/wp-admin/')
await page.goto(URLS.WP_ADMIN)
await expect(page.locator('body')).toHaveClass(/custom-admin-class/)

await helper.navigateToFrontend()
Expand All @@ -141,7 +141,7 @@ test.describe('Code Snippets Evaluation', () => {
code: BODY_CLASS_TEST_CODE
})

await page.goto('/wp-admin/')
await page.goto(URLS.WP_ADMIN)
await expect(page.locator('body')).not.toHaveClass(/custom-admin-class/)

await helper.navigateToFrontend()
Expand Down
9 changes: 5 additions & 4 deletions tests/e2e/code-snippets-quicknav-admin-bar.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { expect, test } from '@playwright/test'
import { SnippetsTestHelper } from './helpers/SnippetsTestHelper'
import { wpCli } from './helpers/wpCli'
import { URLS } from './helpers/constants'

const QUICKNAV_PREFIX = 'E2E QuickNav'
const QUICKNAV_PER_PAGE = 2
Expand Down Expand Up @@ -88,7 +89,7 @@ test.describe('Admin Bar Snippets QuickNav', () => {
const errors: string[] = []
page.on('pageerror', error => errors.push(error.message))

await page.goto('/')
await page.goto(URLS.FRONTEND)

// The admin bar bundle is enqueued on the front end as well as in wp-admin,
// but `wp.i18n`, `wp.url` and `pagenow` are only present in wp-admin unless
Expand Down Expand Up @@ -141,7 +142,7 @@ test.describe('Admin Bar Snippets QuickNav', () => {

await removeMuPlugin()

await page.goto('/wp-admin/admin.php?page=snippets')
await page.goto(URLS.SNIPPETS_ADMIN)
await expect(page.locator('#wp-admin-bar-code-snippets-safe-mode')).toHaveCount(0)

try {
Expand All @@ -158,7 +159,7 @@ test.describe('Admin Bar Snippets QuickNav', () => {
`
])

await page.goto('/wp-admin/admin.php?page=snippets')
await page.goto(URLS.SNIPPETS_ADMIN)
const safeModeNode = page.locator('#wp-admin-bar-code-snippets-safe-mode')
await expect(safeModeNode).toBeVisible({ timeout: 30000 })

Expand All @@ -169,7 +170,7 @@ test.describe('Admin Bar Snippets QuickNav', () => {
await removeMuPlugin()
}

await page.goto('/wp-admin/admin.php?page=snippets')
await page.goto(URLS.SNIPPETS_ADMIN)
await expect(page.locator('#wp-admin-bar-code-snippets-safe-mode')).toHaveCount(0)
})
})
Loading
Loading