Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(chat-e2e): new conversation on refresh tests #3042

Merged
merged 29 commits into from
Feb 4, 2025
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
a2a4337
test
nartovm Jan 27, 2025
57c3887
changes
nartovm Jan 27, 2025
af565bc
'EPMRTC-4587', 'EPMRTC-4586', 'EPMRTC-4718'
nartovm Jan 27, 2025
ea3d966
EPMRTC-4588
nartovm Jan 27, 2025
8587218
EPMRTC-4592
nartovm Jan 27, 2025
88ed66b
EPMRTC-4682
nartovm Jan 28, 2025
3e37327
EPMRTC-4683
nartovm Jan 28, 2025
f492a49
EPMRTC-4593
nartovm Jan 28, 2025
348adb6
Merge branch 'development' into feat/new-conversation-on-refresh-tests
nartovm Jan 28, 2025
bd5ff68
Merge branch 'development' into feat/new-conversation-on-refresh-tests
nartovm Jan 29, 2025
a887626
Merge branch 'development' into feat/new-conversation-on-refresh-tests
nartovm Jan 29, 2025
82236cd
Merge branch 'development' into feat/new-conversation-on-refresh-tests
nartovm Jan 29, 2025
f36680d
review fixes
nartovm Jan 29, 2025
6a8fdf5
Merge branch 'development' into feat/new-conversation-on-refresh-tests
nartovm Jan 30, 2025
2b82c30
test is splitted in 2
nartovm Jan 30, 2025
66784df
Merge branch 'feat/new-conversation-on-refresh-tests' of https://gith…
nartovm Jan 30, 2025
1d03e01
fix
nartovm Jan 30, 2025
323ad1e
fix
nartovm Jan 30, 2025
aeaf2a5
Hover fixes
nartovm Jan 30, 2025
07cdd49
review comments
nartovm Jan 30, 2025
2fb56d4
Merge branch 'development' into feat/new-conversation-on-refresh-tests
nartovm Jan 30, 2025
ec7fecf
fix
nartovm Jan 31, 2025
8b76c43
format fix
nartovm Jan 31, 2025
119780a
Merge branch 'development' into feat/new-conversation-on-refresh-tests
nartovm Jan 31, 2025
1f5abe6
Merge branch 'development' into feat/new-conversation-on-refresh-tests
nartovm Feb 3, 2025
0d6cbd5
fix
nartovm Feb 3, 2025
ebc703e
Merge branch 'development' into feat/new-conversation-on-refresh-tests
nartovm Feb 3, 2025
eb9acd2
Merge branch 'development' into feat/new-conversation-on-refresh-tests
nartovm Feb 3, 2025
236ce6d
Merge branch 'development' into feat/new-conversation-on-refresh-tests
nartovm Feb 4, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 2 additions & 24 deletions apps/chat-e2e/src/assertions/conversationAssertion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import {
TreeEntity,
} from '@/src/testData';
import { Colors, Styles } from '@/src/ui/domData';
import { ChatBarSelectors } from '@/src/ui/selectors';
import { ConversationsTree } from '@/src/ui/webElements/entityTree';
import { expect } from '@playwright/test';

Expand Down Expand Up @@ -53,33 +52,12 @@ export class ConversationAssertion extends SideBarEntityAssertion<ConversationsT
}

public async assertNoConversationIsSelected() {
const entitiesWithIndices =
await this.sideBarEntitiesTree.getAllTreeEntitiesWithIndices();
const selectedEntities = [];

for (const { name, index } of entitiesWithIndices) {
const hasSelectedClass =
(await this.sideBarEntitiesTree
.getEntityByName(name, index)
.locator(ChatBarSelectors.selectedEntity)
.count()) > 0;

const entityBackgroundColor =
await this.sideBarEntitiesTree.getEntityBackgroundColor(name, index);

if (
hasSelectedClass ||
entityBackgroundColor === Colors.backgroundAccentSecondary
) {
selectedEntities.push({ name, index });
}
}

const selectedEntities =
await this.sideBarEntitiesTree.getSelectedEntities();
expect
.soft(selectedEntities.length, ExpectedMessages.noConversationIsSelected)
.toBe(0);
}
nartovm marked this conversation as resolved.
Show resolved Hide resolved

