Git Product home page Git Product logo

react-test's Introduction

Mục tiêu của bài test

  1. Sử dụng được react-router-dom để navigate các trang với nhau
  2. Kết hợp được react-router-dom và phương thức xác thực người dùng thông qua trang đăng nhập
  3. React code-splitting kết hợp với react-router-dom
  4. Dynamic route config
  5. Truyền tham số trên url

Lưu ý

  1. Khi người dùng đăng nhập thành công, sẽ lưu giá trị của token (tùy ý với độ dài lớn hơn 0) tại localStorage với tên là token.
  2. Sử dụng file config route và component (vì trong thực tế không thể config bằng tay)
  3. Nếu chạy test bị lỗi có thể xem lại video test bằng cách click vào phím phía dưới

    Thao khảo lỗi

  4. Tham khảo trang bài giải mẫu tại đây

Test case

  1. Người dùng truy cập đến /dashboard. Vì chưa đăng nhập, nên người dùng được chuyển về path /login
  2. Nếu người dùng không có token thì người dùng sẽ được chuyển đến route đăng nhập /login
  3. Khi người dùng đang ở trang đăng nhập /login và nhập mật khẩu sai vào input (với selector là input[data-test=login__pwd]) và nút submit (với selector là button[data-test=login__submit]) thì sẽ không được chuyển hướng tới /dashboard, đồng thời input nhập mật khẩu cũng sẽ được reset về giá trị rỗng.
  4. Ngược lại, user nhập mật khẩu đúng sẽ được chuyển về /dashboard, tương tự với selector ở case 3, khi người dùng nhập mật khẩu là 123 thì người dùng sẽ được chuyển hướng về /dashboard.
  5. Người dùng đã đăng nhập thành công sẽ không thể truy cập route /login, thay vào đó sẽ được chuyển hướng về /dashboard.
  6. Người dùng sau khi đăng nhập thành công có thể refresh trình duyệt và khi truy cập tới route mặc định / và tự động được chuyển tới /dashboard
  7. Người dùng chuyển tới các route qua lại sẽ không reload lại trang (chỉ render component khác chứ không sử dụng location api của window object) (là 1 thuộc tính của SPA)
  8. Người dùng khi chuyển hướng tới protected route /functions thì hiển thị nội dung text: Functions page
  9. Người dùng khi chuyển hướng tới protected route /functions/foo thì sẽ hiển thì nội dung text: Function Foo
  10. Người dùng khi chuyển hướng đến protected route /setting thì không hiển thị section (truyền được URL query). Ví dụ /setting?section=general thì sẽ hiển thị nội dung: Setting page - Section: general
  11. User bấm đăng xuất với selector button[data-test=logout__btn] sẽ trở về trang đăng nhập.
  12. User khi truy cập tới một route không được định nghĩa trong file config sẽ hiển thị Page not found với selector [data-test=404]
  13. Ứng dụng được implement code-splitting

Success Example

Thao khảo lỗi

react-test's People

Contributors

vanthaodhdt avatar

Stargazers

 avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.