Skip to content

Commit

Permalink
feat(chat-e2e): new conversation on refresh tests (#3042)
Browse files Browse the repository at this point in the history
  • Loading branch information
nartovm authored Feb 4, 2025
1 parent dcaf31d commit bf01289
Show file tree
Hide file tree
Showing 11 changed files with 421 additions and 27 deletions.
6 changes: 5 additions & 1 deletion apps/chat-e2e/src/assertions/base/baseAssertion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,11 @@ export class BaseAssertion {
.soft(elementsCount, ExpectedMessages.elementsCountIsValid)
.toBe(expectedCount);
}

public async assertCount(expectedCount: number, actualCount: number) {
expect
.soft(actualCount, ExpectedMessages.elementsCountIsValid)
.toBe(expectedCount);
}
public assertValue(
actualValue: string | number | undefined,
expectedValue: string | number,
Expand Down
5 changes: 1 addition & 4 deletions apps/chat-e2e/src/assertions/base/entityTreeAssertion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,7 @@ export class EntityTreeAssertion<T extends EntitiesTree> extends BaseAssertion {
entity: TreeEntity,
expectedState: ElementState,
) {
const entityLocator = this.treeEntities.getEntityByExactName(
entity.name,
entity.index,
);
const entityLocator = this.treeEntities.getEntityByExactName(entity.name);
await this.assertElementState(entityLocator, expectedState);
}

Expand Down
23 changes: 15 additions & 8 deletions apps/chat-e2e/src/assertions/conversationAssertion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,16 +41,23 @@ export class ConversationAssertion extends SideBarEntityAssertion<ConversationsT
}

public async assertSelectedConversation(conversationName: string) {
const conversationBackgroundColor =
await this.sideBarEntitiesTree.getEntityBackgroundColor(conversationName);
expect
.soft(
conversationBackgroundColor,
ExpectedMessages.conversationIsSelected,
)
.toBe(Colors.backgroundAccentSecondary);
const selectedEntity =
this.sideBarEntitiesTree.selectedConversation(conversationName);

await this.assertElementState(selectedEntity, 'visible');
await this.assertEntityBackgroundColor(
{ name: conversationName },
Colors.backgroundAccentSecondary,
);
}

public async assertNoConversationIsSelected() {
const selectedEntities =
await this.sideBarEntitiesTree.getSelectedEntities();
expect
.soft(selectedEntities.length, ExpectedMessages.noConversationIsSelected)
.toBe(0);
}
public async assertConversationInToday(conversationName: string) {
const todayConversations =
await this.sideBarEntitiesTree.getChronologyConversations(
Expand Down
17 changes: 13 additions & 4 deletions apps/chat-e2e/src/assertions/sideBarEntityAssertion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,18 @@ export class SideBarEntityAssertion<
);
}

public async assertEntitiesCount(actualCount: number, expectedCount: number) {
expect
.soft(actualCount, ExpectedMessages.entitiesCountIsValid)
.toBe(expectedCount);
public async assertEntitiesCount(
expectedCount: number,
actualCount?: number,
) {
if (actualCount === undefined) {
await this.assertElementsCount(this.sideBarEntitiesTree, expectedCount);
} else {
this.assertValue(
expectedCount,
actualCount,
ExpectedMessages.elementsCountIsValid,
);
}
}
}
6 changes: 6 additions & 0 deletions apps/chat-e2e/src/core/localStorageManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,12 @@ export class LocalStorageManager {
);
}

async removeFromLocalStorage(key: string) {
await this.page.evaluate((storageKey) => {
window.localStorage.removeItem(storageKey);
}, key);
}

async getRecentModels() {
return this.page.evaluate(
() => window.localStorage.getItem('recentModelsIds') ?? undefined,
Expand Down
1 change: 1 addition & 0 deletions apps/chat-e2e/src/testData/expectedMessages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,7 @@ export enum ExpectedMessages {
elementIsDisabled = 'Elements is disabled',
elementIsVisible = 'Elements is visible',
elementIsNotVisible = 'Elements is not visible',
noConversationIsSelected = 'No conversation is selected',
}

export enum PublishingExpectedMessages {
Expand Down
2 changes: 1 addition & 1 deletion apps/chat-e2e/src/tests/chatSelectionFunctionality.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ dialTest(
await conversationDropdownMenu.selectMenuOption(MenuOptions.duplicate, {
triggeredHttpMethod: 'POST',
});
clonedConversation = `${firstConversation.name} 1`;
clonedConversation = `${ExpectedConstants.playbackConversation}${firstConversation.name} 1`;
await conversations.getEntityByName(clonedConversation).waitFor();
await conversationAssertion.assertSelectedConversation(
clonedConversation,
Expand Down
Loading

0 comments on commit bf01289

Please sign in to comment.