99 lines
2.7 KiB
TypeScript
99 lines
2.7 KiB
TypeScript
export interface ContentData {
|
|
type: 'news' | 'product' | 'service' | 'case';
|
|
title: string;
|
|
slug: string;
|
|
excerpt?: string;
|
|
content?: string;
|
|
category?: string;
|
|
tags?: string[];
|
|
status?: 'draft' | 'published' | 'archived';
|
|
}
|
|
|
|
export interface ContactFormData {
|
|
name: string;
|
|
email: string;
|
|
phone?: string;
|
|
company?: string;
|
|
message: string;
|
|
}
|
|
|
|
export class TestDataFactory {
|
|
private static counter = 0;
|
|
|
|
private static getTimestamp(): string {
|
|
return `${Date.now()}-${++this.counter}`;
|
|
}
|
|
|
|
static createNews(overrides?: Partial<ContentData>): ContentData {
|
|
const timestamp = this.getTimestamp();
|
|
return {
|
|
type: 'news',
|
|
title: `测试新闻-${timestamp}`,
|
|
slug: `test-news-${timestamp}`,
|
|
excerpt: '这是一条测试新闻的摘要内容',
|
|
content: '<p>这是测试新闻的正文内容</p>',
|
|
category: '公司新闻',
|
|
tags: ['测试', '自动化'],
|
|
status: 'published',
|
|
...overrides,
|
|
};
|
|
}
|
|
|
|
static createProduct(overrides?: Partial<ContentData>): ContentData {
|
|
const timestamp = this.getTimestamp();
|
|
return {
|
|
type: 'product',
|
|
title: `测试产品-${timestamp}`,
|
|
slug: `test-product-${timestamp}`,
|
|
excerpt: '这是一个测试产品的描述',
|
|
content: '<p>测试产品的详细介绍</p>',
|
|
category: '软件产品',
|
|
tags: ['产品', '测试'],
|
|
status: 'published',
|
|
...overrides,
|
|
};
|
|
}
|
|
|
|
static createService(overrides?: Partial<ContentData>): ContentData {
|
|
const timestamp = this.getTimestamp();
|
|
return {
|
|
type: 'service',
|
|
title: `测试服务-${timestamp}`,
|
|
slug: `test-service-${timestamp}`,
|
|
excerpt: '这是一个测试服务的描述',
|
|
content: '<p>测试服务的详细介绍</p>',
|
|
category: '软件开发',
|
|
tags: ['服务', '测试'],
|
|
status: 'published',
|
|
...overrides,
|
|
};
|
|
}
|
|
|
|
static createCase(overrides?: Partial<ContentData>): ContentData {
|
|
const timestamp = this.getTimestamp();
|
|
return {
|
|
type: 'case',
|
|
title: `测试案例-${timestamp}`,
|
|
slug: `test-case-${timestamp}`,
|
|
excerpt: '这是一个测试案例的描述',
|
|
content: '<p>测试案例的详细介绍</p>',
|
|
category: '企业服务',
|
|
tags: ['案例', '测试'],
|
|
status: 'published',
|
|
...overrides,
|
|
};
|
|
}
|
|
|
|
static createContactForm(overrides?: Partial<ContactFormData>): ContactFormData {
|
|
const timestamp = this.getTimestamp();
|
|
return {
|
|
name: `测试用户-${timestamp}`,
|
|
email: `test-${timestamp}@example.com`,
|
|
phone: '13800138000',
|
|
company: '测试公司',
|
|
message: '这是一条测试咨询留言',
|
|
...overrides,
|
|
};
|
|
}
|
|
}
|