Skip to content

test: add end-to-end tests for mobile adaptation#113

Merged
kagol merged 6 commits intoopentiny:ospp-2025/mobilefrom
WangWant7:test/mobile-adapt
Oct 21, 2025
Merged

test: add end-to-end tests for mobile adaptation#113
kagol merged 6 commits intoopentiny:ospp-2025/mobilefrom
WangWant7:test/mobile-adapt

Conversation

@WangWant7
Copy link
Contributor

@WangWant7 WangWant7 commented Sep 28, 2025

PR

PR Checklist

Please check if your PR fulfills the following requirements:

  • The commit message follows our Commit Message Guidelines
  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Documentation content changes
  • Other... Please describe:

What is the current behavior?

  • Mobile end lacks complete end-to-end tests for adaptive layout and responsiveness.

Issue Number: N/A

What is the new behavior?

  • Added end-to-end tests for mobile adaptation to cover responsive behaviors.
  • Updated mobile responsive styles based on test feedback.

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

Summary by CodeRabbit

  • New Features

    • Responsive grids now adapt pager layout and size to screen width across multiple views.
    • Modal width now switches to 100% at medium screens for better mobile usability.
    • Navbar mobile breakpoint adjusted to 768px for more consistent behavior.
    • Improved mobile scrolling: vertical-only on medium screens; horizontal overflow hidden in user info.
  • Tests

    • Added Playwright end-to-end test setup and script.
    • New mobile E2E tests for navbar, tree menu toggle, grid horizontal scrolling, mini grid sizing, and modal width behavior.

@github-actions github-actions bot added the unit-test Unit test label Sep 28, 2025
@coderabbitai
Copy link

coderabbitai bot commented Sep 28, 2025

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Walkthrough

Adds Playwright-based end-to-end testing with config and mobile specs. Introduces scripts and devDependency. Implements responsive updates: adjusted navbar breakpoint, modal sizing from md breakpoint, responsive grid pager configs and keys across several views, and overflow tweaks in user info.

Changes

Cohort / File(s) Summary
E2E Tooling Setup
package.json, playwright.config.ts
Adds test:e2e script and @playwright/test devDependency. Introduces Playwright config with workers, retries, reporters, device projects, baseURL/trace, and a webServer (pnpm start) for tests.
Responsive & Breakpoint Adjustments
template/tinyvue/src/components/navbar/index.vue, template/tinyvue/src/hooks/responsive.ts, template/tinyvue/src/views/user/info/index.vue
Navbar mobile breakpoint changed to max-width: 768px. useResponsiveSize now uses md for modal width (100%) instead of lg; grid size still based on lg. User info: vertical-only overflow on md and hidden horizontal overflow.
Responsive Grid & Pager Configs
template/tinyvue/src/views/Preview/index.vue, template/tinyvue/src/views/board/home/components/regiontable.vue, template/tinyvue/src/views/board/home/components/roundtable.vue, template/tinyvue/src/views/locale/components/locale-table.vue
Adds useResponsive and useResponsiveSize to drive grid :size, dynamic :key, and conditional pager (sm ? pagerConfigSm : pagerConfigLg). Splits pager configs for small vs large layouts.
Mobile E2E Tests
tests/e2e/mobile/grid.spec.ts, tests/e2e/mobile/modal.spec.ts, tests/e2e/mobile/navbar.spec.ts, tests/e2e/mobile/tree-menu.spec.ts
Adds Playwright tests covering mobile grid horizontal scroll and mini size, modal width (100%), navbar toggle visibility, and tree-menu toggle visibility after login.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant CI/Dev as CI/Dev
  participant PW as Playwright CLI
  participant WS as Web Server (pnpm start)
  participant App as App (localhost)
  participant Test as E2E Specs

  CI/Dev->>PW: npm run test:e2e
  PW->>WS: Launch server (cwd set)
  WS-->>PW: Server ready at baseURL
  PW->>Test: Initialize projects (mobile/tablet)
  loop per spec and project
    Test->>App: open baseURL, navigate, interact
    Test->>App: login, toggle menus, open modal, scroll grid
    App-->>Test: DOM state/attributes
    Test->>PW: assertions (pass/fail), traces as configured
  end
  PW-->>CI/Dev: Report results (list + HTML)
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

I hopped through grids where pages glide,
A toggle blinked, the menus wide—
The modal grew at md’s cue,
While Playwright wrote the paths I flew.
With tiny paws I tap and see,
Green checks bloom—ship happily! 🐇✨

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The title succinctly describes the primary change—adding end-to-end tests for mobile adaptation—using clear and specific phrasing that aligns with the pull request’s main objective.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@hu-qi
Copy link
Contributor

hu-qi commented Sep 29, 2025

@coderabbitai review

@coderabbitai
Copy link

coderabbitai bot commented Sep 29, 2025

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
package.json (2)

85-95: Commit the pnpm-lock.yaml update for the new devDependency

@playwright/test was added, but the corresponding pnpm-lock.yaml change is missing. CI installs with --frozen-lockfile, which refuses to proceed if the lockfile is out of sync with package.json, so every install now fails with ERR_PNPM_OUTDATED_LOCKFILE. Please rerun pnpm install and commit the updated lockfile along with this change. (pnpm.io)


