Skip to content

Commit

Permalink
refactor: update data-testid attributes for consistency and improve c…
Browse files Browse the repository at this point in the history
…ode readability
  • Loading branch information
danny-avila committed Jan 5, 2025
1 parent 91b4a90 commit 43a9301
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 8 deletions.
4 changes: 2 additions & 2 deletions client/src/components/Chat/Menus/HeaderNewChat.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ export default function HeaderNewChat() {
return (
<button
data-testid="wide-header-new-chat-button"
aria-label={localize("com_ui_new_chat")}
aria-label={localize('com_ui_new_chat')}
type="button"
className="btn btn-neutral btn-small border-token-border-medium relative ml-2 flex hidden h-9 w-9 items-center justify-center whitespace-nowrap rounded-lg rounded-lg border focus:border-black-500 dark:focus:border-white-500 md:flex"
className="btn btn-neutral btn-small border-token-border-medium focus:border-black-500 dark:focus:border-white-500 relative ml-2 flex h-9 w-9 items-center justify-center whitespace-nowrap rounded-lg border md:flex"
onClick={() => newConversation()}
>
<div className="flex w-full items-center justify-center gap-2">
Expand Down
5 changes: 2 additions & 3 deletions client/src/components/Chat/Messages/MessageIcon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ const MessageIcon = memo(
const assistantAvatar = useMemo(() => assistant?.metadata?.avatar ?? '', [assistant]);
const agentName = useMemo(() => props.agent?.name ?? '', [props.agent]);
const agentAvatar = useMemo(() => props.agent?.avatar?.filepath ?? '', [props.agent]);
const isCreatedByUser = useMemo(() => iconData?.isCreatedByUser ?? false, [iconData]);

let avatarURL = '';

Expand All @@ -39,7 +38,7 @@ const MessageIcon = memo(
[endpointsConfig, endpoint],
);

if (isCreatedByUser !== true && iconURL != null && iconURL.includes('http')) {
if (iconData?.isCreatedByUser !== true && iconURL != null && iconURL.includes('http')) {
return (
<ConvoIconURL
iconURL={iconURL}
Expand All @@ -56,7 +55,7 @@ const MessageIcon = memo(

return (
<Icon
isCreatedByUser={isCreatedByUser}
isCreatedByUser={iconData?.isCreatedByUser ?? false}
endpoint={endpoint}
iconURL={avatarURL || endpointIconURL}
model={iconData?.model}
Expand Down
2 changes: 1 addition & 1 deletion client/src/components/Nav/NewChat.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ export default function NewChat({
<a
href="/"
tabIndex={0}
data-testid="nav-new-chat"
data-testid="nav-new-chat-button"
onClick={clickHandler}
className={cn(
'group flex h-10 items-center gap-2 rounded-lg px-2 font-medium transition-colors duration-200 hover:bg-surface-hover',
Expand Down
4 changes: 2 additions & 2 deletions e2e/specs/messages.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ test.describe('Messaging suite', () => {
expect(currentUrl).toBe(initialUrl);

//cleanup the conversation
await page.getByTestId('new-chat-button').click();
await page.getByTestId('nav-new-chat-button').click();
expect(page.url()).toBe(initialUrl);

// Click on the first conversation
Expand Down Expand Up @@ -158,7 +158,7 @@ test.describe('Messaging suite', () => {
const currentUrl = page.url();
const conversationId = currentUrl.split(basePath).pop() ?? '';
expect(isUUID(conversationId)).toBeTruthy();
await page.getByTestId('new-chat-button').click();
await page.getByTestId('nav-new-chat-button').click();
expect(page.url()).toBe(initialUrl);
});
});

0 comments on commit 43a9301

Please sign in to comment.