@bernierllc/content-management-tests 0.1.1

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.
package/dist/index.mjs ADDED
@@ -0,0 +1,1068 @@
1
+ "use client";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __commonJS = (cb, mod) => function __require() {
9
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
+ // If the importer is in node compatibility mode or this is not an ESM
21
+ // file that has been converted to a CommonJS file using a Babel-
22
+ // compatible transform (i.e. "__esModule" has not been set), then set
23
+ // "default" to the CommonJS "module.exports" for node compatibility.
24
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
+ mod
26
+ ));
27
+
28
+ // jest.config.js
29
+ var require_jest_config = __commonJS({
30
+ "jest.config.js"(exports, module) {
31
+ "use strict";
32
+ module.exports = {
33
+ testEnvironment: "jsdom",
34
+ setupFilesAfterEnv: ["<rootDir>/src/setup/jest.setup.ts"],
35
+ testMatch: [
36
+ "<rootDir>/src/**/*.test.ts",
37
+ "<rootDir>/src/**/*.test.tsx"
38
+ ],
39
+ collectCoverageFrom: [
40
+ "src/**/*.{ts,tsx}",
41
+ "!src/**/*.test.{ts,tsx}",
42
+ "!src/**/*.stories.{ts,tsx}",
43
+ "!src/setup/**",
44
+ "!src/fixtures/**",
45
+ "!src/mocks/**"
46
+ ],
47
+ coverageThreshold: {
48
+ global: {
49
+ branches: 80,
50
+ functions: 80,
51
+ lines: 80,
52
+ statements: 80
53
+ }
54
+ },
55
+ moduleNameMapper: {
56
+ "^@/(.*)$": "<rootDir>/src/$1",
57
+ "^@test/(.*)$": "<rootDir>/src/test-utils/$1",
58
+ "^@fixtures/(.*)$": "<rootDir>/src/fixtures/$1",
59
+ "^@mocks/(.*)$": "<rootDir>/src/mocks/$1"
60
+ },
61
+ transform: {
62
+ "^.+\\.(ts|tsx)$": "ts-jest"
63
+ }
64
+ };
65
+ }
66
+ });
67
+
68
+ // src/test-utils/test-utils.ts
69
+ import { expect as expect2 } from "@playwright/test";
70
+ var TestUtils = class {
71
+ constructor(page, context) {
72
+ this.page = page;
73
+ this.context = context;
74
+ }
75
+ // Navigation helpers
76
+ async navigateTo(path) {
77
+ await this.page.goto(path);
78
+ await this.page.waitForLoadState("networkidle");
79
+ }
80
+ async waitForElement(selector, timeout = 5e3) {
81
+ await this.page.waitForSelector(selector, { timeout });
82
+ }
83
+ async waitForText(text, timeout = 5e3) {
84
+ await this.page.waitForSelector(`text=${text}`, { timeout });
85
+ }
86
+ // Form helpers
87
+ async fillForm(formData) {
88
+ for (const [field, value] of Object.entries(formData)) {
89
+ await this.page.fill(`[name="${field}"]`, value);
90
+ }
91
+ }
92
+ async clickButton(text) {
93
+ await this.page.click(`button:has-text("${text}")`);
94
+ }
95
+ async clickLink(text) {
96
+ await this.page.click(`a:has-text("${text}")`);
97
+ }
98
+ // Content management helpers
99
+ async createContent(type, data) {
100
+ await this.navigateTo("/admin/content/new");
101
+ await this.page.selectOption('[name="contentType"]', type);
102
+ await this.fillForm(data);
103
+ await this.clickButton("Save as Draft");
104
+ await this.waitForText("Content saved successfully");
105
+ }
106
+ async editContent(contentId, updates) {
107
+ await this.navigateTo(`/admin/content/${contentId}/edit`);
108
+ await this.fillForm(updates);
109
+ await this.clickButton("Save Changes");
110
+ await this.waitForText("Content updated successfully");
111
+ }
112
+ async publishContent(contentId) {
113
+ await this.navigateTo(`/admin/content/${contentId}/edit`);
114
+ await this.clickButton("Publish");
115
+ await this.waitForText("Content published successfully");
116
+ }
117
+ async scheduleContent(contentId, date) {
118
+ await this.navigateTo(`/admin/content/${contentId}/edit`);
119
+ await this.page.fill('[name="publishDate"]', date);
120
+ await this.clickButton("Schedule");
121
+ await this.waitForText("Content scheduled successfully");
122
+ }
123
+ async deleteContent(contentId, soft = true) {
124
+ await this.navigateTo(`/admin/content/${contentId}/edit`);
125
+ await this.clickButton("Delete");
126
+ if (!soft) {
127
+ await this.page.click('[data-testid="confirm-delete"]');
128
+ }
129
+ await this.waitForText("Content deleted successfully");
130
+ }
131
+ // Workflow helpers
132
+ async createWorkflow(workflowData) {
133
+ await this.navigateTo("/admin/workflows/new");
134
+ await this.fillForm(workflowData);
135
+ await this.clickButton("Create Workflow");
136
+ await this.waitForText("Workflow created successfully");
137
+ }
138
+ async updateWorkflow(workflowId, updates) {
139
+ await this.navigateTo(`/admin/workflows/${workflowId}/edit`);
140
+ await this.fillForm(updates);
141
+ await this.clickButton("Update Workflow");
142
+ await this.waitForText("Workflow updated successfully");
143
+ }
144
+ async deleteWorkflow(workflowId) {
145
+ await this.navigateTo(`/admin/workflows/${workflowId}/edit`);
146
+ await this.clickButton("Delete Workflow");
147
+ await this.page.click('[data-testid="confirm-delete"]');
148
+ await this.waitForText("Workflow deleted successfully");
149
+ }
150
+ // Content type helpers
151
+ async createContentType(contentTypeData) {
152
+ await this.navigateTo("/admin/content-types/new");
153
+ await this.fillForm(contentTypeData);
154
+ await this.clickButton("Create Content Type");
155
+ await this.waitForText("Content type created successfully");
156
+ }
157
+ async updateContentType(contentTypeId, updates) {
158
+ await this.navigateTo(`/admin/content-types/${contentTypeId}/edit`);
159
+ await this.fillForm(updates);
160
+ await this.clickButton("Update Content Type");
161
+ await this.waitForText("Content type updated successfully");
162
+ }
163
+ async deleteContentType(contentTypeId) {
164
+ await this.navigateTo(`/admin/content-types/${contentTypeId}/edit`);
165
+ await this.clickButton("Delete Content Type");
166
+ await this.page.click('[data-testid="confirm-delete"]');
167
+ await this.waitForText("Content type deleted successfully");
168
+ }
169
+ // User helpers
170
+ async createUser(userData) {
171
+ await this.navigateTo("/admin/users/new");
172
+ await this.fillForm(userData);
173
+ await this.clickButton("Create User");
174
+ await this.waitForText("User created successfully");
175
+ }
176
+ async updateUser(userId, updates) {
177
+ await this.navigateTo(`/admin/users/${userId}/edit`);
178
+ await this.fillForm(updates);
179
+ await this.clickButton("Update User");
180
+ await this.waitForText("User updated successfully");
181
+ }
182
+ async deleteUser(userId) {
183
+ await this.navigateTo(`/admin/users/${userId}/edit`);
184
+ await this.clickButton("Delete User");
185
+ await this.page.click('[data-testid="confirm-delete"]');
186
+ await this.waitForText("User deleted successfully");
187
+ }
188
+ // Authentication helpers
189
+ async login(email, password) {
190
+ await this.navigateTo("/login");
191
+ await this.fillForm({ email, password });
192
+ await this.clickButton("Login");
193
+ await this.waitForText("Welcome");
194
+ }
195
+ async logout() {
196
+ await this.clickButton("Logout");
197
+ await this.waitForText("Logged out successfully");
198
+ }
199
+ // API helpers
200
+ async apiRequest(method, endpoint, data) {
201
+ const response = await this.page.request.fetch(`/api${endpoint}`, {
202
+ method,
203
+ headers: {
204
+ "Content-Type": "application/json"
205
+ },
206
+ data: data ? JSON.stringify(data) : void 0
207
+ });
208
+ return response;
209
+ }
210
+ async getContent(contentId) {
211
+ const response = await this.apiRequest("GET", `/content/${contentId}`);
212
+ return response.json();
213
+ }
214
+ async createContentViaAPI(type, data) {
215
+ const response = await this.apiRequest("POST", "/content", { type, data });
216
+ return response.json();
217
+ }
218
+ async updateContentViaAPI(contentId, data) {
219
+ const response = await this.apiRequest("PUT", `/content/${contentId}`, { data });
220
+ return response.json();
221
+ }
222
+ async deleteContentViaAPI(contentId, soft = true) {
223
+ const response = await this.apiRequest("DELETE", `/content/${contentId}?soft=${soft}`);
224
+ return response;
225
+ }
226
+ // Assertion helpers
227
+ async expectElementVisible(selector) {
228
+ await expect2(this.page.locator(selector)).toBeVisible();
229
+ }
230
+ async expectElementHidden(selector) {
231
+ await expect2(this.page.locator(selector)).toBeHidden();
232
+ }
233
+ async expectTextVisible(text) {
234
+ await expect2(this.page.locator(`text=${text}`)).toBeVisible();
235
+ }
236
+ async expectTextHidden(text) {
237
+ await expect2(this.page.locator(`text=${text}`)).toBeHidden();
238
+ }
239
+ async expectElementCount(selector, count) {
240
+ await expect2(this.page.locator(selector)).toHaveCount(count);
241
+ }
242
+ async expectElementText(selector, text) {
243
+ await expect2(this.page.locator(selector)).toHaveText(text);
244
+ }
245
+ async expectElementValue(selector, value) {
246
+ await expect2(this.page.locator(selector)).toHaveValue(value);
247
+ }
248
+ // Screenshot helpers
249
+ async takeScreenshot(name) {
250
+ await this.page.screenshot({ path: `test-results/screenshots/${name}.png` });
251
+ }
252
+ async takeElementScreenshot(selector, name) {
253
+ await this.page.locator(selector).screenshot({ path: `test-results/screenshots/${name}.png` });
254
+ }
255
+ // Performance helpers
256
+ async measurePerformance(name, fn) {
257
+ const start = Date.now();
258
+ await fn();
259
+ const end = Date.now();
260
+ console.log(`Performance: ${name} took ${end - start}ms`);
261
+ return end - start;
262
+ }
263
+ // Accessibility helpers
264
+ async checkAccessibility() {
265
+ const elements = await this.page.locator("[role]").all();
266
+ expect2(elements.length).toBeGreaterThan(0);
267
+ }
268
+ // Mobile helpers
269
+ async switchToMobile() {
270
+ await this.page.setViewportSize({ width: 375, height: 667 });
271
+ }
272
+ async switchToTablet() {
273
+ await this.page.setViewportSize({ width: 768, height: 1024 });
274
+ }
275
+ async switchToDesktop() {
276
+ await this.page.setViewportSize({ width: 1920, height: 1080 });
277
+ }
278
+ // Cleanup helpers
279
+ async cleanup() {
280
+ await this.page.evaluate(() => {
281
+ localStorage.clear();
282
+ sessionStorage.clear();
283
+ });
284
+ }
285
+ };
286
+ function createTestUtils(page, context) {
287
+ return new TestUtils(page, context);
288
+ }
289
+
290
+ // src/fixtures/index.ts
291
+ import { faker } from "@faker-js/faker";
292
+ import { v4 as uuidv4 } from "uuid";
293
+ import { addDays, subDays } from "date-fns";
294
+ var contentFixtures = {
295
+ text: {
296
+ id: uuidv4(),
297
+ type: "text",
298
+ title: faker.lorem.sentence(),
299
+ slug: faker.lorem.slug(),
300
+ body: faker.lorem.paragraphs(3),
301
+ excerpt: faker.lorem.sentence(),
302
+ tags: faker.lorem.words(3).split(" "),
303
+ categories: ["general"],
304
+ author: {
305
+ id: uuidv4(),
306
+ name: faker.person.fullName(),
307
+ email: faker.internet.email()
308
+ },
309
+ status: "draft",
310
+ createdAt: /* @__PURE__ */ new Date(),
311
+ updatedAt: /* @__PURE__ */ new Date(),
312
+ publishedAt: null
313
+ },
314
+ image: {
315
+ id: uuidv4(),
316
+ type: "image",
317
+ title: faker.lorem.sentence(),
318
+ slug: faker.lorem.slug(),
319
+ description: faker.lorem.sentence(),
320
+ altText: faker.lorem.sentence(),
321
+ imageUrl: faker.image.url(),
322
+ tags: faker.lorem.words(3).split(" "),
323
+ categories: ["photography"],
324
+ author: {
325
+ id: uuidv4(),
326
+ name: faker.person.fullName(),
327
+ email: faker.internet.email()
328
+ },
329
+ status: "draft",
330
+ createdAt: /* @__PURE__ */ new Date(),
331
+ updatedAt: /* @__PURE__ */ new Date(),
332
+ publishedAt: null
333
+ },
334
+ audio: {
335
+ id: uuidv4(),
336
+ type: "audio",
337
+ title: faker.lorem.sentence(),
338
+ slug: faker.lorem.slug(),
339
+ description: faker.lorem.sentence(),
340
+ audioUrl: faker.internet.url(),
341
+ duration: faker.number.int({ min: 60, max: 3600 }),
342
+ metadata: {
343
+ artist: faker.person.fullName(),
344
+ album: faker.lorem.words(2),
345
+ year: faker.date.past().getFullYear()
346
+ },
347
+ tags: faker.lorem.words(3).split(" "),
348
+ categories: ["podcast"],
349
+ author: {
350
+ id: uuidv4(),
351
+ name: faker.person.fullName(),
352
+ email: faker.internet.email()
353
+ },
354
+ status: "draft",
355
+ createdAt: /* @__PURE__ */ new Date(),
356
+ updatedAt: /* @__PURE__ */ new Date(),
357
+ publishedAt: null
358
+ },
359
+ video: {
360
+ id: uuidv4(),
361
+ type: "video",
362
+ title: faker.lorem.sentence(),
363
+ slug: faker.lorem.slug(),
364
+ description: faker.lorem.sentence(),
365
+ videoUrl: faker.internet.url(),
366
+ duration: faker.number.int({ min: 60, max: 3600 }),
367
+ dimensions: {
368
+ width: 1920,
369
+ height: 1080
370
+ },
371
+ metadata: {
372
+ director: faker.person.fullName(),
373
+ genre: faker.lorem.word(),
374
+ year: faker.date.past().getFullYear()
375
+ },
376
+ tags: faker.lorem.words(3).split(" "),
377
+ categories: ["tutorial"],
378
+ author: {
379
+ id: uuidv4(),
380
+ name: faker.person.fullName(),
381
+ email: faker.internet.email()
382
+ },
383
+ status: "draft",
384
+ createdAt: /* @__PURE__ */ new Date(),
385
+ updatedAt: /* @__PURE__ */ new Date(),
386
+ publishedAt: null
387
+ }
388
+ };
389
+ var workflowFixtures = {
390
+ simple: {
391
+ id: "simple",
392
+ name: "Simple Workflow",
393
+ description: "A simple two-stage workflow",
394
+ stages: [
395
+ {
396
+ id: "draft",
397
+ name: "Draft",
398
+ order: 1,
399
+ isPublishStage: false,
400
+ allowsScheduling: false,
401
+ permissions: ["content.edit"]
402
+ },
403
+ {
404
+ id: "published",
405
+ name: "Published",
406
+ order: 2,
407
+ isPublishStage: true,
408
+ allowsScheduling: true,
409
+ permissions: ["content.publish"]
410
+ }
411
+ ],
412
+ transitions: [
413
+ {
414
+ id: "draft-to-published",
415
+ from: "draft",
416
+ to: "published",
417
+ permissions: ["content.publish"]
418
+ }
419
+ ]
420
+ },
421
+ editorial: {
422
+ id: "editorial",
423
+ name: "Editorial Workflow",
424
+ description: "A comprehensive editorial workflow",
425
+ stages: [
426
+ {
427
+ id: "write",
428
+ name: "Write",
429
+ order: 1,
430
+ isPublishStage: false,
431
+ allowsScheduling: false,
432
+ permissions: ["content.edit"]
433
+ },
434
+ {
435
+ id: "edit",
436
+ name: "Edit",
437
+ order: 2,
438
+ isPublishStage: false,
439
+ allowsScheduling: false,
440
+ permissions: ["content.edit"]
441
+ },
442
+ {
443
+ id: "review",
444
+ name: "Review",
445
+ order: 3,
446
+ isPublishStage: false,
447
+ allowsScheduling: false,
448
+ permissions: ["content.review"]
449
+ },
450
+ {
451
+ id: "publish",
452
+ name: "Publish",
453
+ order: 4,
454
+ isPublishStage: true,
455
+ allowsScheduling: true,
456
+ permissions: ["content.publish"]
457
+ }
458
+ ],
459
+ transitions: [
460
+ {
461
+ id: "write-to-edit",
462
+ from: "write",
463
+ to: "edit",
464
+ permissions: ["content.edit"]
465
+ },
466
+ {
467
+ id: "edit-to-review",
468
+ from: "edit",
469
+ to: "review",
470
+ permissions: ["content.review"]
471
+ },
472
+ {
473
+ id: "review-to-publish",
474
+ from: "review",
475
+ to: "publish",
476
+ permissions: ["content.publish"]
477
+ }
478
+ ]
479
+ }
480
+ };
481
+ var userFixtures = {
482
+ admin: {
483
+ id: uuidv4(),
484
+ name: "Admin User",
485
+ email: "admin@example.com",
486
+ role: "admin",
487
+ permissions: ["*"],
488
+ createdAt: /* @__PURE__ */ new Date(),
489
+ updatedAt: /* @__PURE__ */ new Date()
490
+ },
491
+ editor: {
492
+ id: uuidv4(),
493
+ name: "Editor User",
494
+ email: "editor@example.com",
495
+ role: "editor",
496
+ permissions: ["content.edit", "content.publish", "content.schedule"],
497
+ createdAt: /* @__PURE__ */ new Date(),
498
+ updatedAt: /* @__PURE__ */ new Date()
499
+ },
500
+ author: {
501
+ id: uuidv4(),
502
+ name: "Author User",
503
+ email: "author@example.com",
504
+ role: "author",
505
+ permissions: ["content.edit"],
506
+ createdAt: /* @__PURE__ */ new Date(),
507
+ updatedAt: /* @__PURE__ */ new Date()
508
+ },
509
+ user: {
510
+ id: uuidv4(),
511
+ name: "Regular User",
512
+ email: "user@example.com",
513
+ role: "user",
514
+ permissions: ["content.view"],
515
+ createdAt: /* @__PURE__ */ new Date(),
516
+ updatedAt: /* @__PURE__ */ new Date()
517
+ }
518
+ };
519
+ var contentTypeFixtures = {
520
+ text: {
521
+ id: "text",
522
+ name: "Text Content",
523
+ description: "Rich text content with formatting",
524
+ schema: {
525
+ title: { type: "string", required: true },
526
+ slug: { type: "string", required: true },
527
+ body: { type: "string", required: true },
528
+ excerpt: { type: "string", required: false },
529
+ tags: { type: "array", required: false },
530
+ categories: { type: "array", required: false }
531
+ },
532
+ editorConfig: {
533
+ component: "TextEditor",
534
+ fields: [
535
+ { name: "title", type: "text", label: "Title", required: true },
536
+ { name: "slug", type: "text", label: "Slug", required: true },
537
+ { name: "body", type: "textarea", label: "Body", required: true },
538
+ { name: "excerpt", type: "textarea", label: "Excerpt", required: false },
539
+ { name: "tags", type: "tags", label: "Tags", required: false },
540
+ { name: "categories", type: "select", label: "Categories", required: false }
541
+ ]
542
+ }
543
+ },
544
+ image: {
545
+ id: "image",
546
+ name: "Image Content",
547
+ description: "Image content with metadata",
548
+ schema: {
549
+ title: { type: "string", required: true },
550
+ slug: { type: "string", required: true },
551
+ description: { type: "string", required: false },
552
+ altText: { type: "string", required: true },
553
+ imageUrl: { type: "string", required: true },
554
+ tags: { type: "array", required: false },
555
+ categories: { type: "array", required: false }
556
+ },
557
+ editorConfig: {
558
+ component: "ImageEditor",
559
+ fields: [
560
+ { name: "title", type: "text", label: "Title", required: true },
561
+ { name: "slug", type: "text", label: "Slug", required: true },
562
+ { name: "description", type: "textarea", label: "Description", required: false },
563
+ { name: "altText", type: "text", label: "Alt Text", required: true },
564
+ { name: "imageUrl", type: "url", label: "Image URL", required: true },
565
+ { name: "tags", type: "tags", label: "Tags", required: false },
566
+ { name: "categories", type: "select", label: "Categories", required: false }
567
+ ]
568
+ }
569
+ }
570
+ };
571
+ var configFixtures = {
572
+ development: {
573
+ server: {
574
+ port: 3e3,
575
+ host: "localhost",
576
+ cors: {
577
+ origin: "*",
578
+ credentials: true
579
+ }
580
+ },
581
+ database: {
582
+ type: "sqlite",
583
+ name: "content_management_dev"
584
+ },
585
+ logging: {
586
+ level: "debug",
587
+ format: "text",
588
+ console: {
589
+ enabled: true,
590
+ colorize: true
591
+ }
592
+ }
593
+ },
594
+ production: {
595
+ server: {
596
+ port: 80,
597
+ host: "0.0.0.0",
598
+ cors: {
599
+ origin: ["https://myapp.com"],
600
+ credentials: true
601
+ }
602
+ },
603
+ database: {
604
+ type: "postgresql",
605
+ url: "postgresql://user:password@localhost:5432/content_management"
606
+ },
607
+ logging: {
608
+ level: "info",
609
+ format: "json",
610
+ file: {
611
+ enabled: true,
612
+ path: "./logs",
613
+ maxSize: "10MB",
614
+ maxFiles: 5
615
+ }
616
+ }
617
+ }
618
+ };
619
+ var testDataGenerators = {
620
+ generateContent: (type, overrides = {}) => {
621
+ const base = contentFixtures[type];
622
+ return {
623
+ ...base,
624
+ id: uuidv4(),
625
+ ...overrides
626
+ };
627
+ },
628
+ generateWorkflow: (overrides = {}) => {
629
+ return {
630
+ ...workflowFixtures.simple,
631
+ id: uuidv4(),
632
+ ...overrides
633
+ };
634
+ },
635
+ generateUser: (role = "user", overrides = {}) => {
636
+ const base = userFixtures[role];
637
+ return {
638
+ ...base,
639
+ id: uuidv4(),
640
+ ...overrides
641
+ };
642
+ },
643
+ generateContentType: (overrides = {}) => {
644
+ return {
645
+ ...contentTypeFixtures.text,
646
+ id: uuidv4(),
647
+ ...overrides
648
+ };
649
+ },
650
+ generateConfig: (environment = "development", overrides = {}) => {
651
+ const base = configFixtures[environment];
652
+ return {
653
+ ...base,
654
+ ...overrides
655
+ };
656
+ }
657
+ };
658
+ var dateFixtures = {
659
+ now: /* @__PURE__ */ new Date(),
660
+ tomorrow: addDays(/* @__PURE__ */ new Date(), 1),
661
+ yesterday: subDays(/* @__PURE__ */ new Date(), 1),
662
+ nextWeek: addDays(/* @__PURE__ */ new Date(), 7),
663
+ lastWeek: subDays(/* @__PURE__ */ new Date(), 7),
664
+ nextMonth: addDays(/* @__PURE__ */ new Date(), 30),
665
+ lastMonth: subDays(/* @__PURE__ */ new Date(), 30)
666
+ };
667
+ var apiResponseFixtures = {
668
+ success: {
669
+ success: true,
670
+ message: "Operation completed successfully",
671
+ data: null
672
+ },
673
+ error: {
674
+ success: false,
675
+ message: "An error occurred",
676
+ error: {
677
+ code: "INTERNAL_ERROR",
678
+ details: "Something went wrong"
679
+ }
680
+ },
681
+ validationError: {
682
+ success: false,
683
+ message: "Validation failed",
684
+ error: {
685
+ code: "VALIDATION_ERROR",
686
+ details: {
687
+ field: "title",
688
+ message: "Title is required"
689
+ }
690
+ }
691
+ }
692
+ };
693
+
694
+ // src/setup/jest.setup.ts
695
+ import "@testing-library/jest-dom";
696
+ import { configure } from "@testing-library/react";
697
+ import { TextEncoder, TextDecoder } from "util";
698
+ configure({ testIdAttribute: "data-testid" });
699
+ global.TextEncoder = TextEncoder;
700
+ global.TextDecoder = TextDecoder;
701
+ global.IntersectionObserver = class IntersectionObserver {
702
+ constructor() {
703
+ }
704
+ disconnect() {
705
+ }
706
+ observe() {
707
+ }
708
+ unobserve() {
709
+ }
710
+ };
711
+ global.ResizeObserver = class ResizeObserver {
712
+ constructor() {
713
+ }
714
+ disconnect() {
715
+ }
716
+ observe() {
717
+ }
718
+ unobserve() {
719
+ }
720
+ };
721
+ Object.defineProperty(window, "matchMedia", {
722
+ writable: true,
723
+ value: jest.fn().mockImplementation((query) => ({
724
+ matches: false,
725
+ media: query,
726
+ onchange: null,
727
+ addListener: jest.fn(),
728
+ // deprecated
729
+ removeListener: jest.fn(),
730
+ // deprecated
731
+ addEventListener: jest.fn(),
732
+ removeEventListener: jest.fn(),
733
+ dispatchEvent: jest.fn()
734
+ }))
735
+ });
736
+ var localStorageMock = {
737
+ getItem: jest.fn(),
738
+ setItem: jest.fn(),
739
+ removeItem: jest.fn(),
740
+ clear: jest.fn()
741
+ };
742
+ global.localStorage = localStorageMock;
743
+ var sessionStorageMock = {
744
+ getItem: jest.fn(),
745
+ setItem: jest.fn(),
746
+ removeItem: jest.fn(),
747
+ clear: jest.fn()
748
+ };
749
+ global.sessionStorage = sessionStorageMock;
750
+ global.fetch = jest.fn();
751
+ var originalError = console.error;
752
+ var originalWarn = console.warn;
753
+ beforeAll(() => {
754
+ console.error = (...args) => {
755
+ if (typeof args[0] === "string" && args[0].includes("Warning: ReactDOM.render is no longer supported")) {
756
+ return;
757
+ }
758
+ originalError.call(console, ...args);
759
+ };
760
+ console.warn = (...args) => {
761
+ if (typeof args[0] === "string" && args[0].includes("Warning: ReactDOM.render is no longer supported")) {
762
+ return;
763
+ }
764
+ originalWarn.call(console, ...args);
765
+ };
766
+ });
767
+ afterAll(() => {
768
+ console.error = originalError;
769
+ console.warn = originalWarn;
770
+ });
771
+ afterEach(() => {
772
+ jest.clearAllMocks();
773
+ localStorageMock.clear();
774
+ sessionStorageMock.clear();
775
+ });
776
+
777
+ // src/index.ts
778
+ import { render, screen, fireEvent, waitFor } from "@testing-library/react";
779
+ import { userEvent } from "@testing-library/user-event";
780
+ import { test, expect as expect3 } from "@playwright/test";
781
+
782
+ // playwright.config.ts
783
+ import { defineConfig, devices } from "@playwright/test";
784
+ var playwright_config_default = defineConfig({
785
+ testDir: "./src/playwright",
786
+ fullyParallel: true,
787
+ forbidOnly: !!process.env.CI,
788
+ retries: process.env.CI ? 2 : 0,
789
+ workers: process.env.CI ? 1 : void 0,
790
+ reporter: [
791
+ ["html"],
792
+ ["json", { outputFile: "test-results/results.json" }],
793
+ ["junit", { outputFile: "test-results/results.xml" }]
794
+ ],
795
+ use: {
796
+ baseURL: "http://localhost:3000",
797
+ trace: "on-first-retry",
798
+ screenshot: "only-on-failure",
799
+ video: "retain-on-failure"
800
+ },
801
+ projects: [
802
+ {
803
+ name: "chromium",
804
+ use: { ...devices["Desktop Chrome"] }
805
+ },
806
+ {
807
+ name: "firefox",
808
+ use: { ...devices["Desktop Firefox"] }
809
+ },
810
+ {
811
+ name: "webkit",
812
+ use: { ...devices["Desktop Safari"] }
813
+ },
814
+ {
815
+ name: "Mobile Chrome",
816
+ use: { ...devices["Pixel 5"] }
817
+ },
818
+ {
819
+ name: "Mobile Safari",
820
+ use: { ...devices["iPhone 12"] }
821
+ }
822
+ ],
823
+ webServer: {
824
+ command: "npm run start:test",
825
+ url: "http://localhost:3000",
826
+ reuseExistingServer: !process.env.CI,
827
+ timeout: 120 * 1e3
828
+ }
829
+ });
830
+
831
+ // src/index.ts
832
+ var import_jest = __toESM(require_jest_config());
833
+ var TestRunner = class {
834
+ constructor(config) {
835
+ this.suites = [];
836
+ this.config = config;
837
+ }
838
+ addSuite(suite) {
839
+ this.suites.push(suite);
840
+ }
841
+ async runSuite(suiteName) {
842
+ const suite = this.suites.find((s) => s.name === suiteName);
843
+ if (!suite) {
844
+ throw new Error(`Suite ${suiteName} not found`);
845
+ }
846
+ const results = [];
847
+ const startTime = Date.now();
848
+ try {
849
+ if (suite.setup) {
850
+ await suite.setup();
851
+ }
852
+ for (const testCase of suite.tests) {
853
+ if (testCase.skip) {
854
+ results.push({
855
+ name: testCase.name,
856
+ status: "skipped",
857
+ duration: 0
858
+ });
859
+ continue;
860
+ }
861
+ const testStartTime = Date.now();
862
+ try {
863
+ await testCase.test();
864
+ results.push({
865
+ name: testCase.name,
866
+ status: "passed",
867
+ duration: Date.now() - testStartTime
868
+ });
869
+ } catch (error) {
870
+ results.push({
871
+ name: testCase.name,
872
+ status: "failed",
873
+ duration: Date.now() - testStartTime,
874
+ error
875
+ });
876
+ }
877
+ }
878
+ } finally {
879
+ if (suite.teardown) {
880
+ await suite.teardown();
881
+ }
882
+ }
883
+ const summary = {
884
+ total: results.length,
885
+ passed: results.filter((r) => r.status === "passed").length,
886
+ failed: results.filter((r) => r.status === "failed").length,
887
+ skipped: results.filter((r) => r.status === "skipped").length,
888
+ duration: Date.now() - startTime
889
+ };
890
+ return {
891
+ suite: suiteName,
892
+ results,
893
+ summary
894
+ };
895
+ }
896
+ async runAllSuites() {
897
+ const reports = [];
898
+ for (const suite of this.suites) {
899
+ const report = await this.runSuite(suite.name);
900
+ reports.push(report);
901
+ }
902
+ return reports;
903
+ }
904
+ };
905
+ var TestDataGenerator = class {
906
+ static generateContent(type, overrides = {}) {
907
+ const base = {
908
+ id: `test-${Date.now()}`,
909
+ type,
910
+ title: `Test ${type} Content`,
911
+ slug: `test-${type}-content`,
912
+ body: `Test content for ${type}`,
913
+ author: {
914
+ id: "test-user",
915
+ name: "Test User",
916
+ email: "test@example.com"
917
+ },
918
+ status: "draft",
919
+ createdAt: /* @__PURE__ */ new Date(),
920
+ updatedAt: /* @__PURE__ */ new Date()
921
+ };
922
+ return { ...base, ...overrides };
923
+ }
924
+ static generateWorkflow(overrides = {}) {
925
+ const base = {
926
+ id: `test-workflow-${Date.now()}`,
927
+ name: "Test Workflow",
928
+ description: "Test workflow for testing",
929
+ stages: [
930
+ {
931
+ id: "draft",
932
+ name: "Draft",
933
+ order: 1,
934
+ isPublishStage: false,
935
+ allowsScheduling: false,
936
+ permissions: ["content.edit"]
937
+ },
938
+ {
939
+ id: "published",
940
+ name: "Published",
941
+ order: 2,
942
+ isPublishStage: true,
943
+ allowsScheduling: true,
944
+ permissions: ["content.publish"]
945
+ }
946
+ ],
947
+ transitions: [
948
+ {
949
+ id: "draft-to-published",
950
+ from: "draft",
951
+ to: "published",
952
+ permissions: ["content.publish"]
953
+ }
954
+ ]
955
+ };
956
+ return { ...base, ...overrides };
957
+ }
958
+ static generateUser(role = "user", overrides = {}) {
959
+ const base = {
960
+ id: `test-user-${Date.now()}`,
961
+ name: "Test User",
962
+ email: "test@example.com",
963
+ role,
964
+ permissions: role === "admin" ? ["*"] : ["content.view"],
965
+ createdAt: /* @__PURE__ */ new Date(),
966
+ updatedAt: /* @__PURE__ */ new Date()
967
+ };
968
+ return { ...base, ...overrides };
969
+ }
970
+ };
971
+ var TestAssertions = class {
972
+ static async expectElementVisible(page, selector) {
973
+ const element = await page.locator(selector);
974
+ await expect(element).toBeVisible();
975
+ }
976
+ static async expectElementHidden(page, selector) {
977
+ const element = await page.locator(selector);
978
+ await expect(element).toBeHidden();
979
+ }
980
+ static async expectTextVisible(page, text) {
981
+ const element = await page.locator(`text=${text}`);
982
+ await expect(element).toBeVisible();
983
+ }
984
+ static async expectTextHidden(page, text) {
985
+ const element = await page.locator(`text=${text}`);
986
+ await expect(element).toBeHidden();
987
+ }
988
+ static async expectElementCount(page, selector, count) {
989
+ const elements = await page.locator(selector);
990
+ await expect(elements).toHaveCount(count);
991
+ }
992
+ static async expectElementText(page, selector, text) {
993
+ const element = await page.locator(selector);
994
+ await expect(element).toHaveText(text);
995
+ }
996
+ static async expectElementValue(page, selector, value) {
997
+ const element = await page.locator(selector);
998
+ await expect(element).toHaveValue(value);
999
+ }
1000
+ };
1001
+ var TestHelpers = class {
1002
+ static async waitForElement(page, selector, timeout = 5e3) {
1003
+ await page.waitForSelector(selector, { timeout });
1004
+ }
1005
+ static async waitForText(page, text, timeout = 5e3) {
1006
+ await page.waitForSelector(`text=${text}`, { timeout });
1007
+ }
1008
+ static async fillForm(page, formData) {
1009
+ for (const [field, value] of Object.entries(formData)) {
1010
+ await page.fill(`[name="${field}"]`, value);
1011
+ }
1012
+ }
1013
+ static async clickButton(page, text) {
1014
+ await page.click(`button:has-text("${text}")`);
1015
+ }
1016
+ static async clickLink(page, text) {
1017
+ await page.click(`a:has-text("${text}")`);
1018
+ }
1019
+ static async takeScreenshot(page, name) {
1020
+ await page.screenshot({ path: `test-results/screenshots/${name}.png` });
1021
+ }
1022
+ static async measurePerformance(name, fn) {
1023
+ const start = Date.now();
1024
+ await fn();
1025
+ const end = Date.now();
1026
+ console.log(`Performance: ${name} took ${end - start}ms`);
1027
+ return end - start;
1028
+ }
1029
+ };
1030
+ var defaultTestConfig = {
1031
+ baseURL: "http://localhost:3000",
1032
+ timeout: 3e4,
1033
+ retries: 2,
1034
+ workers: 1,
1035
+ reporter: ["html", "json"],
1036
+ browser: ["chromium", "firefox", "webkit"],
1037
+ mobile: true,
1038
+ tablet: true,
1039
+ desktop: true
1040
+ };
1041
+ var export_jestConfig = import_jest.default;
1042
+ export {
1043
+ TestAssertions,
1044
+ TestDataGenerator,
1045
+ TestHelpers,
1046
+ TestRunner,
1047
+ TestUtils,
1048
+ apiResponseFixtures,
1049
+ configFixtures,
1050
+ contentFixtures,
1051
+ contentTypeFixtures,
1052
+ createTestUtils,
1053
+ dateFixtures,
1054
+ defaultTestConfig,
1055
+ expect3 as expect,
1056
+ fireEvent,
1057
+ export_jestConfig as jestConfig,
1058
+ playwright_config_default as playwrightConfig,
1059
+ render,
1060
+ screen,
1061
+ test,
1062
+ testDataGenerators,
1063
+ userEvent,
1064
+ userFixtures,
1065
+ waitFor,
1066
+ workflowFixtures
1067
+ };
1068
+ //# sourceMappingURL=index.mjs.map