Skip to content

Commit

Permalink
Merge branch 'develop' into feature/peking
Browse files Browse the repository at this point in the history
  • Loading branch information
skique committed Sep 12, 2024
2 parents b484b78 + 43001a1 commit 238f2a8
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 5 deletions.
30 changes: 29 additions & 1 deletion server/src/modules/auth/__test/auth.controller.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,10 @@ describe('AuthController', () => {
};

await expect(controller.register(mockUserInfo)).rejects.toThrow(
new HttpException('密码无效', EXCEPTION_CODE.PASSWORD_INVALID),
new HttpException(
'密码只能输入数字、字母、特殊字符',
EXCEPTION_CODE.PASSWORD_INVALID,
),
);
});
});
Expand Down Expand Up @@ -217,4 +220,29 @@ describe('AuthController', () => {
expect(typeof result.data.img).toBe('string');
});
});

describe('password strength', () => {
it('it should return strong', async () => {
await expect(
controller.getPasswordStrength('abcd&1234'),
).resolves.toEqual({
code: 200,
data: 'Strong',
});
});

it('it should return medium', async () => {
await expect(controller.getPasswordStrength('abc123')).resolves.toEqual({
code: 200,
data: 'Medium',
});
});

it('it should return weak', async () => {
await expect(controller.getPasswordStrength('123456')).resolves.toEqual({
code: 200,
data: 'Weak',
});
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -245,15 +245,20 @@ describe('WorkspaceController', () => {
const req = { user: { _id: new ObjectId() } };

const workspaceId = new ObjectId();
const memberList = [{ workspaceId, userId: new ObjectId() }];
const userId = new ObjectId();
const memberList = [{ workspaceId, userId: userId }];
const workspaces = [{ _id: workspaceId, name: 'Test Workspace' }];
const userList = [{ _id: userId, username: 'Test User' }];

jest
.spyOn(workspaceService, 'findAllByUserId')
.mockResolvedValue(workspaces as Array<Workspace>);
jest
.spyOn(workspaceMemberService, 'batchSearchByWorkspace')
.mockResolvedValue(memberList as unknown as Array<WorkspaceMember>);
jest
.spyOn(userService, 'getUserListByIds')
.mockResolvedValue(userList as User[]);

const result = await controller.getWorkspaceAndMember(req);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@ export default defineComponent({

watch(status, (v) => {
if (v === 'edit') {
document.addEventListener('click', handleDocumentClick)
document.addEventListener('click', handleDocumentClick, {capture: true})
} else {
document.removeEventListener('click', handleDocumentClick)
document.removeEventListener('click', handleDocumentClick, {capture: true})
}
})

Expand Down Expand Up @@ -96,7 +96,8 @@ export default defineComponent({

function handleDocumentClick(e) {
const richEditorDOM = moduleTitleRef.value.querySelector('.rich-editor')
const isClickRichEditor = richEditorDOM?.contains(e.target)
const isUploadImage = e.target.type === 'file' && e.target.tagName.toLowerCase() === 'input' // 富文本上传图片点击事件触发到input file 元素上了, 该元素插入到body了
const isClickRichEditor = richEditorDOM?.contains(e.target) || isUploadImage

if (status.value === 'edit' && richEditorDOM && !isClickRichEditor) {
// 监听编辑状态时点击非编辑区域
Expand Down
1 change: 1 addition & 0 deletions web/src/render/components/QuestionWrapper.vue
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ const props = defineProps({
return {}
}
}
}
})
const emit = defineEmits(['change'])
const questionStore = useQuestionStore()
Expand Down

0 comments on commit 238f2a8

Please sign in to comment.