@baselineos/experience 0.1.0

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,125 @@
1
+ import { describe, it, expect } from 'vitest';
2
+ import { BaselineExperienceSystem } from '../index.js';
3
+
4
+ describe('experience — consent management', () => {
5
+ it('grants consent and returns a record', () => {
6
+ const exp = new BaselineExperienceSystem();
7
+ const record = exp.grantConsent('user-1', 'data-processing');
8
+ expect(record.id).toMatch(/^consent-/);
9
+ expect(record.userId).toBe('user-1');
10
+ expect(record.scope).toBe('data-processing');
11
+ expect(record.granted).toBe(true);
12
+ });
13
+
14
+ it('checks granted consent', () => {
15
+ const exp = new BaselineExperienceSystem();
16
+ exp.grantConsent('user-1', 'data-processing');
17
+ const result = exp.checkConsent('user-1', 'data-processing');
18
+ expect(result.granted).toBe(true);
19
+ expect(result.record).toBeDefined();
20
+ });
21
+
22
+ it('returns not granted for unknown scope', () => {
23
+ const exp = new BaselineExperienceSystem();
24
+ exp.grantConsent('user-1', 'data-processing');
25
+ const result = exp.checkConsent('user-1', 'analytics');
26
+ expect(result.granted).toBe(false);
27
+ });
28
+
29
+ it('revokes consent', () => {
30
+ const exp = new BaselineExperienceSystem();
31
+ const record = exp.grantConsent('user-1', 'data-processing');
32
+ const revoked = exp.revokeConsent(record.id);
33
+ expect(revoked).toBe(true);
34
+ const result = exp.checkConsent('user-1', 'data-processing');
35
+ expect(result.granted).toBe(false);
36
+ });
37
+
38
+ it('returns false for revoking already-revoked consent', () => {
39
+ const exp = new BaselineExperienceSystem();
40
+ const record = exp.grantConsent('user-1', 'data-processing');
41
+ exp.revokeConsent(record.id);
42
+ const result = exp.revokeConsent(record.id);
43
+ expect(result).toBe(false);
44
+ });
45
+
46
+ it('lists consent records by user', () => {
47
+ const exp = new BaselineExperienceSystem();
48
+ exp.grantConsent('user-1', 'data-processing');
49
+ exp.grantConsent('user-1', 'analytics');
50
+ exp.grantConsent('user-2', 'data-processing');
51
+ const records = exp.getConsentRecords('user-1');
52
+ expect(records).toHaveLength(2);
53
+ });
54
+ });
55
+
56
+ describe('experience — interaction logging', () => {
57
+ it('logs an interaction', () => {
58
+ const exp = new BaselineExperienceSystem();
59
+ const record = exp.logInteraction('user-1', 'query', undefined, { query: 'test' });
60
+ expect(record.id).toMatch(/^interaction-/);
61
+ expect(record.userId).toBe('user-1');
62
+ expect(record.action).toBe('query');
63
+ });
64
+
65
+ it('retrieves interactions by user', () => {
66
+ const exp = new BaselineExperienceSystem();
67
+ exp.logInteraction('user-1', 'query');
68
+ exp.logInteraction('user-2', 'query');
69
+ exp.logInteraction('user-1', 'export');
70
+ const records = exp.getInteractions('user-1');
71
+ expect(records).toHaveLength(2);
72
+ });
73
+ });
74
+
75
+ describe('experience — escalation', () => {
76
+ it('creates an escalation', () => {
77
+ const exp = new BaselineExperienceSystem();
78
+ const record = exp.createEscalation('Model failing', 'high');
79
+ expect(record.id).toMatch(/^escalation-/);
80
+ expect(record.status).toBe('open');
81
+ expect(record.priority).toBe('high');
82
+ });
83
+
84
+ it('acknowledges an escalation', () => {
85
+ const exp = new BaselineExperienceSystem();
86
+ const record = exp.createEscalation('Issue', 'medium');
87
+ const ack = exp.acknowledgeEscalation(record.id);
88
+ expect(ack).toBe(true);
89
+ const escalations = exp.getEscalations('acknowledged');
90
+ expect(escalations).toHaveLength(1);
91
+ });
92
+
93
+ it('resolves an escalation', () => {
94
+ const exp = new BaselineExperienceSystem();
95
+ const record = exp.createEscalation('Issue', 'low');
96
+ exp.acknowledgeEscalation(record.id);
97
+ const resolved = exp.resolveEscalation(record.id);
98
+ expect(resolved).toBe(true);
99
+ expect(exp.getEscalations('resolved')).toHaveLength(1);
100
+ });
101
+ });
102
+
103
+ describe('experience — accessibility', () => {
104
+ it('runs WCAG AA check', () => {
105
+ const exp = new BaselineExperienceSystem();
106
+ const report = exp.runAccessibilityCheck('aa');
107
+ expect(report.level).toBe('aa');
108
+ expect(report.compliant).toBe(true);
109
+ expect(report.checks.length).toBeGreaterThan(0);
110
+ });
111
+
112
+ it('runs WCAG AAA check (may not be fully compliant)', () => {
113
+ const exp = new BaselineExperienceSystem();
114
+ const report = exp.runAccessibilityCheck('aaa');
115
+ expect(report.level).toBe('aaa');
116
+ expect(report.checks.length).toBeGreaterThan(0);
117
+ });
118
+
119
+ it('stores accessibility reports', () => {
120
+ const exp = new BaselineExperienceSystem();
121
+ exp.runAccessibilityCheck('aa');
122
+ exp.runAccessibilityCheck('aaa');
123
+ expect(exp.getAccessibilityReports()).toHaveLength(2);
124
+ });
125
+ });
@@ -0,0 +1,15 @@
1
+ import { describe, it, expect } from 'vitest';
2
+ import { BaselineExperienceSystem } from '../index.js';
3
+
4
+ describe('experience', () => {
5
+ it('should instantiate BaselineExperienceSystem', () => {
6
+ const experience = new BaselineExperienceSystem();
7
+ expect(experience).toBeDefined();
8
+ });
9
+
10
+ it('should report initialized status', () => {
11
+ const experience = new BaselineExperienceSystem();
12
+ const status = experience.getStatus();
13
+ expect(status.initialized).toBe(true);
14
+ });
15
+ });
@@ -0,0 +1,11 @@
1
+ import { describe, it, expect } from 'vitest';
2
+ import { BaselineExperienceSystem } from '../index.js';
3
+
4
+ describe('experience workflow', () => {
5
+ it('runs a basic onboarding flow', async () => {
6
+ const exp = new BaselineExperienceSystem();
7
+ const result = await exp.onboarding.team.start({ name: 'Acme' });
8
+ expect(result.success).toBe(true);
9
+ expect(result.teamId).toBeDefined();
10
+ });
11
+ });
package/src/index.ts ADDED
@@ -0,0 +1,12 @@
1
+ export { BaselineExperienceSystem } from './system.js';
2
+
3
+ export type {
4
+ ExperienceResult,
5
+ ExperienceState,
6
+ ExperienceStatus,
7
+ OnboardingSubsystem,
8
+ CollaborationSubsystem,
9
+ LearningSubsystem,
10
+ GuidesSubsystem,
11
+ SupportSubsystem,
12
+ } from './system.js';