phoneTapTargets: every IconButton in Message, RoomInput, RoomViewHeader carries a PhoneHit class
Some checks failed
Build pull request / Build pull request (pull_request) Has been cancelled
Some checks failed
Build pull request / Build pull request (pull_request) Has been cancelled
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
9565e62914
commit
162ad0995c
1 changed files with 30 additions and 0 deletions
|
|
@ -1,3 +1,4 @@
|
|||
import { readFileSync } from 'fs';
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import zlib from 'zlib';
|
||||
import { compile, processVanillaFile } from '@vanilla-extract/integration';
|
||||
|
|
@ -156,3 +157,32 @@ describe('phone icon-button hit areas', () => {
|
|||
expect(css).toMatch(/text-align: start;/);
|
||||
});
|
||||
});
|
||||
|
||||
describe('icon buttons in the room view', () => {
|
||||
// The opening tag of every <IconButton in a source file, read to its closing > outside any {} expression.
|
||||
const iconButtonTags = (src: string) => {
|
||||
const tags: string[] = [];
|
||||
for (let i = src.indexOf('<IconButton'); i !== -1; i = src.indexOf('<IconButton', i + 1)) {
|
||||
let depth = 0;
|
||||
let j = i;
|
||||
for (; j < src.length; j += 1) {
|
||||
if (src[j] === '{') depth += 1;
|
||||
else if (src[j] === '}') depth -= 1;
|
||||
else if (src[j] === '>' && depth === 0) break;
|
||||
}
|
||||
tags.push(src.slice(i, j + 1));
|
||||
}
|
||||
return tags;
|
||||
};
|
||||
|
||||
it.each([
|
||||
'features/room/message/Message.tsx',
|
||||
'features/room/RoomInput.tsx',
|
||||
'features/room/RoomViewHeader.tsx',
|
||||
])('%s: every IconButton carries a PhoneHit class', (file) => {
|
||||
const tags = iconButtonTags(readFileSync(`${process.cwd()}/src/app/${file}`, 'utf8'));
|
||||
expect(tags.length).toBeGreaterThan(0);
|
||||
const bare = tags.filter((t) => !/PhoneHit/.test(t));
|
||||
expect(bare).toEqual([]);
|
||||
});
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in a new issue