35-55: Keep Playwright e2e out of the default npm test chain

By adding test:e2e while the existing script is run-s build test:**, npm test/pnpm test will now run the Playwright suite every time. That introduces a slow, browser-dependent workflow into pipelines that were previously unit/back-end only, which is already visible in the failing “BackEnd UnitTest” job. Please decouple the e2e script (e.g., call it explicitly or adjust the glob) so routine npm test runs aren’t blocked on Playwright. (medium.com)

🧹 Nitpick comments (3)
template/tinyvue/src/views/user/info/index.vue (1)

35-35: Avoid clipping the card shadow on wider screens.

Because .container-info now hides horizontal overflow, the 8px horizontal blur from .general-card’s box-shadow gets cropped on desktop, flattening the card edges. To keep the mobile scroll fix without sacrificing the shadow effect on larger breakpoints, limit the hidden overflow to mobile widths (e.g., via a max-width media query or a max-md:overflow-x-hidden utility) and leave desktop overflow unaffected.

 .container-info {
   display: flex;
   flex-direction: column; 
   justify-content: space-between;
   width: 100%;
   height: calc(100% - 60px);
   margin: 0 auto;
-  overflow-x: hidden;
 }
+
+@media (max-width: 768px) {
+  .container-info {
+    overflow-x: hidden;
+  }
+}
tests/e2e/mobile/modal.spec.ts (1)

13-13: Prefer resilient CSS locator over XPath

Using a bare XPath string here makes the selector harder to read and more brittle if the DOM structure changes. Since the modal already exposes a stable class, we can rely on Playwright’s CSS locator API and still target the first instance explicitly.

-  const modal = page.locator("(//div[@class='tiny-modal__box'])[1]");
+  const modal = page.locator('.tiny-modal__box').first();
tests/e2e/mobile/grid.spec.ts (1)

15-16: Avoid fixed sleeps in tests

page.waitForTimeout(300) can introduce unnecessary flakiness because it guesses how long the UI needs to settle. It’s safer to wait for the scroll position to change using Playwright’s polling helpers so the test only proceeds once the assertion is actually true.

-  await page.waitForTimeout(300)
-  const afterScrollLeft = await bodyWrapper.evaluate(el => el.scrollLeft)
+  const afterScrollLeft = await expect
+    .poll(() => bodyWrapper.evaluate(el => el.scrollLeft))
+    .toBeGreaterThan(initialScrollLeft)
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b806e4e and 67d7a93.

📒 Files selected for processing (13)
  • package.json (2 hunks)
  • playwright.config.ts (1 hunks)
  • template/tinyvue/src/components/navbar/index.vue (1 hunks)
  • template/tinyvue/src/hooks/responsive.ts (1 hunks)
  • template/tinyvue/src/views/Preview/index.vue (3 hunks)
  • template/tinyvue/src/views/board/home/components/regiontable.vue (3 hunks)
  • template/tinyvue/src/views/board/home/components/roundtable.vue (2 hunks)
  • template/tinyvue/src/views/locale/components/locale-table.vue (3 hunks)
  • template/tinyvue/src/views/user/info/index.vue (2 hunks)
  • tests/e2e/mobile/grid.spec.ts (1 hunks)
  • tests/e2e/mobile/modal.spec.ts (1 hunks)
  • tests/e2e/mobile/navbar.spec.ts (1 hunks)
  • tests/e2e/mobile/tree-menu.spec.ts (1 hunks)
🧰 Additional context used
🪛 GitHub Actions: BackEnd UnitTest
package.json

[error] 1-1: pnpm install failed: ERR_PNPM_OUTDATED_LOCKFILE. Frozen lockfile prevents install because lockfile is not up to date with package.json. Specifiers mismatch: 1 dependencies were removed: @playwright/test@^1.55.0.


[warning] 1-1: Resolutions field in package.json will not take effect when using a workspace root. Move resolutions to the workspace root.

@kagol
Copy link
Member

kagol commented Oct 10, 2025

@WangWant7 测试用例没通过,需要处理下
image

@WangWant7
Copy link
Contributor Author

@kagol 已修复CI/CD问题

- .env
environment:
DATABASE_HOST: mysql
REDIS_HOST: redis
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@WangWant7 为什么要加这个呢?
@GaoNeng-wWw 也帮忙看下这样加是否合适哈

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

docker启动服务的时候ip通常是不固定的,所以容器间通信更多通过的是容器名。如果同时使用 env_file 和 environment 属性,则由 environment 设置的环境变量优先。

"fix:tslint": "tslint --fix --project .",
"test": "run-s build test:**",
"test:unit": "run-s build test:lint test:unit:backend test:cov:backend",
"test:all": "run-s build test:**",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个可以不用改哈

Suggested change
"test:all": "run-s build test:**",
"test": "run-s build test:**",

@kagol kagol merged commit 4389d59 into opentiny:ospp-2025/mobile Oct 21, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants

Comments