feat(sync-help): SyncHelpModal 4 anchor 섹션 (메인 conflict / 자동 / silent / setup)

This commit is contained in:
altair823
2026-05-10 23:22:29 +09:00
parent 976d53ccfc
commit 5e55cd3469
2 changed files with 186 additions and 0 deletions

View File

@@ -0,0 +1,121 @@
import React, { useEffect, useRef } from 'react';
export type SyncHelpAnchor = 'main-conflict' | 'auto' | 'silent' | 'setup';
interface Props {
onClose: () => void;
initialAnchor?: SyncHelpAnchor;
}
const overlayStyle: React.CSSProperties = {
position: 'fixed', top: 0, left: 0, width: '100vw', height: '100vh',
background: 'rgba(0,0,0,0.4)', display: 'flex', alignItems: 'center',
justifyContent: 'center', zIndex: 110
};
const modalStyle: React.CSSProperties = {
background: '#fff', borderRadius: 8, padding: 20, width: 640,
maxHeight: '80vh', overflow: 'auto', boxShadow: '0 4px 16px rgba(0,0,0,0.2)'
};
const sectionStyle: React.CSSProperties = {
marginTop: 18, paddingTop: 12, borderTop: '1px solid #eee'
};
const h4Style: React.CSSProperties = { fontSize: 14, margin: '0 0 8px 0' };
const pStyle: React.CSSProperties = { fontSize: 12, color: '#444', lineHeight: 1.6, margin: '4px 0' };
const liStyle: React.CSSProperties = { fontSize: 12, color: '#444', lineHeight: 1.6, marginBottom: 4 };
const codeStyle: React.CSSProperties = { background: '#f4f4f4', padding: '1px 4px', borderRadius: 3, fontSize: 11 };
export function SyncHelpModal({ onClose, initialAnchor }: Props): React.ReactElement {
const bodyRef = useRef<HTMLDivElement>(null);
useEffect(() => {
if (!initialAnchor) return;
const el = bodyRef.current?.querySelector(`#${initialAnchor}`);
if (el) el.scrollIntoView({ behavior: 'auto', block: 'start' });
}, [initialAnchor]);
return (
<div style={overlayStyle} onClick={onClose}>
<div ref={bodyRef} style={modalStyle} onClick={(e) => e.stopPropagation()}>
<div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center' }}>
<h3 style={{ margin: 0, fontSize: 16 }}> </h3>
<button onClick={onClose} aria-label="닫기" style={{ background: 'none', border: 'none', fontSize: 18, cursor: 'pointer', color: '#888' }}>×</button>
</div>
<section id="main-conflict" style={sectionStyle}>
<h4 style={h4Style}>1. ( )</h4>
<p style={pStyle}> . "충돌 해결…" ConflictModal path ( / ) .</p>
<p style={{ ...pStyle, marginTop: 10, fontWeight: 600 }}>/ </p>
<ul style={{ paddingLeft: 18, margin: '4px 0' }}>
<li style={liStyle}> ConflictModal </li>
<li style={liStyle}> 트리: 어느 </li>
<li style={liStyle}> ? 'both' ( )</li>
</ul>
<p style={{ ...pStyle, marginTop: 10, fontWeight: 600 }}>/</p>
<ul style={{ paddingLeft: 18, margin: '4px 0' }}>
<li style={liStyle}> trash , </li>
<li style={liStyle}>"삭제가 의도였다" (trash )</li>
<li style={liStyle}>"수정이 더 중요" ( = trash )</li>
</ul>
<p style={{ ...pStyle, marginTop: 10, fontWeight: 600 }}>AI </p>
<ul style={{ paddingLeft: 18, margin: '4px 0' }}>
<li style={liStyle}> AI ( / / ) </li>
<li style={liStyle}> AI ( )</li>
</ul>
</section>
<section id="auto" style={sectionStyle}>
<h4 style={h4Style}>2. ( )</h4>
<ul style={{ paddingLeft: 18, margin: '4px 0' }}>
<li style={liStyle}><b>fetch + rebase</b>: sync (linear history). conflict </li>
<li style={liStyle}><b> sync </b>: push . fetch rebase</li>
<li style={liStyle}><b>push (non-fast-forward)</b>: push fetch + rebase + . rebase conflict </li>
<li style={liStyle}><b> sync </b>: 30 ( ). 1 </li>
</ul>
</section>
<section id="silent" style={sectionStyle}>
<h4 style={h4Style}>3. (silent risk)</h4>
<ul style={{ paddingLeft: 18, margin: '4px 0' }}>
<li style={liStyle}><b> (NTP)</b>: timestamp merge . macOS / Windows NTP </li>
<li style={liStyle}><b> </b>: conflict . </li>
<li style={liStyle}><b> sync silent</b>: sync . sync / 1 </li>
</ul>
</section>
<section id="setup" style={sectionStyle}>
<h4 style={h4Style}>4. Setup / (troubleshoot)</h4>
<p style={{ ...pStyle, fontWeight: 600 }}>URL ( )</p>
<ul style={{ paddingLeft: 18, margin: '4px 0' }}>
<li style={liStyle}>SSH: <code style={codeStyle}>git@host:user/repo.git</code></li>
<li style={liStyle}>HTTPS: <code style={codeStyle}>https://host/user/repo.git</code></li>
<li style={liStyle}> : <code style={codeStyle}>git@https://...</code> 같은 혼합 형식 ✗</li>
</ul>
<p style={{ ...pStyle, fontWeight: 600, marginTop: 10 }}></p>
<ul style={{ paddingLeft: 18, margin: '4px 0' }}>
<li style={liStyle}>SSH: 기기에 SSH key + public key </li>
<li style={liStyle}>HTTPS: OS credential helper (Windows Credential Manager / macOS Keychain) push token . push X</li>
</ul>
<p style={{ ...pStyle, fontWeight: 600, marginTop: 10 }}>"연결 테스트" </p>
<ul style={{ paddingLeft: 18, margin: '4px 0' }}>
<li style={liStyle}>네트워크: 원격 host </li>
<li style={liStyle}>인증: </li>
<li style={liStyle}>URL: 형식 (SSH/HTTPS) + </li>
</ul>
<p style={{ ...pStyle, fontWeight: 600, marginTop: 10 }}></p>
<ul style={{ paddingLeft: 18, margin: '4px 0' }}>
<li style={liStyle}>URL URL . <code style={codeStyle}>git remote set-url origin</code> </li>
</ul>
</section>
</div>
</div>
);
}

