forked from zhongyidian/yx-react-template
feat: 完善课程模板通用能力
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
1e02c7835e
commit
a641d0e2ea
70 files changed
+2868
-205
No files matched your search
@@ -38,6 +38,22 @@ function getCategory(page: Page, title: string): Locator {
|
||||
return page.getByRole("heading", { name: title, exact: true }).locator("..");
|
||||
}
|
||||
|
||||
async function expectDialogContentCentered(page: Page): Promise<void> {
|
||||
const dialogContent = page
|
||||
.getByRole("dialog")
|
||||
.locator(":scope > div")
|
||||
.first();
|
||||
const box = await dialogContent.boundingBox();
|
||||
const viewport = page.viewportSize();
|
||||
|
||||
if (!box || !viewport) {
|
||||
throw new Error("Dialog content or viewport is not visible");
|
||||
}
|
||||
|
||||
const contentCenter = box.x + box.width / 2;
|
||||
expect(Math.abs(contentCenter - viewport.width / 2)).toBeLessThan(2);
|
||||
}
|
||||
|
||||
test.describe("CourseDemo connected flow", () => {
|
||||
test.beforeEach(async ({ page }) => {
|
||||
await page.goto("/#/course-demo");
|
||||
@@ -58,6 +74,7 @@ test.describe("CourseDemo connected flow", () => {
|
||||
// First step should appear
|
||||
await expect(page.locator("text=欢迎进入学生资助政策微课")).toBeVisible();
|
||||
await expect(page.locator("text=1 / 4")).toBeVisible();
|
||||
await expectDialogContentCentered(page);
|
||||
|
||||
// Click next
|
||||
await page.click("button:has-text('了解任务')");
|
||||
|
||||
Reference in new issue
Block a user