public async assertConversationInToday(conversationName: string) {
const todayConversations =
await this.sideBarEntitiesTree.getChronologyConversations(
Expand Down
6 changes: 5 additions & 1 deletion apps/chat-e2e/src/assertions/sideBarEntityAssertion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,11 @@ export class SideBarEntityAssertion<
if (actualCount === undefined) {
await this.assertElementsCount(this.sideBarEntitiesTree, expectedCount);
} else {
await this.assertCount(expectedCount, actualCount);
this.assertValue(
expectedCount,
actualCount,
ExpectedMessages.elementsCountIsValid,
);
}
}
}
40 changes: 20 additions & 20 deletions apps/chat-e2e/src/tests/newConversationOnRefresh.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ dialTest(
});
await dialHomePage.waitForPageLoaded();
await chat.getSendMessage().waitForState({ state: 'attached' });
nartovm marked this conversation as resolved.
Show resolved Hide resolved
await chat.changeAgentButton.waitForState({ state: 'visible' });
await chat.configureSettingsButton.waitForState({ state: 'visible' });
await chat.changeAgentButton.waitForState();
await chat.configureSettingsButton.waitForState();
await conversationAssertion.assertNoConversationIsSelected();
},
);
Expand All @@ -81,8 +81,8 @@ dialTest(
'Verify nothing changes after going back to chat',
async () => {
await dialHomePage.waitForPageLoaded();
await chat.changeAgentButton.waitForState({ state: 'visible' });
await chat.configureSettingsButton.waitForState({ state: 'visible' });
await chat.changeAgentButton.waitForState();
await chat.configureSettingsButton.waitForState();
await conversationAssertion.assertNoConversationIsSelected();
},
);
Expand Down Expand Up @@ -139,8 +139,8 @@ dialTest(
async () => {
await dialHomePage.reloadPage();
await dialHomePage.waitForPageLoaded();
await chat.changeAgentButton.waitForState({ state: 'visible' });
await chat.configureSettingsButton.waitForState({ state: 'visible' });
await chat.changeAgentButton.waitForState();
await chat.configureSettingsButton.waitForState();
await conversationAssertion.assertNoConversationIsSelected();
},
);
Expand All @@ -153,8 +153,8 @@ dialTest(

await dialTest.step('Verify chat stays selected', async () => {
await dialHomePage.waitForPageLoaded();
await chat.changeAgentButton.waitForState({ state: 'visible' });
await chat.configureSettingsButton.waitForState({ state: 'visible' });
await chat.changeAgentButton.waitForState();
await chat.configureSettingsButton.waitForState();
await conversationAssertion.assertSelectedConversation(
initialConversationName,
);
Expand All @@ -166,8 +166,8 @@ dialTest(
async () => {
await dialHomePage.reloadPage();
await dialHomePage.waitForPageLoaded();
await chat.changeAgentButton.waitForState({ state: 'visible' });
await chat.configureSettingsButton.waitForState({ state: 'visible' });
await chat.changeAgentButton.waitForState();
await chat.configureSettingsButton.waitForState();
await conversationAssertion.assertSelectedConversation(
initialConversationName,
);
Expand All @@ -183,8 +183,8 @@ dialTest(
);
await dialHomePage.reloadPage();
await dialHomePage.waitForPageLoaded();
await chat.changeAgentButton.waitForState({ state: 'visible' });
await chat.configureSettingsButton.waitForState({ state: 'visible' });
await chat.changeAgentButton.waitForState();
await chat.configureSettingsButton.waitForState();
await conversationAssertion.assertNoConversationIsSelected();
},
);
Expand Down Expand Up @@ -259,8 +259,8 @@ dialTest(
});
await dialHomePage.waitForPageLoaded();
await chat.getSendMessage().waitForState({ state: 'attached' });
nartovm marked this conversation as resolved.
Show resolved Hide resolved
await chat.changeAgentButton.waitForState({ state: 'visible' });
await chat.configureSettingsButton.waitForState({ state: 'visible' });
await chat.changeAgentButton.waitForState();
await chat.configureSettingsButton.waitForState();
await conversationAssertion.assertNoConversationIsSelected();
},
);
Expand All @@ -282,8 +282,8 @@ dialTest(
async () => {
await dialHomePage.reloadPage();
await dialHomePage.waitForPageLoaded();
await chat.changeAgentButton.waitForState({ state: 'visible' });
await chat.configureSettingsButton.waitForState({ state: 'visible' });
await chat.changeAgentButton.waitForState();
await chat.configureSettingsButton.waitForState();
await conversationAssertion.assertNoConversationIsSelected();
},
);
Expand All @@ -298,8 +298,8 @@ dialTest(
await chat.changeAgentButton.hoverOver();
await dialHomePage.reloadPage();
await dialHomePage.waitForPageLoaded();
await chat.changeAgentButton.waitForState({ state: 'visible' });
await chat.configureSettingsButton.waitForState({ state: 'visible' });
await chat.changeAgentButton.waitForState();
await chat.configureSettingsButton.waitForState();
await conversationAssertion.assertNoConversationIsSelected();
},
);
Expand All @@ -314,8 +314,8 @@ dialTest(
await chat.changeAgentButton.hoverOver();
await dialHomePage.reloadPage();
await dialHomePage.waitForPageLoaded();
await chat.changeAgentButton.waitForState({ state: 'visible' });
await chat.configureSettingsButton.waitForState({ state: 'visible' });
await chat.changeAgentButton.waitForState();
await chat.configureSettingsButton.waitForState();
await conversationAssertion.assertNoConversationIsSelected();
},
);
Expand Down
29 changes: 1 addition & 28 deletions apps/chat-e2e/src/ui/webElements/entityTree/entitiesTree.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,33 +36,10 @@ export class EntitiesTree extends BaseElement {
return names;
}

