Skip to content

Commit

Permalink
feat/fix-talk-to-search-test: fixed flaky e2e
Browse files Browse the repository at this point in the history
  • Loading branch information
irinakartun committed Feb 14, 2025
1 parent d0d3697 commit c0d2677
Showing 1 changed file with 36 additions and 22 deletions.
58 changes: 36 additions & 22 deletions apps/chat-e2e/src/tests/defaultModelSettings.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
} from '../testData';
import { Cursors, Styles } from '../ui/domData';

import { EntityType } from '@/chat/types/common';
import { DialAIEntityModel } from '@/chat/types/models';
import { keys } from '@/src/ui/keyboard';
import { GeneratorUtil, ModelsUtil } from '@/src/utils';
Expand Down Expand Up @@ -445,34 +446,17 @@ dialTest(
marketplaceHeader,
talkToAgentDialog,
chat,
modelApiHelper,
setTestIds,
}) => {
setTestIds('EPMRTC-408');
const randomEntity = GeneratorUtil.randomArrayElement(
ModelsUtil.getOpenAIEntities().filter((m) => m.name.length >= 3),
);
const searchTerm = randomEntity.name.substring(0, 3);
const matchedModels = ModelsUtil.getModels().filter(
(m) =>
m.name.toLowerCase().includes(searchTerm.toLowerCase()) ||
m.version?.toLowerCase().includes(searchTerm.toLowerCase()),
);
const matchedApplications = ModelsUtil.getApplications().filter(
(a) =>
a.name.toLowerCase().includes(searchTerm.toLowerCase()) ||
a.version?.toLowerCase().includes(searchTerm.toLowerCase()),
);
const matchedAssistants = ModelsUtil.getAssistants().filter(
(a) =>
a.name.toLowerCase().includes(searchTerm.toLowerCase()) ||
a.version?.toLowerCase().includes(searchTerm.toLowerCase()),
);
const expectedMatchedModelsCount =
ModelsUtil.groupEntitiesByName(matchedModels).size;
const expectedMatchedAppsCount =
ModelsUtil.groupEntitiesByName(matchedApplications).size;
const expectedMatchedAssistantsCount =
ModelsUtil.groupEntitiesByName(matchedAssistants).size;
let expectedMatchedModelsCount: number;
let expectedMatchedAppsCount: number;
let expectedMatchedAssistantsCount: number;

await dialTest.step(
'Create new conversation and click "Search on My workspace" link',
Expand All @@ -491,6 +475,33 @@ dialTest(
await marketplaceHeader.searchInput.fillInInput(searchTerm);
const entitiesCount =
await marketplaceAgents.agentNames.getElementsCount();

const configModels = await modelApiHelper.getModels();
const matchedModels = configModels.filter(
(m) =>
m.type === EntityType.Model &&
(m.name.toLowerCase().includes(searchTerm.toLowerCase()) ||
m.version?.toLowerCase().includes(searchTerm.toLowerCase())),
);
const matchedApplications = configModels.filter(
(a) =>
a.type === EntityType.Application &&
(a.name.toLowerCase().includes(searchTerm.toLowerCase()) ||
a.version?.toLowerCase().includes(searchTerm.toLowerCase())),
);
const matchedAssistants = configModels.filter(
(a) =>
a.type === EntityType.Assistant &&
(a.name.toLowerCase().includes(searchTerm.toLowerCase()) ||
a.version?.toLowerCase().includes(searchTerm.toLowerCase())),
);
expectedMatchedModelsCount =
ModelsUtil.groupEntitiesByName(matchedModels).size;
expectedMatchedAppsCount =
ModelsUtil.groupEntitiesByName(matchedApplications).size;
expectedMatchedAssistantsCount =
ModelsUtil.groupEntitiesByName(matchedAssistants).size;

expect
.soft(entitiesCount, ExpectedMessages.searchResultCountIsValid)
.toBe(
Expand Down Expand Up @@ -537,7 +548,10 @@ dialTest(
await marketplaceAgents.agentNames.getElementsCount();
expect
.soft(entitiesCount, ExpectedMessages.searchResultCountIsValid)
.toBe(ModelsUtil.getLatestOpenAIEntities().length);
.toBe(
ModelsUtil.getLatestOpenAIEntities(await modelApiHelper.getModels())
.length,
);
},
);
},
Expand Down

0 comments on commit c0d2677

Please sign in to comment.