Skip to content

Commit

Permalink
e2e: fixed flaky tests, enabled blocked test (#617)
Browse files Browse the repository at this point in the history
Co-authored-by: Irina_Kartun <[email protected]>
  • Loading branch information
irinakartun and irinakartun authored Jan 29, 2024
1 parent 6f5aadd commit d832517
Show file tree
Hide file tree
Showing 9 changed files with 57 additions and 65 deletions.
2 changes: 2 additions & 0 deletions e2e/src/tests/chatExportImport.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,7 @@ test(
conversations,
chat,
apiHelper,
conversationSettings,
}) => {
setTestIds('EPMRTC-906', 'EPMRTC-779');
await test.step('Import conversation from 1.4 app version and verify folder with Gpt-3.5 chat and its history is visible', async () => {
Expand Down Expand Up @@ -477,6 +478,7 @@ test(
ExpectedConstants.newConversationTitle,
2,
);
await conversationSettings.waitForState();
await chat.sendRequestWithButton('1+1=', false);
const todayConversations = await conversations.getTodayConversations();
expect
Expand Down
13 changes: 8 additions & 5 deletions e2e/src/tests/compareMode.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -619,17 +619,17 @@ test('Apply changes with new settings for both chats in compare mode and check c
errorPopup,
apiHelper,
}) => {
test.slow();
setTestIds('EPMRTC-1021');

let firstConversation: Conversation;
let secondConversation: Conversation;
const models = ModelsUtil.getModels();
const modelsWithIcons = models.filter((m) => m.iconUrl);
const initRandomModel = GeneratorUtil.randomArrayElement(models);
const modelsForUpdate = models.filter((m) => m !== initRandomModel);
const firstUpdatedRandomModel =
GeneratorUtil.randomArrayElement(modelsWithIcons);
GeneratorUtil.randomArrayElement(modelsForUpdate);
const secondUpdatedRandomModel =
GeneratorUtil.randomArrayElement(modelsWithIcons);
GeneratorUtil.randomArrayElement(modelsForUpdate);
const firstUpdatedPrompt = 'first prompt';
const secondUpdatedPrompt = 'second prompt';
const firstUpdatedTemp = 0.5;
Expand Down Expand Up @@ -682,7 +682,10 @@ test('Apply changes with new settings for both chats in compare mode and check c
await rightEntitySettings
.getTemperatureSlider()
.setTemperature(secondUpdatedTemp);
await chat.applyChanges().click();
await chat.applyNewEntity(
firstUpdatedRandomModel.iconUrl,
secondUpdatedRandomModel.iconUrl,
);
});

await test.step('Verify chat icons are updated with new model and addons in the header and chat bar', async () => {
Expand Down
49 changes: 23 additions & 26 deletions e2e/src/tests/entityIcon.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,19 +40,18 @@ test(
)
.toBe(allExpectedEntities.length);

for (const entity of allExpectedEntities) {
const actualEntity = actualEntitiesIcons.find(
(e) => e.entityName === entity.name,
)!;
const expectedEntityIcon = await apiHelper.getEntityIcon(entity);
expect
.soft(
actualEntity.icon,
`${ExpectedMessages.entityIconIsValid} for ${entity.name}`,
)
.toBe(expectedEntityIcon);
}

const randomEntity =
GeneratorUtil.randomArrayElement(allExpectedEntities);
const actualEntity = actualEntitiesIcons.find(
(e) => e.entityName === randomEntity.name,
)!;
const expectedEntityIcon = await apiHelper.getEntityIcon(randomEntity);
expect
.soft(
actualEntity.icon,
`${ExpectedMessages.entityIconIsValid} for ${randomEntity.name}`,
)
.toBe(expectedEntityIcon);
await modelsDialog.closeDialog();
});

Expand All @@ -67,19 +66,17 @@ test(
)
.toBeGreaterThanOrEqual(expectedAddons.length);

for (const addon of expectedAddons) {
const actualAddon = actualAddonsIcons.find(
(a) => a.entityName === addon.name,
)!;
const expectedAddonIcon = await apiHelper.getEntityIcon(addon);
expect
.soft(
actualAddon.icon,
`${ExpectedMessages.addonIconIsValid} for ${addon.name}`,
)
.toBe(expectedAddonIcon);
}

const randomAddon = GeneratorUtil.randomArrayElement(expectedAddons);
const actualAddon = actualAddonsIcons.find(
(a) => a.entityName === randomAddon.name,
)!;
const expectedAddonIcon = await apiHelper.getEntityIcon(randomAddon);
expect
.soft(
actualAddon.icon,
`${ExpectedMessages.addonIconIsValid} for ${randomAddon.name}`,
)
.toBe(expectedAddonIcon);
await addonsDialog.closeDialog();
});

