mirror of
https://github.com/logto-io/logto.git
synced 2025-01-20 21:32:31 -05:00
chore: fix tests and add changeset
This commit is contained in:
parent
fd0b1d0717
commit
c03844f12e
5 changed files with 22 additions and 20 deletions
|
@ -67,7 +67,7 @@ describe('user query', () => {
|
|||
const expectSql = sql`
|
||||
select ${sql.join(Object.values(fields), sql`,`)}
|
||||
from ${table}
|
||||
where ${fields.primaryEmail}=$1
|
||||
where lower(${fields.primaryEmail})=lower($1)
|
||||
`;
|
||||
|
||||
mockQuery.mockImplementationOnce(async (sql, values) => {
|
||||
|
@ -179,7 +179,7 @@ describe('user query', () => {
|
|||
SELECT EXISTS(
|
||||
select ${fields.primaryEmail}
|
||||
from ${table}
|
||||
where ${fields.primaryEmail}=$1
|
||||
where lower(${fields.primaryEmail})=lower($1)
|
||||
)
|
||||
`;
|
||||
|
||||
|
|
|
@ -117,8 +117,11 @@ describe('adminUserRoutes', () => {
|
|||
const username = 'MJAtLogto';
|
||||
const password = 'PASSWORD';
|
||||
const name = 'Michael';
|
||||
const primaryEmail = 'foo@logto.io';
|
||||
|
||||
const response = await userRequest.post('/users').send({ username, password, name });
|
||||
const response = await userRequest
|
||||
.post('/users')
|
||||
.send({ primaryEmail, username, password, name });
|
||||
expect(response.status).toEqual(200);
|
||||
expect(response.body).toEqual({
|
||||
...mockUserResponse,
|
||||
|
@ -133,21 +136,6 @@ describe('adminUserRoutes', () => {
|
|||
const password = 'PASSWORD';
|
||||
const name = 'Michael';
|
||||
|
||||
// Missing input
|
||||
await expect(userRequest.post('/users').send({})).resolves.toHaveProperty('status', 400);
|
||||
await expect(userRequest.post('/users').send({ username, password })).resolves.toHaveProperty(
|
||||
'status',
|
||||
400
|
||||
);
|
||||
await expect(userRequest.post('/users').send({ username, name })).resolves.toHaveProperty(
|
||||
'status',
|
||||
400
|
||||
);
|
||||
await expect(userRequest.post('/users').send({ password, name })).resolves.toHaveProperty(
|
||||
'status',
|
||||
400
|
||||
);
|
||||
|
||||
// Invalid input format
|
||||
await expect(
|
||||
userRequest.post('/users').send({ username, password: 'abc', name })
|
||||
|
|
|
@ -125,7 +125,7 @@ export default function adminUserRoutes<T extends AuthedRouter>(router: T) {
|
|||
primaryEmail: string().regex(emailRegEx).optional(),
|
||||
username: string().regex(usernameRegEx).optional(),
|
||||
password: string().regex(passwordRegEx),
|
||||
name: string(),
|
||||
name: string().optional(),
|
||||
}),
|
||||
}),
|
||||
async (ctx, next) => {
|
||||
|
|
|
@ -44,7 +44,7 @@ describe('admin console dashboard', () => {
|
|||
const username = generateUsername();
|
||||
await createUserByAdmin(username, password);
|
||||
|
||||
await signIn(username, password);
|
||||
await signIn({ username, password });
|
||||
|
||||
const newActiveUserStatistics = await getActiveUsersData();
|
||||
|
||||
|
|
|
@ -37,6 +37,18 @@ describe('username and password flow', () => {
|
|||
const username = generateUsername();
|
||||
const password = generatePassword();
|
||||
|
||||
beforeAll(async () => {
|
||||
await setSignUpIdentifier(SignUpIdentifier.Username, true);
|
||||
await setSignInMethod([
|
||||
{
|
||||
identifier: SignInIdentifier.Username,
|
||||
password: true,
|
||||
verificationCode: false,
|
||||
isPasswordPrimary: false,
|
||||
},
|
||||
]);
|
||||
});
|
||||
|
||||
it('register and sign in with username & password', async () => {
|
||||
await expect(registerNewUser(username, password)).resolves.not.toThrow();
|
||||
await expect(signIn({ username, password })).resolves.not.toThrow();
|
||||
|
@ -51,6 +63,8 @@ describe('email and password flow', () => {
|
|||
assert(localPart && domain, new Error('Email address local part or domain is empty'));
|
||||
|
||||
beforeAll(async () => {
|
||||
await setUpConnector(mockEmailConnectorId, mockEmailConnectorConfig);
|
||||
await setSignUpIdentifier(SignUpIdentifier.Email, true);
|
||||
await setSignInMethod([
|
||||
{
|
||||
identifier: SignInIdentifier.Email,
|
||||
|
|
Loading…
Add table
Reference in a new issue