test(web): a tag stored with spaces around its name is still the tag of the name (#204)

POST /api/tags stores a name as it receives it. createTag compares the
stored names trimmed too: without that, every test stayed green when the
trim of the comparison key was removed.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
le king fu 2026-11-15 13:39:52 -05:00
commit 1f257c71c1

View file

@ -704,6 +704,8 @@ describe('createTag', () => {
it('returns the live tag of the account that has the name, whatever the letter case and the spaces around it, and writes nothing', async () => {
const A = await newAccount();
const id = await newTag(A.userId, { name: 'Courses', color: '#C17767' });
// A name stored with spaces around it: POST /api/tags stores what it receives.
const spaced = await newTag(A.userId, { name: ' Maison ' });
const before = await everything();
for (const name of ['Courses', 'courses', 'COURSES', ' cOuRsEs ', '\tcourses\n']) {
@ -712,13 +714,14 @@ describe('createTag', () => {
changed: false, tag: { id, name: 'Courses', color: '#C17767', updatedAt: new Date(SEEDED) },
});
}
expect(await makeTag(A.userId, { name: 'maison' })).toMatchObject({ changed: false, tag: { id: spaced, name: ' Maison ' } });
expect(await everything()).toEqual(before);
// A name that only starts, ends or reads like it is another name.
for (const name of ['Course', 'Courses bio', 'Mes courses', 'Cour ses']) {
expect(await makeTag(A.userId, { name }), name).toMatchObject({ changed: true, tag: { name } });
}
expect(await tagNames(A.userId)).toHaveLength(5);
expect(await tagNames(A.userId)).toHaveLength(6);
});
it('creates one tag for the same name asked twice, and a second call finds the first', async () => {