修改注册功能问题
This commit is contained in:
@@ -13,6 +13,12 @@ function readPage(fileName) {
|
||||
}
|
||||
|
||||
function run() {
|
||||
const expectedFormIds = {
|
||||
'login.html': ['login-password-form', 'login-sms-form'],
|
||||
'register.html': ['register-form'],
|
||||
'forgot-password.html': ['password-reset-form']
|
||||
};
|
||||
|
||||
pages.forEach((fileName) => {
|
||||
const html = readPage(fileName);
|
||||
const formCaptchaBox = /<form[\s\S]*?data-captcha-box[\s\S]*?<\/form>/i.test(html);
|
||||
@@ -30,8 +36,25 @@ function run() {
|
||||
assert.strictEqual(hasCaptchaModalCss, false, `${fileName} 不应加载自定义验证码样式`);
|
||||
assert.notStrictEqual(layuiScriptIndex, -1, `${fileName} 应加载 layui.js 使用 layer.msg`);
|
||||
assert.ok(layuiScriptIndex < authScriptIndex, `${fileName} 应在 auth-pages.js 之前加载 layui.js`);
|
||||
assert.deepStrictEqual(
|
||||
Array.from(html.matchAll(/<form[^>]*id="([^"]+)"/g)).map((match) => match[1]),
|
||||
expectedFormIds[fileName],
|
||||
`${fileName} 应使用表单 id 作为 JS 挂载点`
|
||||
);
|
||||
assert.strictEqual(/data-auth-form=|data-captcha-scene=|data-success-url=|data-scene-code=|data-login-mode/.test(html), false, `${fileName} 不应把认证业务配置写在 HTML data 属性上`);
|
||||
assert.strictEqual(
|
||||
(html.match(/<input type="hidden" name="validToken" \/>/g) || []).length,
|
||||
expectedFormIds[fileName].length,
|
||||
`${fileName} 每个认证表单都应携带 validToken 隐藏字段`
|
||||
);
|
||||
});
|
||||
|
||||
assert.strictEqual(
|
||||
readPage('register.html').includes('id="register-form"'),
|
||||
true,
|
||||
'register.html 应使用 register-form 挂载注册逻辑'
|
||||
);
|
||||
|
||||
console.log('auth-page-structure tests passed');
|
||||
}
|
||||
|
||||
|
||||
@@ -51,13 +51,39 @@ function run() {
|
||||
});
|
||||
|
||||
assert.strictEqual(AuthPages.getCaptchaScene('login'), 'WEB_H5_LOGIN');
|
||||
assert.strictEqual(AuthPages.getCaptchaScene('sms-login'), 'WEB_H5_LOGIN');
|
||||
assert.strictEqual(AuthPages.getCaptchaScene('register'), 'WEB_H5_REGISTER');
|
||||
assert.strictEqual(AuthPages.getCaptchaScene('password-reset'), 'WEB_H5_FORGOT_PASSWORD');
|
||||
assert.strictEqual(AuthPages.getFormCaptchaScene({
|
||||
getAttribute(name) {
|
||||
return name === 'data-captcha-scene' ? 'WEB_H5_REGISTER' : '';
|
||||
}
|
||||
}, 'login'), 'WEB_H5_REGISTER');
|
||||
assert.strictEqual(AuthPages.getSuccessUrl('register'), 'login.html');
|
||||
assert.strictEqual(AuthPages.getSuccessUrl('password-reset'), 'login.html');
|
||||
assert.strictEqual(AuthPages.validateAuthValues('login', {
|
||||
phone: '',
|
||||
password: '123456'
|
||||
}), '请填写手机号');
|
||||
assert.strictEqual(AuthPages.validateAuthValues('login', {
|
||||
phone: '123',
|
||||
password: '123456'
|
||||
}), '请输入正确的手机号');
|
||||
assert.strictEqual(AuthPages.validateAuthValues('register', {
|
||||
phone: '13800000000',
|
||||
password: '12345'
|
||||
}), '密码至少需要 6 位');
|
||||
assert.strictEqual(AuthPages.validateAuthValues('sms-login', {
|
||||
phone: '13800000000',
|
||||
smsCode: '12'
|
||||
}), '请输入正确的短信验证码');
|
||||
assert.strictEqual(AuthPages.validateAuthValues('password-reset', {
|
||||
phone: '13800000000',
|
||||
smsCode: '123456',
|
||||
newPassword: 'abcdef',
|
||||
confirmPassword: 'abcdeg'
|
||||
}), '两次输入的新密码不一致');
|
||||
assert.strictEqual(AuthPages.validateAuthValues('password-reset', {
|
||||
phone: '13800000000',
|
||||
smsCode: '123456',
|
||||
newPassword: 'abcdef',
|
||||
confirmPassword: 'abcdef'
|
||||
}), '');
|
||||
|
||||
console.log('auth-pages tests passed');
|
||||
}
|
||||
|
||||
@@ -53,7 +53,17 @@ function run() {
|
||||
assert.deepStrictEqual(CaptchaPages.buildVerifyBody({
|
||||
id: 'tianai-1',
|
||||
data: {
|
||||
trackList: [{ x: 10, y: 2 }]
|
||||
bgImageWidth: 340,
|
||||
bgImageHeight: 180,
|
||||
templateImageWidth: 50,
|
||||
templateImageHeight: 50,
|
||||
startTime: 1720000000000,
|
||||
stopTime: 1720000001500,
|
||||
trackList: [
|
||||
{ x: 0, y: 0, t: 0, type: 'down' },
|
||||
{ x: 120, y: 0, t: 650, type: 'move' },
|
||||
{ x: 120, y: 0, t: 700, type: 'up' }
|
||||
]
|
||||
}
|
||||
}, {
|
||||
sceneCode: 'WEB_H5_LOGIN',
|
||||
@@ -70,9 +80,20 @@ function run() {
|
||||
providerCode: 'tianai',
|
||||
captchaType: 'SLIDER',
|
||||
payload: {
|
||||
id: 'tianai-1',
|
||||
data: {
|
||||
trackList: [{ x: 10, y: 2 }]
|
||||
track: {
|
||||
bgImageWidth: 340,
|
||||
bgImageHeight: 180,
|
||||
templateImageWidth: 50,
|
||||
templateImageHeight: 50,
|
||||
startTime: 1720000000000,
|
||||
stopTime: 1720000001500,
|
||||
left: 120,
|
||||
top: 0,
|
||||
trackList: [
|
||||
{ x: 0, y: 0, t: 0, type: 'down' },
|
||||
{ x: 120, y: 0, t: 650, type: 'move' },
|
||||
{ x: 120, y: 0, t: 700, type: 'up' }
|
||||
]
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user