first commit

This commit is contained in:
2025-11-04 16:29:07 +08:00
commit 8ee74625c7
19 changed files with 4562 additions and 0 deletions

229
pages/EssayWritingPage.ts Normal file
View File

@ -0,0 +1,229 @@
/**
* Essay Writing 页面对象
* 封装文书写作相关的所有操作
*/
import { Page, expect } from '@playwright/test';
import { BasePage } from './BasePage';
export class EssayWritingPage extends BasePage {
constructor(page: Page) {
super(page);
}
/**
* 进入 Essay Writing
*/
async enterEssayWriting(): Promise<void> {
await this.page.getByRole('button', { name: 'documents Essay Writing' }).first().click();
await expect(this.page.getByText('Notes')).toBeVisible();
}
/**
* 添加材料
*/
async addMaterial(title: string, content: string, expectedButtonText: string): Promise<void> {
await this.page.getByRole('button', { name: 'Add Material' }).click();
await this.page.getByRole('menuitem', { name: 'Manual Add' }).click();
await expect(
this.page.getByText('ClassificationGeneralGeneralAcademic Interests and AchievementsInternship and')
).toBeVisible();
await this.page.getByRole('textbox', { name: 'Title' }).click();
await this.page.getByRole('textbox', { name: 'Title' }).fill(title);
await this.page.getByRole('paragraph').filter({ hasText: /^$/ }).click();
await this.page.locator('.tiptap').fill(content);
await this.page.getByRole('button', { name: 'icon Get Suggestions' }).click();
await expect(this.page.getByRole('heading', { name: 'More Suggestions' })).toBeVisible();
await this.page.getByRole('button', { name: 'Create', exact: true }).click();
await expect(this.page.getByRole('button', { name: expectedButtonText })).toBeVisible({
timeout: 15000
});
await this.waitForPageStable(this.config.waits.shortWait);
}
/**
* 探索 Essay Idea
*/
async exploreEssayIdea(): Promise<void> {
await this.page.getByRole('button', { name: 'icon Explore Essay Idea' }).click();
await expect(this.page.getByRole('heading', { name: 'Select an essay prompt or' })).toBeVisible();
}
/**
* 加载 Recommendation
*/
async loadRecommendation(): Promise<void> {
await this.page.getByRole('button', { name: 'icon Recommendation' }).click();
await this.page.waitForTimeout(10000);
console.log('等待 Recommendation 加载完成...');
await expect(this.page.getByRole('heading', { name: 'Recommendation Material' })).toBeVisible({
timeout: this.config.timeouts.grammarCheck
});
console.log('Recommendation Material 已出现');
}
/**
* 生成 Essay Idea
*/
async generateEssayIdea(): Promise<void> {
await this.page.getByRole('button', { name: 'icon Generate Essay Idea' }).click();
await this.page.getByRole('button', { name: 'Generate' }).click();
await expect(this.page.getByRole('heading', { name: 'Essay Idea' })).toBeVisible({
timeout: this.config.timeouts.aiGeneration
});
}
/**
* 生成 Essay
*/
async generateEssay(): Promise<void> {
await this.page.getByRole('button', { name: 'icon Generate Essay' }).click();
await this.page.getByRole('button', { name: 'Generate' }).click();
console.log('等待 Essay 生成完成...');
const loadingMessage = this.page.getByText(/正在生成文书预计需要30秒请耐心等待/i);
console.log('等待加载消息出现...');
await loadingMessage.waitFor({ state: 'visible', timeout: 10000 });
console.log('加载消息已出现,文书正在生成中...');
await loadingMessage.waitFor({ state: 'hidden', timeout: this.config.timeouts.longAiGeneration });
console.log('Essay 生成完成,加载消息已消失');
await this.waitForPageStable();
}
/**
* 语法检查
*/
async performGrammarCheck(): Promise<void> {
await this.page.getByRole('img', { name: 'trigger' }).first().click();
await this.page.getByRole('button', { name: 'Start Grammar Check' }).click();
console.log('等待 Grammar Check 加载完成...');
await expect(this.page.getByRole('heading', { name: 'suggestions' })).toBeVisible({
timeout: this.config.timeouts.grammarCheck
});
console.log('suggestions 已出现');
await expect(this.page.getByLabel('suggestions')).toBeVisible({ timeout: 30000 });
}
/**
* 查重检查
*/
async performPlagiarismCheck(): Promise<void> {
await this.page.getByRole('img', { name: 'trigger' }).nth(1).click();
await this.page.getByRole('button', { name: 'Start Plagiarism Check' }).click();
console.log('等待 Plagiarism Check 加载完成...');
await expect(this.page.getByRole('button', { name: 'Re-check' })).toBeVisible({
timeout: this.config.timeouts.plagiarismCheck
});
console.log('Re-check 已出现');
}
/**
* AI检测
*/
async performAIDetection(): Promise<void> {
await this.page.getByRole('img', { name: 'trigger' }).nth(2).click();
await this.page.getByRole('button', { name: 'Start AI Detection' }).click();
console.log('等待 AI Detection 加载完成...');
await expect(this.page.getByRole('heading', { name: 'GPTZero Premium' })).toBeVisible({
timeout: this.config.timeouts.aiDetection
});
console.log('GPTZero Premium 已出现');
}
/**
* 人性化处理
*/
async performHumanize(): Promise<void> {
await this.page.getByRole('img', { name: 'trigger' }).nth(3).click();
await this.page.getByRole('button', { name: 'Start Humanize' }).click();
console.log('等待 Humanize 加载完成...');
await expect(this.page.getByText('Accept all')).toBeVisible({
timeout: this.config.timeouts.humanize
});
console.log('Accept all 已出现');
}
/**
* 润色
*/
async performPolish(): Promise<void> {
await this.page.getByRole('img', { name: 'trigger' }).nth(4).click();
await this.page.getByRole('button', { name: 'Start Polish' }).click();
console.log('等待 Polish 加载完成...');
await expect(this.page.getByText('All Suggestions')).toBeVisible({
timeout: this.config.timeouts.polish
});
console.log('All Suggestions 已出现');
}
/**
* 评分
*/
async performGetRated(): Promise<void> {
await this.page.getByRole('img', { name: 'trigger' }).nth(5).click();
await this.page.getByRole('button', { name: 'Get Rated' }).click();
console.log('等待 Get Rated 加载完成...');
await expect(this.page.getByRole('heading', { name: 'Your essay rating is:' })).toBeVisible({
timeout: this.config.timeouts.rated
});
console.log('Your essay rating is: 已出现');
}
/**
* Improvement 检查
*/
async performImprovementCheck(): Promise<void> {
await this.page.getByRole('tab', { name: 'Improvement' }).click();
console.log('等待 Improvement 加载完成...');
await expect(this.page.getByText('Accept all')).toBeVisible({
timeout: this.config.timeouts.improvement
});
console.log('Accept all 已出现');
}
/**
* 返回 Essay Writing (从其他页面)
*/
async returnToEssayWriting(): Promise<void> {
await this.page.getByRole('button', { name: 'Essay Writing' }).click();
await expect(this.page.getByRole('button', { name: 'icon Explore Essay Idea' })).toBeVisible({
timeout: 15000
});
}
/**
* 生成 Outline
*/
async generateOutline(): Promise<void> {
await this.page.getByRole('button', { name: 'icon Generate Outline First' }).click();
await this.page.getByRole('button', { name: 'Generate' }).click();
console.log('等待 Outline 生成...');
await expect(this.page.getByRole('heading', { name: 'Untitled Document' })).toBeVisible({
timeout: this.config.timeouts.aiGeneration
});
console.log('Outline 生成完成');
}
/**
* 生成 Draft
*/
async generateDraft(level: string, length: string): Promise<void> {
await this.page.getByRole('button', { name: 'icon Generate Draft' }).click();
await this.page.getByRole('button', { name: level }).click();
await this.page.getByPlaceholder('Enter the expected length...').click();
await this.page.getByPlaceholder('Enter the expected length...').fill(length);
await this.page.getByRole('button', { name: 'Generate' }).click();
console.log('等待 Draft 生成完成...');
const loadingMessage = this.page.getByText(/正在生成文书预计需要30秒请耐心等待/i);
console.log('等待加载消息出现...');
await loadingMessage.waitFor({ state: 'visible', timeout: 10000 });
console.log('加载消息已出现,文书正在生成中...');
}
}