test(editor): remove jsx snapshot (#9463)

This commit is contained in:
Saul-Mirone
2024-12-31 10:27:12 +00:00
parent 6c33eaace0
commit 36c1b103df
57 changed files with 2743 additions and 1656 deletions
@@ -21,6 +21,8 @@ const fieldChecker: Record<string, (value: any) => boolean> = {
},
};
const skipFields = new Set(['_lastXYWH']);
const snapshotTest = async (snapshotUrl: string, elementsCount: number) => {
const pageService = window.editor.host!.std.getService('affine:page');
if (!pageService) {
@@ -66,17 +68,22 @@ const snapshotTest = async (snapshotUrl: string, elementsCount: number) => {
return;
}
if (skipFields.has(field)) {
return;
}
if (fieldChecker[typeField] || fieldChecker[field]) {
const checker = fieldChecker[typeField] || fieldChecker[field];
expect(checker(value)).toBe(true);
} else {
expect(
value,
`type: ${element.type} field: "${field}"`
).not.toBeUndefined();
expect(value, `type: ${element.type} field: "${field}"`).not.toBeNull();
expect(value, `type: ${element.type} field: "${field}"`).not.toBeNaN();
return;
}
expect(
value,
`type: ${element.type} field: "${field}"`
).not.toBeUndefined();
expect(value, `type: ${element.type} field: "${field}"`).not.toBeNull();
expect(value, `type: ${element.type} field: "${field}"`).not.toBeNaN();
}
});
};
@@ -89,13 +96,11 @@ beforeEach(async () => {
const xywhPattern = /\[(\s*-?\d+(\.\d+)?\s*,){3}(\s*-?\d+(\.\d+)?\s*)\]/;
// FIXME: snapshot tests
test.skip('snapshot 1 importing', async () => {
test('snapshot 1 importing', async () => {
await snapshotTest('https://test.affineassets.com/test-snapshot-1.zip', 25);
});
// FIXME: snapshot tests
test.skip('snapshot 2 importing', async () => {
test('snapshot 2 importing', async () => {
await snapshotTest(
'https://test.affineassets.com/test-snapshot-2%20(onboarding).zip',
174