Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions e2e/screenshots.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { test, expect } from '@playwright/experimental-ct-react17';
import { setTheme } from './helpers/playwright';

test.beforeEach(({ page }) => {
setTheme(page, 'light');
test.beforeEach(async ({ page }) => {
await setTheme(page, 'light');
});

export { test, expect };
Comment thread
Bracciata marked this conversation as resolved.
Outdated
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added e2e/screenshots/dark--text-ellipsis-tooltip.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added e2e/screenshots/dark--text-ellipsis.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added e2e/screenshots/text-ellipsis-hideTooltip-.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added e2e/screenshots/text-ellipsis-maxLines-2-.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added e2e/screenshots/text-ellipsis-no-overflow.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added e2e/screenshots/text-ellipsis-tooltip.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added e2e/screenshots/text-ellipsis.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
109 changes: 109 additions & 0 deletions packages/react/src/components/TextEllipsis/screenshots.e2e.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
import React from 'react';
import { test, expect } from '../../../../../e2e/screenshots';
import { setTheme } from '../../../../../e2e/helpers/playwright';
import { TextEllipsis } from '../../../';

const overflowText =
'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.';

test('should have screenshot for TextEllipsis', async ({ mount, page }) => {
const component = await mount(
<div style={{ width: '200px' }}>
<TextEllipsis>{overflowText}</TextEllipsis>
</div>
);

await expect(component).toHaveScreenshot('text-ellipsis');
await setTheme(page, 'dark');
await expect(component).toHaveScreenshot('dark--text-ellipsis');
});
Comment thread
Bracciata marked this conversation as resolved.

test('should have screenshot for TextEllipsis tooltip on hover', async ({
mount,
page
}) => {
await mount(
<div style={{ width: '200px' }}>
<TextEllipsis>{overflowText}</TextEllipsis>
</div>
);

const ellipsis = page.getByRole('button');
await ellipsis.waitFor();
await ellipsis.hover();
await expect(page.locator('.Tooltip')).toBeVisible();

await expect(page).toHaveScreenshot('text-ellipsis-tooltip');
await setTheme(page, 'dark');
await expect(page).toHaveScreenshot('dark--text-ellipsis-tooltip');
});

test('should have screenshot for TextEllipsis[maxLines=2]', async ({
mount,
page
}) => {
const component = await mount(
<div style={{ width: '200px' }}>
<TextEllipsis maxLines={2}>{overflowText}</TextEllipsis>
</div>
);

await expect(component).toHaveScreenshot('text-ellipsis[maxLines=2]');
await setTheme(page, 'dark');
await expect(component).toHaveScreenshot('dark--text-ellipsis[maxLines=2]');
});

test('should have screenshot for TextEllipsis[hideTooltip]', async ({
mount,
page
}) => {
await mount(
<div style={{ width: '200px' }}>
<TextEllipsis hideTooltip>{overflowText}</TextEllipsis>
</div>
);

const ellipsis = page.locator('.TextEllipsis');
await ellipsis.hover();
await expect(page.locator('.Tooltip')).toHaveCount(0);

await expect(page).toHaveScreenshot('text-ellipsis[hideTooltip]');
await setTheme(page, 'dark');
await expect(page).toHaveScreenshot('dark--text-ellipsis[hideTooltip]');
});

test('should have screenshot for TextEllipsis[hideTooltip][maxLines=2]', async ({
Comment thread
Bracciata marked this conversation as resolved.
mount,
page
}) => {
const component = await mount(
<div style={{ width: '200px' }}>
<TextEllipsis hideTooltip maxLines={2}>
{overflowText}
</TextEllipsis>
</div>
);

await expect(component).toHaveScreenshot(
'text-ellipsis[hideTooltip][maxLines=2]'
);
await setTheme(page, 'dark');
await expect(component).toHaveScreenshot(
'dark--text-ellipsis[hideTooltip][maxLines=2]'
);
});

test('should have screenshot for TextEllipsis without overflow', async ({
mount,
page
}) => {
const component = await mount(
<div style={{ width: '200px' }}>
<TextEllipsis>Short text</TextEllipsis>
</div>
);

await expect(component).toHaveScreenshot('text-ellipsis-no-overflow');
await setTheme(page, 'dark');
await expect(component).toHaveScreenshot('dark--text-ellipsis-no-overflow');
});
Comment thread
Bracciata marked this conversation as resolved.
Loading