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

test(pie-link): DSW-2229 updated visual tests to split by size #1952

Merged
merged 7 commits into from
Oct 1, 2024
52 changes: 32 additions & 20 deletions packages/components/pie-link/test/visual/pie-link.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const props: PropObject<LinkProps> = {
isBold: [true, false],
isStandalone: [true, false],
hasVisited: [true, false],
iconPlacement: [undefined, ...iconPlacements],
iconPlacement: iconPlacements,
};

const renderTestPieLink = (propVals: WebComponentPropValues) => `<pie-link tag="${propVals.tag}" variant="${propVals.variant}" size="${propVals.size}" underline="${propVals.underline}" iconPlacement="${propVals.iconPlacement}" href="${propVals.href}" ${propVals.isBold ? 'isBold' : ''} ${propVals.hasVisited ? 'hasVisited' : ''} ${propVals.isStandalone ? 'isStandalone' : ''}>${propVals.iconPlacement ? '<icon-heart-filled slot="icon"></icon-heart-filled>' : ''} Link</pie-link>`;
Expand All @@ -48,24 +48,36 @@ test.beforeEach(async ({ mount }, testInfo) => {
await iconComponent.unmount();
});

componentVariants.forEach((variant) => test(`should render all prop variations for Variant: ${variant}`, async ({ page, mount }) => {
for (const combo of componentPropsMatrixByVariant[variant]) {
const testComponent = createTestWebComponent(combo, renderTestPieLink);
const propKeyValues = `
tag: ${testComponent.propValues.tag},
size: ${testComponent.propValues.size},
iconPlacement: ${testComponent.propValues.iconPlacement},
isBold: ${testComponent.propValues.isBold},
isStandalone: ${testComponent.propValues.isStandalone},
href: ${testComponent.propValues.href}`;
componentVariants.forEach((variant) => {
const componentPropsMatrixBySize = splitCombinationsByPropertyValue(componentPropsMatrixByVariant[variant], 'size');
const componentSizes: string[] = Object.keys(componentPropsMatrixBySize);

await mount(WebComponentTestWrapper, {
props: { propKeyValues, darkMode: variant === 'inverse' },
slots: {
component: testComponent.renderedString.trim(),
},
});
}
componentSizes.forEach((size) => {
test(`should render all prop variations for Variant: ${variant} and Size: ${size}`, async ({ page, mount }) => {
const combos = componentPropsMatrixBySize[size];

for (const combo of combos) {
const testComponent = createTestWebComponent(combo, renderTestPieLink);
const propKeyValues = `
tag: ${testComponent.propValues.tag},
size: ${testComponent.propValues.size},
iconPlacement: ${testComponent.propValues.iconPlacement},
isBold: ${testComponent.propValues.isBold},
isStandalone: ${testComponent.propValues.isStandalone},
href: ${testComponent.propValues.href}`;

await mount(WebComponentTestWrapper, {
props: { propKeyValues, darkMode: variant === 'inverse' },
slots: {
component: testComponent.renderedString.trim(),
},
});
}

await percySnapshot(page, `PIE Link - Variant: ${variant}`, percyWidths);
}));
await page.waitForLoadState('domcontentloaded');

const snapshotName = `PIE Link - Variant: ${variant} - Size: ${size}`;
await percySnapshot(page, snapshotName, percyWidths);
});
});
});
Loading