mirror of
https://github.com/strapi/strapi.git
synced 2025-10-18 11:32:42 +00:00
fix: wrong count of non draftAndPublish entries (#24211)
This commit is contained in:
parent
9243d2d1af
commit
a8a53e3e7c
@ -304,10 +304,13 @@ const DonutChartSVG = ({ data }: { data: ChartData[] }) => {
|
|||||||
fontWeight="normal"
|
fontWeight="normal"
|
||||||
$textColor="neutral600"
|
$textColor="neutral600"
|
||||||
>
|
>
|
||||||
{formatMessage({
|
{formatMessage(
|
||||||
id: 'content-manager.widget.chart-entries.title',
|
{
|
||||||
defaultMessage: 'entries',
|
id: 'content-manager.widget.chart-entries.count.label',
|
||||||
})}
|
defaultMessage: '{count, plural, =0 {entries} one {entry} other {entries}}',
|
||||||
|
},
|
||||||
|
{ count: total }
|
||||||
|
)}
|
||||||
</TextChart>
|
</TextChart>
|
||||||
</text>
|
</text>
|
||||||
</svg>
|
</svg>
|
||||||
|
@ -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.",
|
"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",
|
"bulk-publish.edit": "Edit",
|
||||||
"widget.chart-entries.title": "Entries",
|
"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.chart-entries.tooltip": "{count} {label}",
|
||||||
"widget.last-edited.title": "Last edited entries",
|
"widget.last-edited.title": "Last edited entries",
|
||||||
"widget.last-edited.single-type": "Single-Type",
|
"widget.last-edited.single-type": "Single-Type",
|
||||||
|
@ -185,5 +185,6 @@
|
|||||||
"popUpWarning.warning.publish-question": "¿Aún quieres publicarlo?",
|
"popUpWarning.warning.publish-question": "¿Aún quieres publicarlo?",
|
||||||
"popUpwarning.warning.has-draft-relations.button-confirm": "Si, publicar",
|
"popUpwarning.warning.has-draft-relations.button-confirm": "Si, publicar",
|
||||||
"widget.chart-entries.title": "Entradas",
|
"widget.chart-entries.title": "Entradas",
|
||||||
|
"widget.chart-entries.count.label": "{count, plural, =0 {Entradas} one {Entrada} other {Entradas}}",
|
||||||
"widget.chart-entries.tooltip": "{count} {label}"
|
"widget.chart-entries.tooltip": "{count} {label}"
|
||||||
}
|
}
|
||||||
|
@ -208,6 +208,7 @@
|
|||||||
"history.restore.success.title": "Version restaurée.",
|
"history.restore.success.title": "Version restaurée.",
|
||||||
"history.restore.success.message": "Le contenu de la version restaurée n'a pas encore été publié.",
|
"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.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.chart-entries.tooltip": "{count} {label}",
|
||||||
"widget.last-edited.title": "Dernières entrées éditées",
|
"widget.last-edited.title": "Dernières entrées éditées",
|
||||||
"widget.last-edited.single-type": "Types uniques",
|
"widget.last-edited.single-type": "Types uniques",
|
||||||
|
@ -281,10 +281,8 @@ const createHomepageService = ({ strapi }: { strapi: Core.Strapi }) => {
|
|||||||
})
|
})
|
||||||
.first()
|
.first()
|
||||||
: await strapiDBConnection(tableName)
|
: await strapiDBConnection(tableName)
|
||||||
.select('document_id')
|
|
||||||
.from(`${tableName}`)
|
|
||||||
.countDistinct('document_id as count')
|
.countDistinct('document_id as count')
|
||||||
.groupBy('document_id')
|
.from(`${tableName}`)
|
||||||
.first();
|
.first();
|
||||||
countDocuments.published += Number(publishedDocuments?.count) || 0;
|
countDocuments.published += Number(publishedDocuments?.count) || 0;
|
||||||
|
|
||||||
|
@ -2,7 +2,12 @@ import * as React from 'react';
|
|||||||
|
|
||||||
import { NotificationsProvider } from '@strapi/admin/strapi-admin';
|
import { NotificationsProvider } from '@strapi/admin/strapi-admin';
|
||||||
import { DesignSystemProvider } from '@strapi/design-system';
|
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 userEvent from '@testing-library/user-event';
|
||||||
import { IntlProvider } from 'react-intl';
|
import { IntlProvider } from 'react-intl';
|
||||||
import { QueryClient, QueryClientProvider } from 'react-query';
|
import { QueryClient, QueryClientProvider } from 'react-query';
|
||||||
@ -25,6 +30,9 @@ const render = () => ({
|
|||||||
queries: {
|
queries: {
|
||||||
retry: false,
|
retry: false,
|
||||||
},
|
},
|
||||||
|
mutations: {
|
||||||
|
retry: false,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -111,6 +119,10 @@ describe('Roles – EditPage', () => {
|
|||||||
|
|
||||||
await waitForElementToBeRemoved(() => getByText('Loading content.'));
|
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: 'Name' }), 'test');
|
||||||
await user.type(getByRole('textbox', { name: 'Description' }), 'testing');
|
await user.type(getByRole('textbox', { name: 'Description' }), 'testing');
|
||||||
await user.click(
|
await user.click(
|
||||||
@ -118,6 +130,11 @@ describe('Roles – EditPage', () => {
|
|||||||
name: 'Address Define all allowed actions for the api::address plugin.',
|
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' }));
|
await user.click(getByRole('checkbox', { name: 'create' }));
|
||||||
|
|
||||||
const button = await findByRole('button', { name: 'Save' });
|
const button = await findByRole('button', { name: 'Save' });
|
||||||
|
@ -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({
|
await strapi.documents(authorUid).create({
|
||||||
data: {
|
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({
|
expect(response.body.data).toMatchObject({
|
||||||
draft: 1,
|
draft: 1,
|
||||||
modified: 1,
|
modified: 1,
|
||||||
published: 1,
|
published: 2,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user