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
6 changes: 2 additions & 4 deletions src/js/hooks/useDuplicateReports.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
import { useEffect, useState } from 'react'
import { addQueryArg } from '../utils/restAPI'
import { TIMEOUTS } from '../../../tests/e2e/helpers/constants'
import { useRestAPI } from './useRestAPI'
import type { DuplicateReport, DuplicateSearchResponse } from '../types/Feedback'

/** Shortest title worth looking for existing reports of. */
const MIN_SEARCH_LENGTH = 6

/** How long to wait after the last keystroke before searching. */
const SEARCH_DEBOUNCE_MS = 600

/**
* Offer reports already filed about whatever is being described, so the same problem is
* not reported twice. A cloud that cannot answer leaves the list empty rather than
Expand All @@ -32,7 +30,7 @@ export const useDuplicateReports = (searchUrl: string, title: string): Duplicate
api.get<DuplicateSearchResponse>(addQueryArg({ url: searchUrl, name: 'q', value: query }))
.then(data => active && setDuplicates(data.results))
.catch(() => active && setDuplicates([]))
}, SEARCH_DEBOUNCE_MS)
}, TIMEOUTS.VERY_SHORT)

return () => {
active = false
Expand Down
5 changes: 2 additions & 3 deletions src/js/utils/files.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import { TIMEOUTS } from '../../../tests/e2e/helpers/constants'
import { getSnippetType } from './snippets/snippets'
import type { SnippetsExport } from '../types/schema/SnippetsExport'
import type { Snippet } from '../types/Snippet'

const SECOND_IN_MS = 1000
const TIMEOUT_SECONDS = 40
const JSON_INDENT_SPACES = 2
const EXPORT_FILENAME = 'snippets'
const EXPORT_GENERATOR = 'Code Snippets'
Expand All @@ -24,7 +23,7 @@ export const downloadAsFile = (content: BlobPart, filename: string, type: string
link.download = filename
link.href = URL.createObjectURL(new Blob([content], { type }))

setTimeout(() => URL.revokeObjectURL(link.href), TIMEOUT_SECONDS * SECOND_IN_MS)
setTimeout(() => URL.revokeObjectURL(link.href), TIMEOUTS.DEFAULT)

// Some browsers (notably headless Chromium) can ignore programmatic clicks on detached anchors.
// Appending the link to the DOM before clicking improves reliability.
Expand Down
1 change: 1 addition & 0 deletions tests/e2e/ai-agent-demo.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ test.describe('AI Agent demo', () => {
})

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

Expand Down
1 change: 1 addition & 0 deletions tests/e2e/blueprints-demo.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ test.describe('Blueprints demo', () => {
})

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

Expand Down
4 changes: 1 addition & 3 deletions tests/e2e/code-snippets-community-featured.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ import { TIMEOUTS, URLS } from './helpers/constants'
import { wpCli } from './helpers/wpCli'
import type { Page } from '@playwright/test'

const REFRESH_DELAY = 3000

const switchSnippetView = async (page: Page, view: 'Card view' | 'Table view') => {
const saved = page
.waitForResponse(
Expand Down Expand Up @@ -184,7 +182,7 @@ test.describe('Community Cloud Featured Snippets', () => {

// Hold the refresh back so the card can be checked before it arrives.
if (1 < featuredRequests) {
await new Promise(resolve => setTimeout(resolve, REFRESH_DELAY))
await new Promise(resolve => setTimeout(resolve, TIMEOUTS.SHORT))
}

return route.fulfill({
Expand Down
4 changes: 3 additions & 1 deletion tests/e2e/code-snippets-list.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -635,10 +635,12 @@ test.describe('Manage table Screen Options', () => {

await helper.navigateToSnippetsAdmin()

await openScreenOptions(page)
await page.locator('#adv-settings input.hide-column-tog[value="desc"]').check()

const description = snippetRowByName(page, unrelatedSnippetName).locator('.snippet-description-content')
await expect(description).toBeVisible()

await openScreenOptions(page)
const truncationToggle = page.locator('#snippets-table-truncate-row-values')

await truncationToggle.check()
Expand Down
Loading