public async getAllTreeEntitiesWithIndices(): Promise<
{ name: string; index: number }[]
> {
const entities = await this.getAllTreeEntities();
const namesWithIndices: { name: string; index: number }[] = [];
const nameOccurrences: Record<string, number> = {};

for (const entity of entities) {
const nameElement = entity.locator(EntitySelectors.entityName);
const name = await nameElement.textContent();
if (name) {
nameOccurrences[name] = (nameOccurrences[name] || 0) + 1;
namesWithIndices.push({
name,
index: nameOccurrences[name],
});
}
}

return namesWithIndices;
}

public async getAllTreeEntities(): Promise<Locator[]> {
const allEntities = this.getChildElementBySelector(this.entitySelector)
return this.getChildElementBySelector(this.entitySelector)
.getElementLocator()
.all();
return allEntities;
}

getTreeEntity(
Expand Down Expand Up @@ -106,10 +83,6 @@ export class EntitiesTree extends BaseElement {
);
}

test() {
return this.getElementLocator().locator(EntitySelectors.entityName);
}

getEntityCheckbox(name: string, index?: number) {
return this.getEntityByName(name, index).getByRole('checkbox');
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { isApiStorageType } from '@/src/hooks/global-setup';
import { Colors } from '@/src/ui/domData';
import { ChatBarSelectors } from '@/src/ui/selectors';
import { SideBarEntitiesTree } from '@/src/ui/webElements/entityTree/sidebar/sideBarEntitiesTree';

Expand All @@ -24,4 +25,32 @@ export class BaseSideBarConversationTree extends SideBarEntitiesTree {
ChatBarSelectors.selectedEntity,
);
}

public async getSelectedEntities(): Promise<
{ name: string; index?: number }[]
> {
const allNames = await this.getAllTreeEntitiesNames();
const selectedEntities = [];

for (const name of allNames) {
const hasSelectedClass = await this.isEntitySelected(name);
const backgroundColor = await this.getEntityBackgroundColor(name);

if (
hasSelectedClass ||
backgroundColor === Colors.backgroundAccentSecondary
) {
selectedEntities.push({ name });
}
}
return selectedEntities;
}

public async isEntitySelected(name: string): Promise<boolean> {
nartovm marked this conversation as resolved.
Show resolved Hide resolved
return (
(await this.getEntityByExactName(name)
.locator(ChatBarSelectors.selectedEntity)
.count()) > 0
);
}
}