Expand Down
7 changes: 3 additions & 4 deletions e2e/src/tests/replay.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -845,11 +845,10 @@ test(

const newModels = [ModelIds.BISON_001, ModelIds.GPT_4];
for (let i = 1; i <= newModels.length; i++) {
const newModel = ModelsUtil.getModel(newModels[i - 1])!;
await chatHeader.openConversationSettingsPopup();
await talkToSelector.selectModel(
ModelsUtil.getModel(newModels[i - 1])!.name,
);
await chat.applyChanges().click();
await talkToSelector.selectModel(newModel.name);
await chat.applyNewEntity(newModel.iconUrl);
const newMessage = `${i}*2=`;
await chat.sendRequestWithButton(newMessage);
}
Expand Down
9 changes: 5 additions & 4 deletions e2e/src/tests/sharedChatIcons.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ test(
talkToSelector,
chat,
tooltip,
conversationSettings,
setTestIds,
}) => {
setTestIds(
Expand Down Expand Up @@ -258,12 +259,12 @@ test(
});

await test.step('Change chat model, send a new request and verify share icon is preserved on chat bar', async () => {
const updatedModel = ModelsUtil.getModel(ModelIds.GPT_4)!;
await chatHeader.openConversationSettingsPopup();
await talkToSelector.waitForState();
await talkToSelector.selectModel(
ModelsUtil.getModel(ModelIds.GPT_4)!.name,
);
await chat.applyChanges().click();
await talkToSelector.selectModel(updatedModel.name);
await chat.applyNewEntity(updatedModel.iconUrl);
await conversationSettings.waitForState({ state: 'hidden' });
await chat.sendRequestWithButton('1+2=', false);
await conversations.getConversationArrowIcon(conversation.name).waitFor();
});
Expand Down
15 changes: 0 additions & 15 deletions e2e/src/tests/sidePanelEntityDragAndDrop.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,13 +130,6 @@ test(
for (const folder of nestedFolders) {
await folderConversations.getFolderByName(folder.name).waitFor();
}
const folderBackgroundColor =
await folderConversations.getFolderGroupBackgroundColor(
nestedFolders[0].name,
);
expect
.soft(folderBackgroundColor, ExpectedMessages.folderIsHighlighted)
.toBe(Colors.backgroundAccentSecondary);
await page.mouse.up();
});

Expand All @@ -163,10 +156,8 @@ test('Chat is moved using drag&drop to expanded folder', async ({
localStorageManager,
chatBar,
setTestIds,
setIssueIds,
}) => {
setTestIds('EPMRTC-941');
setIssueIds('482');
let folderConversation: FolderConversation;
let conversationToDrop: Conversation;

Expand Down Expand Up @@ -275,12 +266,6 @@ test('Prompt is moved using drag&drop to collapsed folder', async ({
await promptBar.drugPromptToFolder(folders[0].name, prompt.name);
await folderPrompts.getFolderByName(folders[1].name).waitFor();
await folderPrompts.waitForFolderGroupIsHighlighted(folders[0].name);

const folderBackgroundColor =
await folderPrompts.getFolderGroupBackgroundColor(folders[0].name);
expect
.soft(folderBackgroundColor, ExpectedMessages.folderIsHighlighted)
.toBe(Colors.backgroundAccentTertiary);
await page.mouse.up();
await folderPrompts.getFolderEntity(folders[0].name, prompt.name).waitFor();
});
Expand Down
15 changes: 15 additions & 0 deletions e2e/src/ui/webElements/chat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -236,4 +236,19 @@ export class Chat extends BaseElement {
);
await this.getPlaybackControl().playbackPreviousButton.click();
}

public async applyNewEntity(...iconsHosts: (string | undefined)[]) {
const responses = [];
for (const iconHost of iconsHosts) {
const resp = this.page.waitForResponse(
(response) =>
response.url().includes(iconHost!) && response.status() === 200,
);
responses.push(resp);
}
await this.applyChanges().click();
for (const resp of responses) {
await resp;
}
}
}
1 change: 1 addition & 0 deletions e2e/src/ui/webElements/chatMessages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,7 @@ export class ChatMessages extends BaseElement {

public async openEditMessageMode(message: string | number) {
const chatMessage = this.getChatMessage(message);
await chatMessage.scrollIntoViewIfNeeded();
await chatMessage.hover();
const editIcon = this.messageEditIcon(chatMessage);
await editIcon.waitFor();
Expand Down
11 changes: 0 additions & 11 deletions e2e/src/ui/webElements/folders.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,17 +115,6 @@ export class Folders extends BaseElement {
return folder.getComputedStyleProperty(Styles.color);
}

public async getFolderGroupBackgroundColor(parentFolderName: string) {
const backgroundColor = await this.foldersGroup(
parentFolderName,
).getComputedStyleProperty(Styles.backgroundColor);
backgroundColor[0] = backgroundColor[0].replace(
ExpectedConstants.backgroundColorPattern,
'$1)',
);
return backgroundColor[0];
}

public getFolderEntities(name: string, index?: number) {
return this.getFolderByName(name, index).locator(
`~${Tags.div} ${this.entitySelector}`,
Expand Down

0 comments on commit d832517

Please sign in to comment.