@ncds/ui-admin 1.8.26-alpha.2 → 1.8.26-alpha.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,94 @@
1
+ "use strict";
2
+
3
+ var _nodePath = _interopRequireDefault(require("node:path"));
4
+ var _sass = require("sass");
5
+ var _vitest = require("vitest");
6
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
7
+ // 배경·그림자·패딩은 jsdom 에서 계산되지 않으므로, 컴파일된 CSS 에서 variant 별 규칙을 검사한다.
8
+ // (input-base/__tests__/inputAutofill.test.ts 와 같은 방식 — 컴포넌트 SCSS 엔트리를 직접 컴파일)
9
+ const PAGE_TITLE_SCSS_PATH = _nodePath.default.resolve(__dirname, '../../../../../assets/styles/components/page-title/_index.scss');
10
+ const compiledPageTitleCss = (0, _sass.compile)(PAGE_TITLE_SCSS_PATH).css;
11
+ /** 선택자 → 선언 목록. 같은 선택자가 여러 규칙에 나오면 선언을 이어 붙인다. */
12
+ const parseRules = css => {
13
+ const rules = new Map();
14
+ for (const [, selectorList, body] of css.matchAll(/([^{}]+)\{([^{}]*)\}/g)) {
15
+ const declarations = body.split(';').map(declaration => declaration.trim().replace(/\s+/g, ' ')).filter(Boolean);
16
+ for (const selector of selectorList.split(',').map(selector => selector.trim().replace(/\s+/g, ' '))) {
17
+ rules.set(selector, [...(rules.get(selector) ?? []), ...declarations]);
18
+ }
19
+ }
20
+ return rules;
21
+ };
22
+ const rules = parseRules(compiledPageTitleCss);
23
+ const declarationsOf = selector => rules.get(selector) ?? [];
24
+ const propertiesOf = selector => declarationsOf(selector).map(declaration => declaration.split(':')[0].trim());
25
+ const ROOT = '.ncua-page-title';
26
+ const FIXED = '.ncua-page-title--fixed';
27
+ const PAGE_HEADER = '.ncua-page-title__page-header';
28
+ const FIXED_PAGE_HEADER = '.ncua-page-title--fixed .ncua-page-title__page-header';
29
+ (0, _vitest.describe)('PageTitle 스타일 — Default (·Detail)', () => {
30
+ (0, _vitest.it)('.ncua-page-title 에 background·box-shadow 가 없다 (투명, 그림자 없음)', () => {
31
+ // Given: 컴파일된 PageTitle CSS 에서
32
+ // When: 루트 규칙의 속성을 모으면
33
+ const properties = propertiesOf(ROOT);
34
+ // Then: 루트 규칙은 존재하지만 배경·그림자를 지정하지 않는다
35
+ (0, _vitest.expect)(properties.length).toBeGreaterThan(0);
36
+ (0, _vitest.expect)(properties).not.toContain('background');
37
+ (0, _vitest.expect)(properties).not.toContain('background-color');
38
+ (0, _vitest.expect)(properties).not.toContain('box-shadow');
39
+ });
40
+ (0, _vitest.it)('.ncua-page-title__page-header 패딩은 32px 40px 0 이다', () => {
41
+ // Given: 컴파일된 PageTitle CSS 에서
42
+ // When: page-header 규칙을 찾으면
43
+ const declarations = declarationsOf(PAGE_HEADER);
44
+ // Then: 위 32px · 좌우 40px · 아래 0 이다
45
+ (0, _vitest.expect)(declarations).toContain('padding: 32px 40px 0');
46
+ (0, _vitest.expect)(declarations).not.toContain('padding: 24px 40px');
47
+ });
48
+ });
49
+ (0, _vitest.describe)('PageTitle 스타일 — Fixed (·Fixed Detail)', () => {
50
+ (0, _vitest.it)('.ncua-page-title--fixed 배경은 --gray-50 이다', () => {
51
+ // Given: 컴파일된 PageTitle CSS 에서
52
+ // When: fixed modifier 규칙을 찾으면
53
+ const declarations = declarationsOf(FIXED);
54
+ // Then: sticky 로 콘텐츠 위에 겹치므로 배경 Gray/50 을 가진다
55
+ (0, _vitest.expect)(declarations).toContain('background: var(--gray-50)');
56
+ });
57
+ (0, _vitest.it)('.ncua-page-title--fixed 하단 border 는 1px solid --gray-100 이다', () => {
58
+ // Given/When: fixed modifier 규칙을 찾으면
59
+ const declarations = declarationsOf(FIXED);
60
+ // Then: 기존 Gray/300 이 아니라 Gray/100 border 를 쓴다
61
+ (0, _vitest.expect)(declarations).toContain('border-bottom: 1px solid var(--gray-100)');
62
+ (0, _vitest.expect)(declarations).not.toContain('border-bottom: 1px solid var(--gray-300)');
63
+ });
64
+ (0, _vitest.it)('.ncua-page-title--fixed 에 box-shadow 가 없다', () => {
65
+ // Given/When: fixed modifier 규칙의 속성을 모으면
66
+ // Then: 그림자를 지정하지 않는다
67
+ (0, _vitest.expect)(propertiesOf(FIXED)).not.toContain('box-shadow');
68
+ });
69
+ (0, _vitest.it)('Fixed 의 page-header 패딩은 12px 40px 로 유지된다', () => {
70
+ // Given/When: fixed 하위 page-header 규칙을 찾으면
71
+ // Then: 기존 Fixed 패딩이 그대로다 (범위 밖)
72
+ (0, _vitest.expect)(declarationsOf(FIXED_PAGE_HEADER)).toContain('padding: 12px 40px');
73
+ });
74
+ (0, _vitest.it)('Fixed sticky 동작(position·top·z-index)은 유지된다', () => {
75
+ // Given/When: fixed modifier 규칙을 찾으면
76
+ const declarations = declarationsOf(FIXED);
77
+ // Then: 기존 sticky 선언이 그대로다
78
+ (0, _vitest.expect)(declarations).toContain('position: sticky');
79
+ (0, _vitest.expect)(declarations).toContain('top: 0');
80
+ (0, _vitest.expect)(declarations).toContain('z-index: 999');
81
+ });
82
+ });
83
+ (0, _vitest.describe)('PageTitle 스타일 — 토큰 사용', () => {
84
+ (0, _vitest.it)('배경·border 색상에 하드코딩 값 없이 CSS 변수만 쓴다 (ADR-4)', () => {
85
+ // Given/When: 루트·fixed 규칙의 배경·border 선언을 모으면
86
+ const colorDeclarations = [...declarationsOf(ROOT), ...declarationsOf(FIXED)].filter(declaration => /^(background|border-bottom)/.test(declaration));
87
+ // Then: hex·rgb·색 이름 대신 var(--*) 만 쓴다
88
+ (0, _vitest.expect)(colorDeclarations.length).toBeGreaterThan(0);
89
+ for (const declaration of colorDeclarations) {
90
+ (0, _vitest.expect)(declaration).not.toMatch(/#[0-9a-f]{3,8}\b|rgba?\(|(?<![-\w])white\b/i);
91
+ (0, _vitest.expect)(declaration).toMatch(/var\(--[a-z0-9-]+\)/);
92
+ }
93
+ });
94
+ });