docs: filterAvailableLocales (#11031)
Adding documentation and tests missing in PR #11007 --------- Co-authored-by: Jarrod Flesch <jarrodmflesch@gmail.com> Co-authored-by: Jarrod Flesch <30633324+JarrodMFlesch@users.noreply.github.com>
This commit is contained in:
@@ -414,9 +414,16 @@ export default buildConfigWithDefaults({
|
||||
},
|
||||
],
|
||||
localization: {
|
||||
filterAvailableLocales: ({ locales }) => {
|
||||
return locales.filter((locale) => locale.code !== 'xx')
|
||||
},
|
||||
defaultLocale,
|
||||
fallback: true,
|
||||
locales: [
|
||||
{
|
||||
code: 'xx',
|
||||
label: 'FILTERED',
|
||||
},
|
||||
{
|
||||
code: defaultLocale,
|
||||
label: 'English',
|
||||
|
||||
@@ -97,7 +97,7 @@ describe('Localization', () => {
|
||||
// })
|
||||
})
|
||||
|
||||
describe('localizer', async () => {
|
||||
describe('localizer', () => {
|
||||
test('should show localizer controls', async () => {
|
||||
await page.goto(url.create)
|
||||
await expect(page.locator('.localizer.app-header__localizer')).toBeVisible()
|
||||
@@ -105,6 +105,13 @@ describe('Localization', () => {
|
||||
await expect(page.locator('.localizer .popup.popup--active')).toBeVisible()
|
||||
})
|
||||
|
||||
test('should filter locale with filterAvailableLocales', async () => {
|
||||
await page.goto(url.create)
|
||||
await expect(page.locator('.localizer.app-header__localizer')).toBeVisible()
|
||||
await page.locator('.localizer >> button').first().click()
|
||||
await expect(page.locator('.localizer .popup.popup--active')).not.toContainText('FILTERED')
|
||||
})
|
||||
|
||||
test('should disable control for active locale', async () => {
|
||||
await page.goto(url.create)
|
||||
|
||||
@@ -472,7 +479,7 @@ describe('Localization', () => {
|
||||
await runCopy(page)
|
||||
await expect(page.locator('#field-title')).toHaveValue(title)
|
||||
|
||||
const regexPattern = new RegExp(`locale=es`)
|
||||
const regexPattern = /locale=es/
|
||||
await expect(page).toHaveURL(regexPattern)
|
||||
|
||||
await openCopyToLocaleDrawer(page)
|
||||
|
||||
@@ -68,7 +68,7 @@ export interface Config {
|
||||
'global-array': GlobalArraySelect<false> | GlobalArraySelect<true>;
|
||||
'global-text': GlobalTextSelect<false> | GlobalTextSelect<true>;
|
||||
};
|
||||
locale: 'en' | 'es' | 'pt' | 'ar' | 'hu';
|
||||
locale: 'xx' | 'en' | 'es' | 'pt' | 'ar' | 'hu';
|
||||
user: User & {
|
||||
collection: 'users';
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user