View File

@@ -0,0 +1,65 @@
// @vitest-environment jsdom
import { describe, it, expect, vi, beforeEach } from 'vitest';
import '@testing-library/jest-dom/vitest';
import { render, screen, fireEvent, cleanup } from '@testing-library/react';
import React from 'react';
import { SyncHelpModal } from '../../src/renderer/inbox/components/SyncHelpModal';
describe('SyncHelpModal', () => {
beforeEach(() => {
cleanup();
});
it('4 섹션 헤더 렌더링', () => {
render(<SyncHelpModal onClose={() => {}} />);
expect(screen.getByRole('heading', { name: /충돌 해결/ })).toBeInTheDocument();
expect(screen.getByRole('heading', { name: /자동 처리/ })).toBeInTheDocument();
expect(screen.getByRole('heading', { name: /조용히 잘못될 수 있는/ })).toBeInTheDocument();
expect(screen.getByRole('heading', { name: /Setup/ })).toBeInTheDocument();
});
it('각 섹션이 anchor id 보유', () => {
const { container } = render(<SyncHelpModal onClose={() => {}} />);
expect(container.querySelector('#main-conflict')).not.toBeNull();
expect(container.querySelector('#auto')).not.toBeNull();
expect(container.querySelector('#silent')).not.toBeNull();
expect(container.querySelector('#setup')).not.toBeNull();
});
it('초기 anchor prop 으로 해당 섹션 scrollIntoView 호출', () => {
const scrollSpy = vi.fn();
Element.prototype.scrollIntoView = scrollSpy;
render(<SyncHelpModal onClose={() => {}} initialAnchor="main-conflict" />);
expect(scrollSpy).toHaveBeenCalled();
});
it('X 버튼 클릭 → onClose 호출', () => {
const onClose = vi.fn();
render(<SyncHelpModal onClose={onClose} />);
fireEvent.click(screen.getByRole('button', { name: /닫기/ }));
expect(onClose).toHaveBeenCalled();
});
it('overlay 클릭 → onClose 호출', () => {
const onClose = vi.fn();
const { container } = render(<SyncHelpModal onClose={onClose} />);
const overlay = container.firstChild as HTMLElement;
fireEvent.click(overlay);
expect(onClose).toHaveBeenCalled();
});
it('modal body 클릭 → onClose 호출 X (stopPropagation)', () => {
const onClose = vi.fn();
render(<SyncHelpModal onClose={onClose} />);
fireEvent.click(screen.getByRole('heading', { name: /충돌 해결/ }));
expect(onClose).not.toHaveBeenCalled();
});
it('주요 시나리오 키워드 본문 포함 (회귀)', () => {
render(<SyncHelpModal onClose={() => {}} />);
expect(screen.getByText(/편집\/편집/)).toBeInTheDocument();
expect(screen.getByText(/삭제\/편집/)).toBeInTheDocument();
expect(screen.getByText(/AI 결과 충돌/)).toBeInTheDocument();
expect(screen.getByText(/git@https:\/\//)).toBeInTheDocument();
});
});