login.spec.js 886 B

123456789101112131415161718192021222324
  1. const { test, expect } = require('@playwright/test');
  2. const { loginAs } = require('../../helpers/auth');
  3. test.describe('【孩子】登录', function() {
  4. var auth;
  5. test.beforeAll(async function({ browser }) {
  6. auth = await loginAs(browser, 'child');
  7. });
  8. test('[场景1] 孩子角色登录 — 获得合法token', async function() {
  9. expect(auth.token).toBeTruthy();
  10. expect(auth.role).toBe('child');
  11. });
  12. // TODO: SPA前端缺少路由守卫,孩子可以访问家长页面URL。
  13. // 需要在前端路由层实现角色权限判断后才能启用此测试。
  14. test.skip('[场景2] 孩子尝试访问家长页面 — 被重定向', async function({ page }) {
  15. await page.goto('http://cfc.iwintrue.com/#/pages/parent/index');
  16. await page.waitForLoadState('networkidle');
  17. var url = page.url();
  18. expect(url).not.toContain('/parent/index');
  19. });
  20. });