n8n/packages/design-system/src/utils/testUtils.ts
Milorad FIlipović ecd287564d
feat(editor): Update element-plus to 2.4.3 (no-changelog) (#10281)
Co-authored-by: कारतोफ्फेलस्क्रिप्ट™ <aditya@netroy.in>
2024-08-21 10:42:08 +02:00

19 lines
848 B
TypeScript

const DYNAMIC_ATTRIBUTES = ['aria-controls'];
/**
* Deletes dynamic attributes from the container children so snapshots can be tested.
*
* Background:
* Vue test utils use server rendering to render components (https://v1.test-utils.vuejs.org/api/render.html#render).
* Element UI in SSR mode adds dynamic attributes to the rendered HTML each time the test is run (https://element-plus.org/en-US/guide/ssr#provide-an-id).
*
* NOTE: Make sure to manually remove same attributes from the expected snapshot.
*/
// TODO: Find a way to inject static value for dynamic attributes in tests
export function removeDynamicAttributes(container: Element): void {
DYNAMIC_ATTRIBUTES.forEach((attribute) => {
const elements = container.querySelectorAll(`[${attribute}]`);
elements.forEach((element) => element.removeAttribute(attribute));
});
}