From 9706d2434edeb62a7c3896674c95db8195a199d3 Mon Sep 17 00:00:00 2001 From: yoyo201626 <15014217605@163.com> Date: Wed, 22 Nov 2023 15:46:57 +0800 Subject: [PATCH] test(site/loading): [loading] e2e test case completion --- .../sites/demos/pc/app/loading/background.spec.ts | 2 +- .../sites/demos/pc/app/loading/custom-class.spec.ts | 2 +- .../sites/demos/pc/app/loading/directive.spec.ts | 11 ++++++++--- .../sites/demos/pc/app/loading/fullscreen.spec.ts | 1 - .../demos/pc/app/loading/loading-tip-text.spec.ts | 2 +- examples/sites/demos/pc/app/loading/spinner.spec.ts | 13 ++++--------- 6 files changed, 15 insertions(+), 16 deletions(-) diff --git a/examples/sites/demos/pc/app/loading/background.spec.ts b/examples/sites/demos/pc/app/loading/background.spec.ts index 0d1c3a285d..5c0637013d 100644 --- a/examples/sites/demos/pc/app/loading/background.spec.ts +++ b/examples/sites/demos/pc/app/loading/background.spec.ts @@ -4,5 +4,5 @@ test('自定义遮罩背景色', async ({ page }) => { page.on('pageerror', (exception) => expect(exception).toBeNull()) await page.goto('loading#background') const loadingBg = page.locator('.tiny-loading__mask') - await expect(loadingBg).toHaveCSS('background-color', 'rgba(0, 0, 0, 0.3)') + await expect(loadingBg).toHaveCSS('background-color', 'rgba(0, 0, 0, 0.2)') }) diff --git a/examples/sites/demos/pc/app/loading/custom-class.spec.ts b/examples/sites/demos/pc/app/loading/custom-class.spec.ts index 4510540b37..28f5e0d931 100644 --- a/examples/sites/demos/pc/app/loading/custom-class.spec.ts +++ b/examples/sites/demos/pc/app/loading/custom-class.spec.ts @@ -5,6 +5,6 @@ test('自定义样式', async ({ page }) => { await page.goto('loading#custom-class') const loadingBg = page.locator('.tiny-loading__mask') const loadingText = page.locator('.new-loading') - await expect(loadingBg).toHaveCSS('background-color', 'rgba(0, 0, 0, 0.8)') + await expect(loadingBg).toHaveCSS('background-color', 'rgba(0, 0, 0, 0.7)') await expect(loadingText).toBeVisible() }) diff --git a/examples/sites/demos/pc/app/loading/directive.spec.ts b/examples/sites/demos/pc/app/loading/directive.spec.ts index ec25f1fe55..c76b4aadf6 100644 --- a/examples/sites/demos/pc/app/loading/directive.spec.ts +++ b/examples/sites/demos/pc/app/loading/directive.spec.ts @@ -2,7 +2,12 @@ import { test, expect } from '@playwright/test' test('修饰符', async ({ page }) => { page.on('pageerror', (exception) => expect(exception).toBeNull()) - await page.goto('loading#body') - const loadingText = page.locator('.tiny-loading__text') - await expect(loadingText).toHaveText('同 v——loading 指令中的 body 修饰符') + await page.goto('loading#directive') + + await expect(page.getByText('v-loadingText')).not.toBeVisible() + await page.getByRole('button', { name: 'change loading' }).click() + await expect(page.getByText('v-loadingText')).toBeVisible() + + await page.getByRole('button', { name: 'change loading' }).click() + await expect(page.getByText('v-loadingText')).not.toBeVisible() }) diff --git a/examples/sites/demos/pc/app/loading/fullscreen.spec.ts b/examples/sites/demos/pc/app/loading/fullscreen.spec.ts index 72f5e805a5..319ae0dbb7 100644 --- a/examples/sites/demos/pc/app/loading/fullscreen.spec.ts +++ b/examples/sites/demos/pc/app/loading/fullscreen.spec.ts @@ -3,7 +3,6 @@ import { test, expect } from '@playwright/test' test('全局加载', async ({ page }) => { page.on('pageerror', (exception) => expect(exception).toBeNull()) await page.goto('loading#fullscreen') - const loadingText = page.locator('.tiny-loading__text') await page.getByRole('button', { name: '指令方式加载全屏Loading' }).click() const vLoading = page.locator('.circular') await expect(vLoading).toBeVisible() diff --git a/examples/sites/demos/pc/app/loading/loading-tip-text.spec.ts b/examples/sites/demos/pc/app/loading/loading-tip-text.spec.ts index 1c3df484ea..9aa1124bcd 100644 --- a/examples/sites/demos/pc/app/loading/loading-tip-text.spec.ts +++ b/examples/sites/demos/pc/app/loading/loading-tip-text.spec.ts @@ -4,5 +4,5 @@ test('自定义加载提示文本', async ({ page }) => { page.on('pageerror', (exception) => expect(exception).toBeNull()) await page.goto('loading#loading-tip-text') const loadingText = page.locator('.tiny-loading__text') - await expect(loadingText).toBeVisible() + await expect(loadingText).toContainText('加载中') }) diff --git a/examples/sites/demos/pc/app/loading/spinner.spec.ts b/examples/sites/demos/pc/app/loading/spinner.spec.ts index 05e5f93184..7faababd66 100644 --- a/examples/sites/demos/pc/app/loading/spinner.spec.ts +++ b/examples/sites/demos/pc/app/loading/spinner.spec.ts @@ -4,13 +4,8 @@ test('自定义加载图标', async ({ page }) => { page.on('pageerror', (exception) => expect(exception).toBeNull()) await page.goto('loading#spinner') const loadingText = page.locator('.tiny-loading__text') - const sloading = page.locator('.tiny-loading__spinner-small') - const mloading = page.locator('.tiny-loading__spinner-medium') - const lloading = page.locator('.tiny-loading__spinner-large') - const svg = page.locator('.tiny-loading__spinner-large > svg > defs > linearGradient > stop').nth(1) - await expect(loadingText).toHaveText(['自定义loading图标', '自定义loading图标', '自定义loading图标']) - await expect(sloading).toBeVisible() - await expect(mloading).toBeVisible() - await expect(lloading).toBeVisible() - await expect(svg).toHaveAttribute('stop-color', '#191919') + + const svg = page.locator('#tiny-demo-loading-spinner .tiny-icon-loading') + await expect(loadingText).toContainText('自定义loading图标') + await expect(svg).toHaveClass(/tiny-icon-loading/) })