fix 0 pending tasks message MM-66695 (#9300)

fix 0 pending tasks message MM-66695
This commit is contained in:
Guillermo Vayá 2025-11-20 17:26:28 +01:00 committed by GitHub
parent c4a2ce38da
commit 79e8d37365
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 38 additions and 5 deletions

View file

@ -354,6 +354,29 @@ describe('PlaybookRun', () => {
expect(finishRun).toHaveBeenCalledWith(serverUrl, props.playbookRun!.id);
});
it('handles finish run button press with no pending tasks', () => {
const props = getBaseProps();
props.participants.push(TestHelper.fakeUserModel({id: props.currentUserId}));
props.pendingCount = 0;
jest.mocked(Alert.alert).mockClear();
const {getByText} = renderWithEverything(<PlaybookRun {...props}/>, {database});
const finishRunButton = getByText('Finish');
fireEvent.press(finishRunButton);
expect(Alert.alert).toHaveBeenCalledWith(
'Finish',
'Are you sure you want to finish the checklist for all participants?',
[
{text: 'Cancel', style: 'cancel'},
{text: 'Finish', style: 'destructive', onPress: expect.any(Function)},
],
);
const finishAction = jest.mocked(Alert.alert).mock.calls[0][2]![1];
finishAction.onPress?.();
expect(finishRun).toHaveBeenCalledWith(serverUrl, props.playbookRun!.id);
});
it('does not render finish run button when read only', () => {
const props = getBaseProps();
const {queryByText} = renderWithEverything(<PlaybookRun {...props}/>, {database});

View file

@ -71,9 +71,13 @@ const messages = defineMessages({
id: 'playbooks.playbook_run.finish_run_dialog_title',
defaultMessage: 'Finish',
},
finishRunDialogDescription: {
id: 'playbooks.playbook_run.finish_run_dialog_description',
defaultMessage: 'There are {pendingCount} {pendingCount, plural, =1 {task} other {tasks}} pending.\n\nAre you sure you want to finish the checklist for all participants?',
finishRunDialogPendingTasks: {
id: 'playbooks.playbook_run.finish_run_dialog_pending_tasks',
defaultMessage: 'There are {pendingCount} {pendingCount, plural, =1 {task} other {tasks}} pending.',
},
finishRunDialogConfirmation: {
id: 'playbooks.playbook_run.finish_run_dialog_confirmation',
defaultMessage: 'Are you sure you want to finish the checklist for all participants?',
},
finishRunDialogCancel: {
id: 'playbooks.playbook_run.finish_run_dialog_cancel',
@ -270,9 +274,14 @@ export default function PlaybookRun({
return;
}
let message = intl.formatMessage(messages.finishRunDialogConfirmation);
if (pendingCount > 0) {
message = `${intl.formatMessage(messages.finishRunDialogPendingTasks, {pendingCount})}\n\n${message}`;
}
Alert.alert(
intl.formatMessage(messages.finishRunDialogTitle),
intl.formatMessage(messages.finishRunDialogDescription, {pendingCount}),
message,
[
{
text: intl.formatMessage(messages.finishRunDialogCancel),

View file

@ -1040,8 +1040,9 @@
"playbooks.playbook_run.error.title": "Unable to fetch details",
"playbooks.playbook_run.finish_run_button": "Finish",
"playbooks.playbook_run.finish_run_dialog_cancel": "Cancel",
"playbooks.playbook_run.finish_run_dialog_description": "There are {pendingCount} {pendingCount, plural, =1 {task} other {tasks}} pending.\n\nAre you sure you want to finish the checklist for all participants?",
"playbooks.playbook_run.finish_run_dialog_confirmation": "Are you sure you want to finish the checklist for all participants?",
"playbooks.playbook_run.finish_run_dialog_finish": "Finish",
"playbooks.playbook_run.finish_run_dialog_pending_tasks": "There are {pendingCount} {pendingCount, plural, =1 {task} other {tasks}} pending.",
"playbooks.playbook_run.finish_run_dialog_title": "Finish",
"playbooks.playbook_run.finished": "Finished",
"playbooks.playbook_run.overdue": "{num} {num, plural, =1 {task} other {tasks}} overdue",