Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
e175338
feat: add new tests
ramiy Sep 15, 2026
d838469
feat: add new tests
ramiy Sep 15, 2026
cb748b5
feat: add new tests
ramiy Sep 15, 2026
bdf27e0
feat: add new tests
ramiy Sep 15, 2026
0f17bd1
refactor: standardize timeout values across tests using TIMEOUTS cons…
ramiy Sep 15, 2026
f04c4ea
feat: add new tests
ramiy Sep 16, 2026
f7fa621
Merge changes from core-beta branch
ramiy Sep 16, 2026
a714eba
Revert "Merge changes from core-beta branch"
ramiy Sep 16, 2026
2a668b8
feat: remove tests
ramiy Sep 18, 2026
7aa83ae
Merge branch 'core-beta' into tests/core
ramiy Sep 18, 2026
251297b
feat: add new tests
ramiy Sep 18, 2026
f422c5e
test: ensure proper cleanup during complete uninstall
ramiy Sep 18, 2026
3547032
test: ensure temporary tables are removed during teardown
ramiy Sep 18, 2026
5689fab
tests: update button name for download action and improve snippet cle…
ramiy Sep 18, 2026
7f2520e
fix: show save shortcut in code editor help
ramiy Sep 18, 2026
e43f574
fix: handle empty tag filter value and reset filters in search results
ramiy Sep 18, 2026
04bccb3
fix: add restore action to bulk operations and update related tests
ramiy Sep 18, 2026
2f60b36
Merge branch 'core-beta' into tests/core
ramiy Sep 18, 2026
bfdcd2f
fix: ensure active snippets are sorted consistently and cleanup snipp…
ramiy Sep 20, 2026
a0956b9
fix: change user from root to www-data in docker exec command
ramiy Sep 20, 2026
2d3e99c
Merge branch 'core-beta' into tests/core
ramiy Sep 20, 2026
7cc8964
feat: add new tests
ramiy Sep 20, 2026
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
Original file line number Diff line number Diff line change
Expand Up @@ -151,9 +151,9 @@ export const CodeEditorShortcuts: React.FC<CodeEditorShortcutsProps> = ({ editor
const keyMapName = codeEditorInstance.codemirror.getOption('keyMap')

const combinedKeyMap: KeyMap = {
...isMacOS() ? fallbackKeyMapMac : fallbackKeyMap,
...keyMapName && getKeyMap(keyMapName),
...'object' === typeof extraKeys ? extraKeys : undefined
...'object' === typeof extraKeys ? extraKeys : undefined,
...isMacOS() ? fallbackKeyMapMac : fallbackKeyMap
}

return unpackKeyMap(combinedKeyMap)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ const FilterByTagControl: React.FC<FilterByTagControlProps> = ({ visibleSnippets
<select
id={tagFilterId}
name="tag"
value={currentTag}
value={currentTag ?? ''}
aria-label={__('Filter snippets by tag', 'code-snippets')}
onChange={event => setCurrentTag(event.target.value)}
>
Expand Down
12 changes: 10 additions & 2 deletions src/js/components/ManageMenu/SnippetsTable/SnippetsTableSearch.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { __, sprintf } from '@wordpress/i18n'
import React from 'react'
import { Button } from '../../common/Button'
import { useSnippetsFilters } from './WithSnippetsTableFilters'
import { INDEX_STATUS, useSnippetsFilters } from './WithSnippetsTableFilters'

export const SearchArea = () => {
const { searchQuery, setSearchQuery } = useSnippetsFilters()
Expand Down Expand Up @@ -30,7 +30,14 @@ export const SearchArea = () => {
}

export const SearchResultsIndicator = () => {
const { searchQueryText, searchLineNumber, currentTag, setSearchQuery, setCurrentTag } = useSnippetsFilters()
const {
searchQueryText,
searchLineNumber,
currentTag,
setCurrentStatus,
setSearchQuery,
setCurrentTag
} = useSnippetsFilters()

return searchQueryText || currentTag
? <p className="snippets-search-subtitle">
Expand All @@ -47,6 +54,7 @@ export const SearchResultsIndicator = () => {

{' '}
<Button small className="clear-filters" onClick={() => {
setCurrentStatus(INDEX_STATUS)
setSearchQuery()
setCurrentTag()
}}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,9 +135,12 @@ export const useApplyBulkAction = (

case 'trash':
case 'delete':
case 'restore':
await applyAndRefresh(
allSnippets.filter(snippet => selected.has(snippet.id)),
snippet => api.delete({ id: snippet.id, network: snippet.network }),
snippet => 'restore' === action
? api.restore({ id: snippet.id, network: snippet.network })
: api.delete({ id: snippet.id, network: snippet.network }),
refreshSnippetsList)
break

Expand Down
4 changes: 2 additions & 2 deletions src/php/Flat_Files/Snippet_Files.php
Original file line number Diff line number Diff line change
Expand Up @@ -484,11 +484,11 @@ public static function get_active_snippets_from_flat_files(
'condition_id' => intval( $snippet['condition_id'] ),
];
}

self::sort_active_snippets( $active_snippets, $db );
}
}

self::sort_active_snippets( $active_snippets, $db );

return $active_snippets;
}

Expand Down
70 changes: 70 additions & 0 deletions tests/e2e/code-snippets-community-featured.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@ const isSnippetDownloadRequest = (url: URL): boolean =>
url.pathname.includes('/cloud/snippets/501/download') ||
true === url.searchParams.get('rest_route')?.includes('/cloud/snippets/501/download')

const isSearchRequest = (url: URL): boolean =>
(url.pathname.includes('/cloud/snippets') || true === url.searchParams.get('rest_route')?.includes('/cloud/snippets')) &&
!isFeaturedRequest(url) && !url.pathname.includes('/download') &&
!url.searchParams.get('rest_route')?.includes('/download')

const makeCloudSnippet = (id: number, name: string, localId: number | null = null) => ({
id,
slug: `mock-cloud-snippet-${id}`,
Expand Down Expand Up @@ -169,6 +174,71 @@ test.describe('Community Cloud Featured Snippets', () => {
.toContainText('An error occurred while fetching search results. Please try again.')
})

test('shows a clear empty state when a keyword search has no results', async ({ page }) => {
await page.route(isSearchRequest, route => route.fulfill({
contentType: 'application/json',
body: JSON.stringify(makeFeaturedResponse([]))
}))
await openCommunityCloud(page)

await page.getByRole('searchbox', { name: 'Search query' }).fill('no matching snippet')
await page.getByRole('button', { name: 'Search Cloud Library' }).click()
await expect(page.locator('.no-results'))
.toHaveText('No snippets could be found with that search term. Please try again.')
})

test('shows a library-specific empty state for a codevault search', async ({ page }) => {
await page.route(isSearchRequest, route => route.fulfill({
contentType: 'application/json',
body: JSON.stringify(makeFeaturedResponse([]))
}))
await openCommunityCloud(page)

await page.getByRole('combobox', { name: 'Search method' }).selectOption('codevault')
await page.getByRole('searchbox', { name: 'Search query' }).fill('missing library')
await page.getByRole('button', { name: 'Search Cloud Library' }).click()
await expect(page.locator('.no-results'))
.toHaveText('Could not find a codevault with that name. Please try again.')
})

test('shows every available cloud filter', async ({ page }) => {
await page.route(isFeaturedRequest, route => route.fulfill({
contentType: 'application/json',
body: JSON.stringify({
...makeFeaturedResponse(),
available_filters: {
categories: [{ id: 12, name: 'Utilities' }],
types: [{ id: 1, name: 'PHP' }],
statuses: [{ id: 4, name: 'Verified' }]
}
})
}))
await openCommunityCloud(page)

await expect(page.getByRole('combobox', { name: 'Snippet Category' })).toContainText('Utilities')
await expect(page.getByRole('combobox', { name: 'Snippet Type' })).toContainText('PHP')
await expect(page.getByRole('combobox', { name: 'Snippet Status' })).toContainText('Verified')
})

test('includes a chosen category in the next cloud request', async ({ page }) => {
await page.route(isFeaturedRequest, route => route.fulfill({
contentType: 'application/json',
body: JSON.stringify({
...makeFeaturedResponse(),
available_filters: { categories: [{ id: 12, name: 'Utilities' }] }
})
}))
await openCommunityCloud(page)
await expect(page.getByRole('combobox', { name: 'Snippet Category' })).toBeVisible()

const filteredRequest = page.waitForRequest(request => {
const url = new URL(request.url())
return isFeaturedRequest(url) && '12' === url.searchParams.get('category')
})
await page.getByRole('combobox', { name: 'Snippet Category' }).selectOption('12')
await filteredRequest
})

test('Shares download state between the card and its preview', async ({ page }) => {
let releaseDownload: VoidFunction = () => undefined
const downloadPending = new Promise<void>(resolve => {
Expand Down
Loading
Loading