Skip to content

Commit

Permalink
Chat: Fix avatar positioning
Browse files Browse the repository at this point in the history
  • Loading branch information
marker-dao authored Sep 11, 2024
1 parent bcdcdbb commit fb6f86e
Show file tree
Hide file tree
Showing 12 changed files with 47 additions and 3 deletions.
47 changes: 45 additions & 2 deletions e2e/testcafe-devextreme/tests/chat/common.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
import { Selector } from 'testcafe';
import { createScreenshotsComparer } from 'devextreme-screenshot-comparer';
import url from '../../helpers/getPageUrl';
import { createWidget } from '../../helpers/createWidget';
import { testScreenshot } from '../../helpers/themeUtils';
import { appendElementTo } from '../../helpers/domUtils';
import { appendElementTo, setStyleAttribute } from '../../helpers/domUtils';

const CHAT_AVATAR_SELECTOR = '.dx-chat-message-avatar';

fixture.disablePageReloads`Chat`
.page(url(__dirname, '../container.html'));

test('Chat: line breaks', async (t) => {
const { takeScreenshot, compareResults } = createScreenshotsComparer(t);
await testScreenshot(t, takeScreenshot, 'Chat message bubble line breaks.png', { element: '#container' });
await testScreenshot(t, takeScreenshot, 'Chat message bubble line breaks.png', { element: '#chat' });

await t
.expect(compareResults.isValid())
Expand All @@ -27,3 +30,43 @@ test('Chat: line breaks', async (t) => {
],
}, '#chat');
});

test('Chat: avatar rendering', async (t) => {
const { takeScreenshot, compareResults } = createScreenshotsComparer(t);

await testScreenshot(t, takeScreenshot, 'Avatar has correct position.png', { element: '#chat' });

await setStyleAttribute(Selector(CHAT_AVATAR_SELECTOR), 'width: 64px; height: 64px');

await testScreenshot(t, takeScreenshot, 'Avatar sizes do not affect indentation between bubbles.png', { element: '#chat' });

await t
.expect(compareResults.isValid())
.ok(compareResults.errorMessages());
}).before(async () => {
await appendElementTo('#container', 'div', 'chat');

const author = {
id: 1,
name: 'First User Name',
};
const timestamp = new Date(1721747399083);
const text = '0.392722124265449';

return createWidget('dxChat', {
height: 500,
width: 400,
items: [
{
timestamp,
text,
author,
},
{
timestamp,
text,
author,
},
],
}, '#chat');
});
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.
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.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
.dx-chat-message-avatar {
grid-row: span 3;
grid-row: 2 / auto;
display: flex;
align-items: center;
justify-content: center;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

.dx-chat-message-group-alignment-start {
.dx-chat-message-bubble-container {
grid-column: 2;
align-items: flex-start;
}

Expand Down

0 comments on commit fb6f86e

Please sign in to comment.