Skip to content

Commit

Permalink
feat(chat-e2e): fixed flaky model image behavior (#2959)
Browse files Browse the repository at this point in the history
  • Loading branch information
irinakartun authored Jan 22, 2025
1 parent e88d2a9 commit 6bfc81b
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 16 deletions.
4 changes: 2 additions & 2 deletions apps/chat-e2e/src/tests/chatHeader.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ dialTest(
for (const addonId of addonIds) {
const expectedAddon = ModelsUtil.getAddon(addonId)!;
const actualAddon = headerAddonIcons.find(
(a) => a.entityName === expectedAddon.name,
(a) => a.entityId === expectedAddon.id,
)!;
const expectedAddonIcon =
iconApiHelper.getEntityIcon(expectedAddon);
Expand Down Expand Up @@ -148,7 +148,7 @@ dialTest(
for (const addonId of addonIds) {
const expectedAddon = ModelsUtil.getAddon(addonId)!;
const actualAddonInfoIcon = actualAddonsInfoIcons.find(
(a) => a.entityName === expectedAddon.name,
(a) => a.entityId === expectedAddon.id,
)!;
const expectedAddonIcon = iconApiHelper.getEntityIcon(expectedAddon);
await conversationInfoTooltipAssertion.assertEntityIcon(
Expand Down
4 changes: 2 additions & 2 deletions apps/chat-e2e/src/tests/compareMode.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -199,8 +199,8 @@ dialTest(
.toBe(expectedModels.length);

for (const expectedModel of expectedModels) {
const actualOptionIcon = compareOptionsIcons.find((o) =>
o.entityName.includes(expectedModel.name),
const actualOptionIcon = compareOptionsIcons.find(
(o) => o.entityId === expectedModel.id,
)!;
const expectedModelIcon = iconApiHelper.getEntityIcon(expectedModel);

Expand Down
6 changes: 3 additions & 3 deletions apps/chat-e2e/src/tests/defaultModelSettings.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ dialTest(
for (const recentEntityId of recentModelIds) {
const entity = ModelsUtil.getOpenAIEntity(recentEntityId)!;
const actualRecentEntity = recentAgentsIcons.find(
(e) => e.entityName === entity.name,
(e) => e.entityId === entity.id,
)!;
const expectedEntityIcon = iconApiHelper.getEntityIcon(entity);
await baseAssertion.assertEntityIcon(
Expand Down Expand Up @@ -161,8 +161,8 @@ dialTest(

for (const addon of recentAddonIds) {
const addonEntity = ModelsUtil.getAddon(addon)!;
const actualRecentAddon = recentAddonsIcons.find((a) =>
a.entityName.includes(addonEntity.name),
const actualRecentAddon = recentAddonsIcons.find(
(a) => a.entityId === addonEntity.id,
)!;
const expectedAddonIcon = iconApiHelper.getEntityIcon(addonEntity);
await agentSettingAssertion.assertEntityIcon(
Expand Down
6 changes: 3 additions & 3 deletions apps/chat-e2e/src/tests/entityIcon.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ dialTest(
.soft(actualIcons.length, ExpectedMessages.entitiesIconsCountIsValid)
.toBe(allExpectedEntities.length);

const actualEntity = actualIcons.find((e) =>
e.entityName.includes(randomEntity.name),
const actualEntity = actualIcons.find(
(e) => e.entityId === randomEntity.id,
)!;
const expectedEntityIcon = iconApiHelper.getEntityIcon(randomEntity);
await marketplaceAgentsAssertion.assertEntityIcon(
Expand All @@ -91,7 +91,7 @@ dialTest(

const randomAddon = GeneratorUtil.randomArrayElement(expectedAddons);
const actualAddon = actualAddonsIcons.find(
(a) => a.entityName === randomAddon.name,
(a) => a.entityId === randomAddon.id,
)!;
const expectedAddonIcon = iconApiHelper.getEntityIcon(randomAddon);
await addonsDialogAssertion.assertEntityIcon(
Expand Down
2 changes: 1 addition & 1 deletion apps/chat-e2e/src/tests/overlay/overlayAuth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ for (let i = 0; i < overlayUsernames.length; i++) {
setTestIds('EPMRTC-3785');
const overlayLoginPage = new OverlayLoginPage(page);
await overlayLoginPage.navigateToUrl(
OverlaySandboxUrls.modelIdSetSandboxUrl,
OverlaySandboxUrls.disableAllFeaturesUrl,
);
const newPage = await overlayLoginPage.clickLoginButton();

Expand Down
2 changes: 1 addition & 1 deletion apps/chat-e2e/src/ui/domData/attributes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ export enum Attributes {
download = 'download',
href = 'href',
dataQA = 'data-qa',
dataImageName = 'data-image-name',
ariaSelected = 'aria-selected',
id = 'id',
}
8 changes: 4 additions & 4 deletions apps/chat-e2e/src/ui/webElements/baseElement.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import path from 'path';
export const elementIndexExceptionError = 'Element index should start from 1';

export interface EntityIcon {
entityName: string;
entityId: string;
iconLocator: Locator;
}

Expand Down Expand Up @@ -213,11 +213,11 @@ export class BaseElement {
for (let i = 1; i <= elementsCount; i++) {
const element = elements.getNthElement(i);
const elementIconLocator = this.getElementIcon(element);
const elementIconName = await elementIconLocator.getAttribute(
Attributes.dataImageName,
const elementIconId = await elementIconLocator.getAttribute(
Attributes.id,
);
allIcons.push({
entityName: elementIconName!,
entityId: elementIconId!,
iconLocator: elementIconLocator,
});
}
Expand Down
1 change: 1 addition & 0 deletions apps/chat/src/components/Chatbar/ModelIcon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ const ModelIconTemplate = memo(
data-image-name={description}
ref={ref}
style={{ height: `${size}px`, width: `${size}px` }}
id={entityId}
/>
</span>
);
Expand Down

0 comments on commit 6bfc81b

Please sign in to comment.