Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

N21-2134 bugfix missing users in migration wizard #5176

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion apps/server/src/shared/repo/mongo.patterns.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ export class MongoPatterns {
* Used to remove all non-language characters except numbers, whitespace or minus.
*/
static REGEX_MONGO_LANGUAGE_PATTERN_WHITELIST =
/[^\-_\w\d áàâäãåçéèêëíìîïñóòôöõúùûüýÿæœÁÀÂÄÃÅÇÉÈÊËÍÌÎÏÑÓÒÔÖÕÚÙÛÜÝŸÆŒ]/gi;
/[^\-_\w\d áàâäãåçéèêëíìîïñóòôöõúùûüýÿæœÁÀÂÄÃÅÇÉÈÊËÍÌÎÏÑÓÒÔÖÕÚÙÛÜÝŸÆŒß]/gi;
}
25 changes: 25 additions & 0 deletions apps/server/src/shared/repo/user/user.repo.integration.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,31 @@ describe('user repo', () => {
// id do not exist
await expect(repo.findForImportUser(school)).rejects.toThrowError();
});

describe('when the first or lastname of the user contains "ß"', () => {
describe('when the name filter query is exactly the first or lastname of the user', () => {
const setup = async () => {
const school = schoolEntityFactory.build();
const user = userFactory.build({ school, firstName: 'Martin', lastName: 'Beißner' });
await em.persistAndFlush([user]);
em.clear();

return {
school,
user,
};
};

it('should return the searched user', async () => {
const { school, user } = await setup();

const [result, count] = await repo.findForImportUser(school, { name: user.lastName });

expect(count).toEqual(1);
expect(result.map((u) => u.id)).toContain(user.id);
});
});
});
});

describe('findByEmail', () => {
Expand Down
22 changes: 21 additions & 1 deletion apps/server/src/shared/repo/user/user.scope.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,26 @@ describe('UserScope', () => {
expect(scope.query).toEqual({});
});
});

describe('when a name contains "ß"', () => {
const setup = () => {
const name = 'Beißner';

return {
name,
};
};

it('should return scope with added query where first or lastname is given without removing the "ß"', () => {
const { name } = setup();

scope.byName(name);

expect(scope.query).toEqual({
$or: [{ firstName: new RegExp(name, 'i') }, { lastName: new RegExp(name, 'i') }],
});
});
});
});

describe('withDeleted', () => {
Expand All @@ -173,7 +193,7 @@ describe('UserScope', () => {
it('should add a query that removes deleted users', () => {
scope.withDeleted(false);

expect(scope.query).toEqual({ deletedAt: { $exists: false } });
expect(scope.query).toEqual({ $or: [{ deletedAt: { $exists: false } }, { deletedAt: null }] });
});
});
});
Expand Down
2 changes: 1 addition & 1 deletion apps/server/src/shared/repo/user/user.scope.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export class UserScope extends Scope<User> {

withDeleted(deleted?: boolean): UserScope {
if (!deleted) {
this.addQuery({ deletedAt: { $exists: false } });
this.addQuery({ $or: [{ deletedAt: { $exists: false } }, { deletedAt: null }] });
}
return this;
}
Expand Down
Loading