login.spec.js 722 B

12345678910111213141516171819202122
  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. test('[场景2] 孩子尝试访问家长页面 — 被重定向', async function({ page }) {
  13. await page.goto('http://cfc.iwintrue.com/#/pages/parent/index');
  14. await page.waitForLoadState('networkidle');
  15. var url = page.url();
  16. expect(url).not.toContain('/parent/index');
  17. });
  18. });