Skip to content

Commit 6aa95dc

Browse files
fix(console): email delivery is an optional first-run checklist row, and the deployment notice no longer says mail is unset (#32797)
Fixes #32643 Clause-②: yes (widening) Metadata-protocol: none ## 维护者速读 - 改了什么:首页新手清单里的「邮件发送」一行标为「可选」,不再计入进度;其余必需的行都完成后,清单就收起。首页和系统概览的部署提示不再显示「没有设置邮件服务」。 - 为什么改:维护者裁定「环境的新手清单中要求设置邮箱。我觉得这个不应该是必须的设置」。以前不发邮件的管理员和所有托管租户会一直看到清单和这条提示。 - 风险与回滚:只改前端展示,不动服务端和数据。回滚即还原本 PR。服务端仍会返回 `email_not_configured`,只是控制台不再显示它。 - 先看:`ui/apps/console/src/pages/settings/FirstRunChecklist.tsx`(完成判断与「可选」标记);`ui/packages/app-shell/src/console/deployment-notice/deploymentNotice.ts`(不再识别邮件这一项);`ui/apps/console/src/pages/settings/firstRunChecklistLogic.ts`(`checklistCompletion`)。 - 两分钟验证:`cd ui && npx vitest run --root . --project @object-ui/console apps/console/src/pages/settings/__tests__/FirstRunChecklist.test.tsx`,预期全绿,其中「every required row done and mail never set up: the checklist draws nothing」一条通过。 - 需要你做的:无,席位落地。 ## What changes **The mail row is optional** (ruling item 2, coordinator comment 6819876581). `firstRunChecklistLogic.ts` gains `OPTIONAL_ROWS` (`mail`) and `checklistCompletion(rows)`. The checklist draws nothing once every required row it shows is done, whatever the mail row says. The progress line counts required rows only. The mail row carries an "Optional" mark (`console.firstRunChecklist.optional`, added to all 11 packs). A mail setup that delivers still reads done through `isMailConfigured`, unchanged. A done mail row folds with the other done rows, so "Show completed (N)" counts it while the progress line does not. **The notice no longer says mail is unset** (ruling item 3). The server's `email_not_configured` finding (`packages/services/service-settings/src/deployment-notice.ts`, `readDeploymentNotice`) is raised whenever `IEmailService.isConfigured()` is not `true`. That is "mail is unset", not "something needs mail and cannot send it", and the server states nothing narrower. Per the dispatch, no signal is guessed. The console leaves that finding out the way it already leaves out any finding it has no words for. The id is removed from `DeploymentFindingId` / `KNOWN_FINDINGS` and from `findingText`, on Home and System Overview alike. A production deployment whose only finding is the unset email service now shows no notice. Hiding still sends the fingerprint the server served, which still names the finding. **The `mail` Home-item claim is gone.** Only the notice's email line claimed it, and the checklist row stood aside for it. `HomeItem` is now `'connect_assistant'` alone, and the checklist no longer reads `useHomeItemClaimed('mail')`. **Ruling item 1 (the hosted platform channel) is left out, measured.** `GET /api/settings/mail` serves no `live` field on `main`. The mail namespace's live-status provider (`packages/plugins/plugin-email/src/email-plugin.ts` registers `describeLiveMailTransport`, `live-transport-status.ts`) answers `label` / `bannerSeverity` / `bannerText` only and no `values`, so there is no `live.provider` with a `source` to read as `aiProviderState` does. Nothing is invented. The seat routes this to the cloud lane. Landing spot vs the producer: the unset-mail line is produced server-side, at `deployment-notice.ts` line 161. The dispatch bars server changes, so this PR does the console half. The server half (retire `email_not_configured` or narrow it to a real "needs mail and cannot send" signal) is reported to the seat as a finding. ## Tests - `FirstRunChecklist.test.tsx`: new top-level `describe` "email delivery is optional…": the optional mark is on mail only and the count excludes it; every required row done with mail unset draws nothing (and the mail namespace was read); CONTROL with one required row left keeps the checklist with an undone mail row; a delivering setup reads done and moves no required count; the zh mark. The two pins of the retired `mail` claim are removed, and every progress pin's total drops by one (the mail row no longer counts). - `firstRunChecklistLogic.test.ts`: `checklistCompletion` pins, including the CONTROL that a required row keeps it open with mail done. - `DeploymentNotice.test.tsx`: the "owns the email line" describe is replaced by "says nothing about an unset email service": not drawn beside other findings; email-only draws nothing on Home and System Overview; CONTROL that a lone `file_storage_local` still draws. The hide pin still asserts the server's full fingerprint is posted. ## Acceptance notes - `deploymentNotice.finding.emailNotConfigured` is now unreferenced in all 11 packs (`check:i18n-dead-keys`, report-only: `[confirmed]`). It is kept because this lane's surface adds keys only. carrier: the server-side follow-up on `email_not_configured`. That follow-up either reuses the key or deletes it. - The fingerprint still names `email_not_configured`. An administrator who hid a notice with another finding and later configures mail sees the notice again, because the server's fingerprint changed. carrier: the same server-side follow-up. - Observation, not filed: in this tree no package registers a live-status provider for `ai` (`git grep registerLiveStatus` finds only `localization` and `mail`), so `aiProviderState` sees no `live.provider` and the AI row is left out unless a producer elsewhere (e.g. the hosted runtime) states it. carrier: none. ## Verification All readings are on `objectstack` at head `8ed49b217` unless a line names another commit. <details><summary>Tests (scoped, one locked call): 185 files, 2539 passed</summary> - `packages/app-shell/src/console/deployment-notice/` and `packages/app-shell/src/console/home/`: Test Files 40 passed, Tests 255 passed. - `packages/i18n/` (the whole package, including `zh-hant-generated.test.ts`): Test Files 102 passed, Tests 1894 passed, 13 skipped. - `@object-ui/console`, `apps/console/src/pages/settings/` plus the three App/FormPage suites that mount the checklist: Test Files 43 passed, Tests 390 passed. - Lock verdict: `command-exit 0`. Declared narrowing: the full app-shell package was started and stopped at the coordinator's direction, after it had held the shared lock for 83 minutes. The full console package was not run either. CI's Test UI shards run both packages in full. </details> <details><summary>Type-check: i18n, app-shell, console all exit 0</summary> `pnpm --filter @object-ui/i18n type-check && pnpm --filter @object-ui/app-shell type-check && pnpm --filter @object-ui/console type-check` under the lock: `command-exit 0`, no `error TS`. Run at `520b020ee`; the only later commit changes one zh-Hant string value. </details> <details><summary>Ablations: both go red, both restored to HEAD</summary> - `OPTIONAL_ROWS` emptied (`new Set(['mail'])` changed to `new Set([])`, landed: anchor 1 to 0, blob 5970cf6 to b05f7337): 16 failed and 38 passed across the two checklist files, including every optional-mail pin and every `checklistCompletion` pin. Restored: blob equals HEAD, `git diff HEAD` empty. - `email_not_configured` re-admitted to `KNOWN_FINDINGS` (blob 1d69f58 to 7f8909ab): 4 failed and 11 passed in `DeploymentNotice.test.tsx` (the drawn-findings pin, both new "says nothing about mail" pins, and the parse pin). The CONTROL pin stayed green. Restored: blob equals HEAD, `git diff HEAD` empty. </details> <details><summary>Gates</summary> - `node scripts/pm/dispatch-gates.mjs --commands` at `8ed49b217`: 38 commands, the same list as at `520b020ee`. 36 re-run at `8ed49b217`, all exit 0. - `pnpm check:type-check-debt`: exit 0 at `520b020ee` (re-measure OK, 0 raw tsc errors). At `8ed49b217` it is NOT MEASURED: lock queue-timeout (exit 99) behind another lane's run. - `pnpm --dir ui exec vitest run scripts/`: exit 0 at `520b020ee` (171 passed and 2 skipped files, 5062 tests). Not re-run at `8ed49b217`. - `--ran` reconciliation: 38 derived, 38 run, 0 UNRUN. - i18n families (`ui/`): `check:i18n-keys` exit 0, `check:i18n-drift` exit 0 (1 key added, 0 en values changed), `check:i18n-dead-keys` exit 0 (report-only; lists `deploymentNotice.finding.emailNotConfigured` as confirmed dead, see Acceptance notes). </details> --- _Generated by [Claude Code](https://claude.ai/code/session_012MmDsRT6hvZsQH9dTzn4CA)_ --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent 2f80f28 commit 6aa95dc

20 files changed

Lines changed: 277 additions & 141 deletions

File tree

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
---
2+
'@object-ui/console': patch
3+
'@object-ui/i18n': patch
4+
---
5+
6+
fix(console): email delivery is an optional row on the first-run checklist, and Home's deployment notice no longer says that no email service is set up
7+
8+
Clause-②: yes (widening)
9+
Metadata-protocol: none
10+
11+
The first-run checklist on Home stayed until every row was done, so an administrator whose applications send no mail, and every hosted tenant, kept it for good because of the Email delivery row. That row is now marked Optional and is not counted: the progress line counts the other rows, and the checklist disappears once they are done, whether mail is set up or not. A mail setup that delivers still reads done, and the row still links to Setup → Mail Delivery.
12+
13+
The deployment notice no longer draws the server's `email_not_configured` finding ("No email service is set up…"), on Home or on System Overview. The notice should speak about mail only when something needs mail and cannot send it, and the server does not state that today. A production deployment whose only finding is the unset email service now shows no notice. Hiding the notice still sends the fingerprint the server served.
14+
15+
`@object-ui/i18n` adds one locale key in every pack: `console.firstRunChecklist.optional`.

‎ui/apps/console/src/pages/settings/FirstRunChecklist.tsx‎

Lines changed: 33 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,11 @@
2929
* 2. Language and country, 3. timezone, 4. default currency: the
3030
* localization keys, edited in place with the Settings page's own fields,
3131
* pre-filled from the browser and written only on the row's Confirm.
32-
* 5. Email delivery: mail can deliver; links to Setup → Mail Delivery.
33-
* Only for a session that may write mail, and left out while the
34-
* deployment notice on the same page states that no email service is
35-
* set up (it claims the `mail` item, app-shell's `useHomeItemClaim`):
36-
* what that notice says is ruled (objectstack#30120), so the row yields.
32+
* 5. Email delivery, OPTIONAL (objectstack#32643): mail can deliver; links
33+
* to Setup → Mail Delivery. Only for a session that may write mail. The
34+
* row says it is optional and never holds the checklist open
35+
* (`OPTIONAL_ROWS`): a deployment that sends no mail has nothing to set
36+
* up. A setup that delivers still reads done.
3737
* 6. Invite colleagues: a second member or a pending invitation; links to
3838
* Setup → Users, where Invite User is.
3939
* 7. The built-in AI: a provider is in use in the running system, as the
@@ -58,8 +58,10 @@
5858
* zh-CN page read 「当前为English、美国 (US)」.
5959
*
6060
* A row whose state cannot be read is left out rather than shown as not done.
61-
* Once every row shown is done the checklist draws nothing; it comes back on
62-
* its own if a setting is unset again.
61+
* Once every REQUIRED row shown is done the checklist draws nothing, whatever
62+
* the optional rows say (`checklistCompletion`), and its progress line counts
63+
* the required rows alone; it comes back on its own if a setting is unset
64+
* again.
6365
*
6466
* Rows that are done are folded away: the list draws the rows still to do, and
6567
* one control under them names how many are done and shows them (in their
@@ -97,7 +99,6 @@ import {
9799
resolveSetupAppPath,
98100
useConnectedAccess,
99101
useHomeItemClaim,
100-
useHomeItemClaimed,
101102
useMetadata,
102103
} from '@object-ui/app-shell';
103104
import { useAuth } from '@object-ui/auth';
@@ -117,9 +118,11 @@ import {
117118
LOCALE_KEY,
118119
LOCALIZATION_NAMESPACE,
119120
TIMEZONE_KEY,
121+
checklistCompletion,
120122
deviceStorage,
121123
dismissRecordKey,
122124
hasInvitedColleagues,
125+
isOptionalRow,
123126
isOrganizationNamed,
124127
localizationRows,
125128
markDismissed,
@@ -193,19 +196,32 @@ function ChecklistRow({
193196
action?: ReactNode;
194197
children?: ReactNode;
195198
}) {
199+
const { t } = useObjectTranslation();
200+
const optional = isOptionalRow(id);
196201
return (
197202
<li
198203
className="flex items-start gap-3 py-3"
199204
data-testid={`first-run-checklist-row-${id}`}
200205
data-done={done ? 'true' : 'false'}
206+
data-optional={optional ? 'true' : undefined}
201207
>
202208
{done ? (
203209
<CheckCircle2 className="mt-0.5 h-5 w-5 shrink-0 text-success" aria-hidden />
204210
) : (
205211
<Circle className="mt-0.5 h-5 w-5 shrink-0 text-muted-foreground" aria-hidden />
206212
)}
207213
<div className="min-w-0 flex-1">
208-
<p className={cn('text-sm font-medium', done && 'text-muted-foreground')}>{title}</p>
214+
<p className={cn('text-sm font-medium', done && 'text-muted-foreground')}>
215+
{title}
216+
{optional ? (
217+
<span
218+
className="ml-2 rounded-full border border-border px-1.5 py-px align-middle text-[11px] font-normal text-muted-foreground"
219+
data-testid={`first-run-checklist-optional-${id}`}
220+
>
221+
{t('console.firstRunChecklist.optional')}
222+
</span>
223+
) : null}
224+
</p>
209225
{detail ? <p className="mt-0.5 text-[13px] text-muted-foreground">{detail}</p> : null}
210226
{children}
211227
</div>
@@ -465,10 +481,8 @@ export function FirstRunChecklist() {
465481
// connected one only once the checklist is going to draw.
466482
const assistantPath = connectAssistantPath(apps);
467483
const assistant = useConnectedAccess({ enabled: Boolean(settings && !dismissed && assistantPath) });
468-
// One Home card per item (app-shell's `homeItemClaims`): the deployment
469-
// notice's email line outranks the mail row; this checklist's assistant row,
470-
// while it is open, outranks Home's Connect an AI Assistant card.
471-
const mailSaidByNotice = useHomeItemClaimed('mail');
484+
// One Home card per item (app-shell's `homeItemClaims`): this checklist's
485+
// assistant row, while it is open, outranks Home's Connect an AI Assistant card.
472486
const drawsAssistantRow = Boolean(
473487
settings && !dismissed && orgId && userId && recordKey && assistantPath &&
474488
assistant.state === 'ready' && !assistant.connected,
@@ -570,7 +584,7 @@ export function FirstRunChecklist() {
570584
});
571585
}
572586

573-
if (settings.mail && !mailSaidByNotice) {
587+
if (settings.mail) {
574588
const done = settings.mail.done;
575589
rows.push({
576590
id: 'mail',
@@ -676,8 +690,11 @@ export function FirstRunChecklist() {
676690
});
677691
}
678692

693+
// Done rows are folded away, the optional ones included; only the required
694+
// ones decide whether the checklist is still drawn and what its progress says.
679695
const doneCount = rows.filter((row) => row.done).length;
680-
if (rows.length === 0 || doneCount === rows.length) return null;
696+
const completion = checklistCompletion(rows);
697+
if (completion.complete) return null;
681698

682699
const hide = () => {
683700
markDismissed(deviceStorage(), recordKey);
@@ -700,7 +717,7 @@ export function FirstRunChecklist() {
700717
</div>
701718
<div className="flex shrink-0 items-center gap-2">
702719
<span className="text-xs text-muted-foreground" data-testid="first-run-checklist-progress">
703-
{t('console.firstRunChecklist.progress', { done: doneCount, total: rows.length })}
720+
{t('console.firstRunChecklist.progress', { done: completion.done, total: completion.total })}
704721
</span>
705722
<button
706723
type="button"

‎ui/apps/console/src/pages/settings/__tests__/FirstRunChecklist.test.tsx‎

Lines changed: 84 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ vi.mock('@object-ui/react', async (importOriginal) => ({
5959
useAdapter: () => SHELL.adapter,
6060
}));
6161

62-
import { useHomeItemClaim, useHomeItemClaimed, type HomeItem } from '@object-ui/app-shell';
62+
import { useHomeItemClaimed, type HomeItem } from '@object-ui/app-shell';
6363
import { FirstRunChecklist } from '../FirstRunChecklist';
6464
import { __resetBootPainted } from '../../../loadLocales';
6565
import type { Specifier } from '../types';
@@ -292,7 +292,7 @@ describe('each row is read from the real setting', () => {
292292
expect(await screen.findByTestId('first-run-checklist-row-invite')).toBeTruthy();
293293
const ids = ['organization_name', 'language_country', 'timezone', 'currency', 'mail', 'invite'];
294294
for (const id of ids) expect(row(id).getAttribute('data-done')).toBe('false');
295-
expect(screen.getByTestId('first-run-checklist-progress').textContent).toBe('0 of 6 done');
295+
expect(screen.getByTestId('first-run-checklist-progress').textContent).toBe('0 of 5 done');
296296
expect(screen.getByText('Not set yet, so amounts are shown without a currency symbol.')).toBeTruthy();
297297
expect(screen.getByTestId('first-run-checklist-link-organization_name').getAttribute('href')).toBe(
298298
'/apps/setup/sys_organization/record/org_1',
@@ -315,7 +315,7 @@ describe('each row is read from the real setting', () => {
315315
await showDone();
316316
for (const id of ['language_country', 'timezone', 'currency']) expect(row(id).getAttribute('data-done')).toBe('true');
317317
expect(row('organization_name').getAttribute('data-done')).toBe('false');
318-
expect(screen.getByTestId('first-run-checklist-progress').textContent).toBe('3 of 6 done');
318+
expect(screen.getByTestId('first-run-checklist-progress').textContent).toBe('3 of 5 done');
319319
cleanup();
320320

321321
AUTH.activeOrganization = { id: 'org_1', name: 'Acme' };
@@ -488,7 +488,7 @@ describe('Connect an AI assistant: done from a real record, never from a click',
488488
expect(screen.getByTestId('first-run-checklist-link-connect_assistant').getAttribute('href')).toBe(
489489
'/apps/account/page/connect_agent',
490490
);
491-
expect(screen.getByTestId('first-run-checklist-progress').textContent).toBe('0 of 7 done');
491+
expect(screen.getByTestId('first-run-checklist-progress').textContent).toBe('0 of 6 done');
492492
expect(find).toHaveBeenCalledWith('sys_api_key', expect.objectContaining({ $filter: { user_id: 'u_admin' } }));
493493
});
494494

@@ -544,39 +544,12 @@ describe('Connect an AI assistant: done from a real record, never from a click',
544544
});
545545
});
546546

547-
/** Another Home card saying it draws `item` (the deployment notice, for `mail`). */
548-
function Claim({ item }: { item: HomeItem }) {
549-
useHomeItemClaim(item, true);
550-
return null;
551-
}
552-
553547
/** What Home's other cards read: whether some card draws `item`. */
554548
function Claimed({ item }: { item: HomeItem }) {
555549
return <span data-testid={`claimed-${item}`}>{String(useHomeItemClaimed(item))}</span>;
556550
}
557551

558552
describe('one Home card per item (objectstack#32021 item 3)', () => {
559-
it('while the deployment notice draws its email line, the checklist leaves the mail row out', async () => {
560-
const notice = render(<Claim item="mail" />);
561-
renderChecklist(ADMIN);
562-
await screen.findByTestId('first-run-checklist-row-invite');
563-
await settle();
564-
expect(screen.queryByTestId('first-run-checklist-row-mail')).toBeNull();
565-
expect(screen.getByTestId('first-run-checklist-progress').textContent).toBe('0 of 5 done');
566-
567-
// The notice hidden (or gone): the row comes back.
568-
notice.unmount();
569-
expect(await screen.findByTestId('first-run-checklist-row-mail')).toBeTruthy();
570-
expect(screen.getByTestId('first-run-checklist-progress').textContent).toBe('0 of 6 done');
571-
});
572-
573-
it('CONTROL: with no notice drawing it, the mail row is on the list', async () => {
574-
render(<Claimed item="mail" />);
575-
renderChecklist(ADMIN);
576-
expect(await screen.findByTestId('first-run-checklist-row-mail')).toBeTruthy();
577-
expect(screen.getByTestId('claimed-mail').textContent).toBe('false');
578-
});
579-
580553
describe('the assistant row, while open, is what Home says about connecting one', () => {
581554
const ACCOUNT_APP = {
582555
name: 'account',
@@ -679,7 +652,7 @@ describe('the built-in AI: the provider the server runs, from live.provider (obj
679652
expect(within(r).getByText('Set up the built-in AI')).toBeTruthy();
680653
expect(within(r).getByText('No AI provider is in use yet. Choose one and add its key.')).toBeTruthy();
681654
await screen.findByTestId('first-run-checklist-row-invite');
682-
expect(screen.getByTestId('first-run-checklist-progress').textContent).toBe('0 of 7 done');
655+
expect(screen.getByTestId('first-run-checklist-progress').textContent).toBe('0 of 6 done');
683656

684657
fireEvent.click(within(r).getByRole('link', { name: 'Set up' }));
685658
expect(await screen.findByRole('heading', { name: 'AI settings page' })).toBeTruthy();
@@ -719,7 +692,7 @@ describe('the built-in AI: the provider the server runs, from live.provider (obj
719692
await settle();
720693
expect(calls('GET', '/api/settings/ai')).toHaveLength(1);
721694
expect(screen.queryByTestId('first-run-checklist-row-ai_provider')).toBeNull();
722-
expect(screen.getByTestId('first-run-checklist-progress').textContent).toBe('0 of 6 done');
695+
expect(screen.getByTestId('first-run-checklist-progress').textContent).toBe('0 of 5 done');
723696
});
724697

725698
it('a session that may not write ai never reads it and draws no row', async () => {
@@ -789,7 +762,7 @@ describe('rows that are done are folded away, so the card keeps the screen for t
789762
renderChecklist(ADMIN);
790763
await screen.findByTestId('first-run-checklist-row-invite');
791764
expect(drawnRows()).toEqual(['organization_name', 'mail', 'invite']);
792-
expect(screen.getByTestId('first-run-checklist-progress').textContent).toBe('3 of 6 done');
765+
expect(screen.getByTestId('first-run-checklist-progress').textContent).toBe('3 of 5 done');
793766
const toggle = screen.getByTestId('first-run-checklist-toggle-done');
794767
expect(toggle.textContent).toBe('Show completed (3)');
795768
expect(toggle.getAttribute('aria-expanded')).toBe('false');
@@ -812,7 +785,7 @@ describe('rows that are done are folded away, so the card keeps the screen for t
812785
const toggle = await screen.findByTestId('first-run-checklist-toggle-done');
813786
expect(toggle.textContent).toBe('Show completed (1)');
814787
expect(screen.queryByTestId('first-run-checklist-row-currency')).toBeNull();
815-
expect(screen.getByTestId('first-run-checklist-progress').textContent).toBe('1 of 6 done');
788+
expect(screen.getByTestId('first-run-checklist-progress').textContent).toBe('1 of 5 done');
816789
});
817790

818791
it('CONTROL: with nothing done every row is drawn and there is nothing to unfold', async () => {
@@ -831,3 +804,79 @@ describe('rows that are done are folded away, so the card keeps the screen for t
831804
expect(toggle.textContent).toBe('收起已完成的项');
832805
});
833806
});
807+
808+
describe('email delivery is optional: shown, marked so, and never what keeps the checklist open (objectstack#32643)', () => {
809+
// The maintainer's ruling on the card: 「环境的新手清单中要求设置邮箱。我觉得这个不应该是必须的设置」.
810+
function setRequiredRows() {
811+
localizationValues = {
812+
locale: resolved('zh-CN', 'tenant'),
813+
default_country: resolved('CN', 'tenant'),
814+
timezone: resolved('Asia/Shanghai', 'tenant'),
815+
currency: resolved('CNY', 'tenant'),
816+
};
817+
AUTH.activeOrganization = { id: 'org_1', name: 'Acme' };
818+
AUTH.getMembers.mockResolvedValue([{ id: 'm_1' }, { id: 'm_2' }]);
819+
}
820+
const DELIVERING = () => ({
821+
provider: resolved('smtp', 'global'),
822+
smtp_host: resolved('mx', 'global'),
823+
from_email: resolved('a@b.co', 'global'),
824+
});
825+
826+
it('the mail row says it is optional and is left out of the progress count; no other row is marked', async () => {
827+
renderChecklist(ADMIN);
828+
await screen.findByTestId('first-run-checklist-row-invite');
829+
expect(row('mail').getAttribute('data-optional')).toBe('true');
830+
expect(within(row('mail')).getByTestId('first-run-checklist-optional-mail').textContent).toBe('Optional');
831+
for (const id of ['organization_name', 'language_country', 'timezone', 'currency', 'invite']) {
832+
expect(row(id).getAttribute('data-optional')).toBeNull();
833+
expect(screen.queryByTestId(`first-run-checklist-optional-${id}`)).toBeNull();
834+
}
835+
// Six rows drawn, five required.
836+
expect(within(screen.getByTestId('first-run-checklist')).getAllByRole('listitem')).toHaveLength(6);
837+
expect(screen.getByTestId('first-run-checklist-progress').textContent).toBe('0 of 5 done');
838+
});
839+
840+
it('every required row done and mail never set up: the checklist draws nothing', async () => {
841+
setRequiredRows();
842+
renderChecklist(ADMIN);
843+
await settle();
844+
await waitFor(() => expect(AUTH.getMembers).toHaveBeenCalled());
845+
await settle();
846+
// The mail namespace was read, and still answers "not set up".
847+
expect(calls('GET', '/api/settings/mail')).toHaveLength(1);
848+
expect(screen.queryByTestId('first-run-checklist')).toBeNull();
849+
});
850+
851+
it('CONTROL: one required row left, the checklist stays and the unset mail row is on it, not done', async () => {
852+
setRequiredRows();
853+
AUTH.activeOrganization = { id: 'org_1', name: 'Default Organization' };
854+
renderChecklist(ADMIN);
855+
// The invite row is done, so folded: its read is awaited through the count.
856+
await waitFor(() => expect(screen.getByTestId('first-run-checklist-progress').textContent).toBe('4 of 5 done'));
857+
expect(drawnRowIds()).toEqual(['organization_name', 'mail']);
858+
expect(row('mail').getAttribute('data-done')).toBe('false');
859+
});
860+
861+
it('a mail setup that delivers still reads done; it folds with the done rows and moves no required count', async () => {
862+
mailValues = DELIVERING();
863+
renderChecklist(ADMIN);
864+
await screen.findByTestId('first-run-checklist-row-invite');
865+
expect(screen.queryByTestId('first-run-checklist-row-mail')).toBeNull();
866+
expect(screen.getByTestId('first-run-checklist-progress').textContent).toBe('0 of 5 done');
867+
await showDone();
868+
expect(row('mail').getAttribute('data-done')).toBe('true');
869+
expect(screen.getByTestId('first-run-checklist-link-mail').textContent).toBe('Change');
870+
});
871+
872+
it('zh: the optional mark reads in the reader language', async () => {
873+
renderChecklist(ADMIN, 'zh');
874+
expect((await screen.findByTestId('first-run-checklist-optional-mail')).textContent).toBe('可选');
875+
});
876+
877+
function drawnRowIds() {
878+
return within(screen.getByTestId('first-run-checklist'))
879+
.getAllByRole('listitem')
880+
.map((li) => li.getAttribute('data-testid')?.replace('first-run-checklist-row-', ''));
881+
}
882+
});

‎ui/apps/console/src/pages/settings/__tests__/firstRunChecklistLogic.test.ts‎

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import { describe, it, expect } from 'vitest';
1111
import {
1212
DEFAULT_ORGANIZATION_NAME,
1313
browserRegion,
14+
checklistCompletion,
1415
dismissRecordKey,
1516
hasInvitedColleagues,
1617
isKeySet,
@@ -200,3 +201,30 @@ describe('hiding the checklist is a per-device record, per workspace and user',
200201
expect(markDismissed(broken, 'k')).toBe(false);
201202
});
202203
});
204+
205+
describe('completion counts the required rows; email delivery is optional (objectstack#32643)', () => {
206+
const required = ['organization_name', 'language_country', 'timezone', 'currency', 'invite'].map((id) => ({ id, done: true }));
207+
208+
it('every required row done and mail not: complete, and mail is in neither count', () => {
209+
expect(checklistCompletion([...required, { id: 'mail', done: false }])).toEqual({ done: 5, total: 5, complete: true });
210+
});
211+
212+
it('mail done moves neither count', () => {
213+
expect(checklistCompletion([...required, { id: 'mail', done: true }])).toEqual({ done: 5, total: 5, complete: true });
214+
});
215+
216+
it('CONTROL: a required row not done keeps it open, mail done or not', () => {
217+
const open = required.map((r) => (r.id === 'invite' ? { ...r, done: false } : r));
218+
expect(checklistCompletion([...open, { id: 'mail', done: true }])).toEqual({ done: 4, total: 5, complete: false });
219+
expect(checklistCompletion([...open, { id: 'mail', done: false }]).complete).toBe(false);
220+
});
221+
222+
it('the rows outside the localization set count as required too (the AI rows)', () => {
223+
expect(checklistCompletion([{ id: 'ai_provider', done: false }, { id: 'mail', done: false }])).toEqual({
224+
done: 0,
225+
total: 1,
226+
complete: false,
227+
});
228+
expect(checklistCompletion([{ id: 'connect_assistant', done: false }]).complete).toBe(false);
229+
});
230+
});

0 commit comments

Comments
 (0)