Skip to content

Commit

Permalink
e2e: fixed tests after icon caching (#550)
Browse files Browse the repository at this point in the history
Co-authored-by: Irina_Kartun <[email protected]>
  • Loading branch information
2 people authored and mikitabut committed Jan 17, 2024
1 parent 4b18543 commit 377f1dc
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 24 deletions.
12 changes: 2 additions & 10 deletions e2e/src/tests/replay.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -527,10 +527,7 @@ test(
await test.step('Send new request with preselected "Replay as is" option and verify message icons correspond models', async () => {
await dialHomePage.openHomePage();
await dialHomePage.waitForPageLoaded();
await chat.startReplayForDifferentModels([
conversation.messages[0].content,
conversation.messages[2].content,
]);
await chat.startReplayForDifferentModels();

const expectedFirstModelIcon = await apiHelper.getEntityIcon(firstModel);
const expectedSecondModelIcon =
Expand Down Expand Up @@ -827,7 +824,6 @@ test(
replayAsIs,
}) => {
setTestIds('EPMRTC-1330', 'EPMRTC-1332');
const newMessages: string[] = [];
const filename = GeneratorUtil.randomArrayElement([
Import.v14AppImportedFilename,
Import.v19AppImportedFilename,
Expand Down Expand Up @@ -855,7 +851,6 @@ test(
);
await chat.applyChanges().click();
const newMessage = `${i}*2=`;
newMessages.push(newMessage);
await chat.sendRequestWithButton(newMessage);
}
});
Expand Down Expand Up @@ -892,10 +887,7 @@ test(
});

await test.step('Start replaying and verify old requests are replayed using gpt-4 model', async () => {
const requests = await chat.startReplayForDifferentModels([
Import.oldVersionAppGpt35Message,
...newMessages,
]);
const requests = await chat.startReplayForDifferentModels();
for (let i = 0; i < requests.length; i++) {
const modelId = i === 1 ? ModelIds.BISON_001 : ModelIds.GPT_4;
expect
Expand Down
2 changes: 1 addition & 1 deletion e2e/src/ui/pages/basePage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export class BasePage {
for (const iconHost of options.iconsToBeLoaded) {
const resp = this.page.waitForResponse(
(response) =>
response.url() === iconHost && response.status() === 200,
response.url().includes(iconHost!) && response.status() === 200,
{ timeout: apiTimeout },
);
responses.push(resp);
Expand Down
21 changes: 8 additions & 13 deletions e2e/src/ui/webElements/chat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,22 +114,17 @@ export class Chat extends BaseElement {
return request.postDataJSON();
}

public async startReplayForDifferentModels(userRequests: string[]) {
public async startReplayForDifferentModels() {
await this.replay.waitForState();
const requestPromises = [];
for (const req of userRequests) {
const requestPromise = this.waitForRequestSent(req);
requestPromises.push(requestPromise);
}
const requests: string[] = [];
this.page.on('request', (data) => {
if (data.url().includes(API.chatHost)) {
requests.push(data.postData()!);
}
});
await this.replay.click();

const requests = [];
for (const req of requestPromises) {
const request = await req;
requests.push(request);
}
await this.waitForResponse(true);
return requests.map((r) => r.postDataJSON());
return requests.map((r) => JSON.parse(r));
}

public async sendRequestInCompareMode(
Expand Down

0 comments on commit 377f1dc

Please sign in to comment.