diff --git a/apps/web/src/components/affine/new-workspace-setting-detail/delete-leave-workspace/index.tsx b/apps/web/src/components/affine/new-workspace-setting-detail/delete-leave-workspace/index.tsx index 9117d6e877..7cd9d7350a 100644 --- a/apps/web/src/components/affine/new-workspace-setting-detail/delete-leave-workspace/index.tsx +++ b/apps/web/src/components/affine/new-workspace-setting-detail/delete-leave-workspace/index.tsx @@ -31,6 +31,7 @@ export const DeleteLeaveWorkspace: FC<{ onClick={() => { setShowDelete(true); }} + testId="delete-workspace-button" > diff --git a/apps/web/src/components/affine/setting-modal/general-setting/about/index.tsx b/apps/web/src/components/affine/setting-modal/general-setting/about/index.tsx index 0db3d15fd0..40f4dbdea3 100644 --- a/apps/web/src/components/affine/setting-modal/general-setting/about/index.tsx +++ b/apps/web/src/components/affine/setting-modal/general-setting/about/index.tsx @@ -21,7 +21,11 @@ export const AboutAffine = () => { ); return ( <> - + {runtimeConfig.enableNewSettingUnstableApi && environment.isDesktop ? ( { [setTheme] )} > - {t['system']()} - {t['light']()} - {t['dark']()} + + {t['system']()} + + + {t['light']()} + + + {t['dark']()} + ); }; @@ -86,6 +92,7 @@ export const AppearanceSettings = () => { desc={t['Maximum display of content within a page.']()} > changeSwitch('fullWidthLayout', checked)} /> diff --git a/apps/web/src/components/affine/setting-modal/general-setting/index.tsx b/apps/web/src/components/affine/setting-modal/general-setting/index.tsx index 01f7c17585..7b87163b85 100644 --- a/apps/web/src/components/affine/setting-modal/general-setting/index.tsx +++ b/apps/web/src/components/affine/setting-modal/general-setting/index.tsx @@ -16,6 +16,7 @@ export type GeneralSettingList = { key: GeneralSettingKeys; title: string; icon: FC>; + testId: string; }[]; export const useGeneralSettingList = (): GeneralSettingList => { @@ -25,16 +26,19 @@ export const useGeneralSettingList = (): GeneralSettingList => { key: 'appearance', title: t['com.affine.settings.appearance'](), icon: AppearanceIcon, + testId: 'appearance-panel-trigger', }, { key: 'shortcuts', title: t['Keyboard Shortcuts'](), icon: KeyboardIcon, + testId: 'shortcuts-panel-trigger', }, { key: 'about', title: t['About AFFiNE'](), icon: InformationIcon, + testId: 'about-panel-trigger', }, ]; }; diff --git a/apps/web/src/components/affine/setting-modal/general-setting/shortcuts/index.tsx b/apps/web/src/components/affine/setting-modal/general-setting/shortcuts/index.tsx index 3817c50c63..85ac4d2c98 100644 --- a/apps/web/src/components/affine/setting-modal/general-setting/shortcuts/index.tsx +++ b/apps/web/src/components/affine/setting-modal/general-setting/shortcuts/index.tsx @@ -23,6 +23,7 @@ export const Shortcuts = () => { {Object.entries(generalShortcuts).map(([title, shortcuts]) => { diff --git a/apps/web/src/components/affine/setting-modal/setting-sidebar/index.tsx b/apps/web/src/components/affine/setting-modal/setting-sidebar/index.tsx index d448538f3f..89f67b5bc1 100644 --- a/apps/web/src/components/affine/setting-modal/setting-sidebar/index.tsx +++ b/apps/web/src/components/affine/setting-modal/setting-sidebar/index.tsx @@ -46,11 +46,11 @@ export const SettingSidebar = ({ }) => { const t = useAFFiNEI18N(); return ( -
+
{t['Settings']()}
{t['General']()}
- {generalSettingList.map(({ title, icon, key }) => { + {generalSettingList.map(({ title, icon, key, testId }) => { return (
{ onGeneralSettingClick(key); }} + data-testid={testId} > {icon({ className: 'icon' })} {title} diff --git a/apps/web/src/components/root-app-sidebar/index.tsx b/apps/web/src/components/root-app-sidebar/index.tsx index cf43bd2724..bf3cbf0ddc 100644 --- a/apps/web/src/components/root-app-sidebar/index.tsx +++ b/apps/web/src/components/root-app-sidebar/index.tsx @@ -182,7 +182,7 @@ export const RootAppSidebar = ({ {runtimeConfig.enableNewSettingModal ? ( } onClick={onOpenSettingModal}> - + {t['Settings']()} = ({ - title, - subtitle, -}) => { + +export const SettingHeader: FC< + { title: string; subtitle?: string } & Omit< + HTMLAttributes, + 'title' + > +> = ({ title, subtitle, ...otherProps }) => { return ( -
+
{title}
{subtitle}
diff --git a/packages/component/src/components/setting-components/setting-row.tsx b/packages/component/src/components/setting-components/setting-row.tsx index 6955a06ce3..2e6cf2ae78 100644 --- a/packages/component/src/components/setting-components/setting-row.tsx +++ b/packages/component/src/components/setting-components/setting-row.tsx @@ -10,8 +10,17 @@ export const SettingRow: FC< style?: CSSProperties; onClick?: () => void; spreadCol?: boolean; + testId?: string; }> -> = ({ name, desc, children, onClick, style, spreadCol = true }) => { +> = ({ + name, + desc, + children, + onClick, + style, + spreadCol = true, + testId = '', +}) => { return (
{name}
diff --git a/packages/component/src/ui/switch/switch.tsx b/packages/component/src/ui/switch/switch.tsx index 91945f3b56..a6be83833e 100644 --- a/packages/component/src/ui/switch/switch.tsx +++ b/packages/component/src/ui/switch/switch.tsx @@ -1,17 +1,17 @@ // components/switch.tsx import clsx from 'clsx'; -import { useState } from 'react'; +import { type HTMLAttributes, type ReactNode, useState } from 'react'; import * as styles from './index.css'; -type SwitchProps = { +type SwitchProps = Omit, 'onChange'> & { checked?: boolean; onChange?: (checked: boolean) => void; - children?: React.ReactNode; + children?: ReactNode; }; export const Switch = (props: SwitchProps) => { - const { checked, onChange, children } = props; + const { checked, onChange, children, ...otherProps } = props; const [isChecked, setIsChecked] = useState(checked); const handleChange = (event: React.ChangeEvent) => { @@ -21,7 +21,7 @@ export const Switch = (props: SwitchProps) => { }; return ( -