fix: wrong count of non draftAndPublish entries (#24211)

This commit is contained in:
Adrien L 2025-08-26 09:45:23 +02:00 committed by GitHub
parent 9243d2d1af
commit a8a53e3e7c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 37 additions and 11 deletions

View File

@ -304,10 +304,13 @@ const DonutChartSVG = ({ data }: { data: ChartData[] }) => {
fontWeight="normal"
$textColor="neutral600"
>
{formatMessage({
id: 'content-manager.widget.chart-entries.title',
defaultMessage: 'entries',
})}
{formatMessage(
{
id: 'content-manager.widget.chart-entries.count.label',
defaultMessage: '{count, plural, =0 {entries} one {entry} other {entries}}',
},
{ count: total }
)}
</TextChart>
</text>
</svg>

View File

@ -306,6 +306,7 @@
"validation.error.unreadable-required-field": "Your current permissions prevent access to certain required fields. Please request access from an administrator to proceed.",
"bulk-publish.edit": "Edit",
"widget.chart-entries.title": "Entries",
"widget.chart-entries.count.label": "{count, plural, =0 {Entries} one {Entry} other {Entries}}",
"widget.chart-entries.tooltip": "{count} {label}",
"widget.last-edited.title": "Last edited entries",
"widget.last-edited.single-type": "Single-Type",

View File

@ -185,5 +185,6 @@
"popUpWarning.warning.publish-question": "¿Aún quieres publicarlo?",
"popUpwarning.warning.has-draft-relations.button-confirm": "Si, publicar",
"widget.chart-entries.title": "Entradas",
"widget.chart-entries.count.label": "{count, plural, =0 {Entradas} one {Entrada} other {Entradas}}",
"widget.chart-entries.tooltip": "{count} {label}"
}

View File

@ -208,6 +208,7 @@
"history.restore.success.title": "Version restaurée.",
"history.restore.success.message": "Le contenu de la version restaurée n'a pas encore été publié.",
"widget.chart-entries.title": "Entrées",
"widget.chart-entries.count.label": "{count, plural, =0 {entrées} one {entrée} other {entrées}}",
"widget.chart-entries.tooltip": "{count} {label}",
"widget.last-edited.title": "Dernières entrées éditées",
"widget.last-edited.single-type": "Types uniques",

View File

@ -281,10 +281,8 @@ const createHomepageService = ({ strapi }: { strapi: Core.Strapi }) => {
})
.first()
: await strapiDBConnection(tableName)
.select('document_id')
.from(`${tableName}`)
.countDistinct('document_id as count')
.groupBy('document_id')
.from(`${tableName}`)
.first();
countDocuments.published += Number(publishedDocuments?.count) || 0;

View File

@ -2,7 +2,12 @@ import * as React from 'react';
import { NotificationsProvider } from '@strapi/admin/strapi-admin';
import { DesignSystemProvider } from '@strapi/design-system';
import { fireEvent, render as renderRTL, waitForElementToBeRemoved } from '@testing-library/react';
import {
fireEvent,
render as renderRTL,
waitForElementToBeRemoved,
waitFor,
} from '@testing-library/react';
import userEvent from '@testing-library/user-event';
import { IntlProvider } from 'react-intl';
import { QueryClient, QueryClientProvider } from 'react-query';
@ -25,6 +30,9 @@ const render = () => ({
queries: {
retry: false,
},
mutations: {
retry: false,
},
},
});
@ -111,6 +119,10 @@ describe('Roles EditPage', () => {
await waitForElementToBeRemoved(() => getByText('Loading content.'));
await waitFor(() => {
expect(getByRole('textbox', { name: 'Name' })).toBeInTheDocument();
});
await user.type(getByRole('textbox', { name: 'Name' }), 'test');
await user.type(getByRole('textbox', { name: 'Description' }), 'testing');
await user.click(
@ -118,6 +130,11 @@ describe('Roles EditPage', () => {
name: 'Address Define all allowed actions for the api::address plugin.',
})
);
await waitFor(() => {
expect(getByRole('checkbox', { name: 'create' })).toBeInTheDocument();
});
await user.click(getByRole('checkbox', { name: 'create' }));
const button = await findByRole('button', { name: 'Save' });

View File

@ -305,10 +305,15 @@ describe('Homepage API', () => {
},
});
// Publish author (draftAndPublish is false, so created documents are published by default)
// Publish authors (draftAndPublish is false, so created documents are published by default)
await strapi.documents(authorUid).create({
data: {
name: 'Paul McCartney',
name: 'Stephen King',
},
});
await strapi.documents(authorUid).create({
data: {
name: 'Michael Crichton',
},
});
@ -322,7 +327,7 @@ describe('Homepage API', () => {
expect(response.body.data).toMatchObject({
draft: 1,
modified: 1,
published: 1,
published: 2,
});
});