Skip to content

Commit 33bd925

Browse files
authored
feat(chat-e2e): fixed app editor test (#3839)
1 parent cf63ca9 commit 33bd925

File tree

10 files changed

+87
-45
lines changed

10 files changed

+87
-45
lines changed

apps/chat-e2e/src/core/dialFixtures.ts

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ import {
55
AgentInfo,
66
AppEditorContainer,
77
AppEditorGeneralForm,
8+
AppEditorGeneralInfoAgentPreview,
89
AppEditorHeader,
9-
AppEditorPreview,
1010
AppEditorViewForm,
1111
AttachFilesModal,
1212
Chat,
@@ -91,6 +91,7 @@ import { Addons } from '@/src/ui/webElements/addons';
9191
import { AddonsDialog } from '@/src/ui/webElements/addonsDialog';
9292
import { AgentSettings } from '@/src/ui/webElements/agentSettings';
9393
import { AppContainer } from '@/src/ui/webElements/appContainer';
94+
import { AppEditorAppSettingsAgentPreview } from '@/src/ui/webElements/appEditor/appEditorAppSettingsAgentPreview';
9495
import { Banner } from '@/src/ui/webElements/banner';
9596
import { Compare } from '@/src/ui/webElements/compare';
9697
import { ConfirmationDialog } from '@/src/ui/webElements/confirmationDialog';
@@ -170,7 +171,8 @@ const dialTest = test.extend<{
170171
appEditorHeader: AppEditorHeader;
171172
appEditorHeaderAssertion: AppEditorHeaderAssertion;
172173
appEditorGeneralForm: AppEditorGeneralForm;
173-
appEditorPreview: AppEditorPreview;
174+
appEditorGeneralInfoAgentPreview: AppEditorGeneralInfoAgentPreview;
175+
appEditorAppSettingsAgentPreview: AppEditorAppSettingsAgentPreview;
174176
appEditorViewForm: AppEditorViewForm;
175177
chatBar: ChatBar;
176178
navigationPanel: NavigationPanel;
@@ -475,9 +477,15 @@ const dialTest = test.extend<{
475477
const appEditorGeneralForm = appEditorContainer.getAppEditorGeneralForm();
476478
await use(appEditorGeneralForm);
477479
},
478-
appEditorPreview: async ({ appEditorContainer }, use) => {
479-
const appEditorPreview = appEditorContainer.getAppEditorPreview();
480-
await use(appEditorPreview);
480+
appEditorGeneralInfoAgentPreview: async ({ appEditorContainer }, use) => {
481+
const appEditorGeneralInfoPreview =
482+
appEditorContainer.getAppEditorGeneralInfoPreview();
483+
await use(appEditorGeneralInfoPreview);
484+
},
485+
appEditorAppSettingsAgentPreview: async ({ appEditorContainer }, use) => {
486+
const appEditorAppSettingsPreview =
487+
appEditorContainer.getAppEditorAppSettingsPreview();
488+
await use(appEditorAppSettingsPreview);
481489
},
482490
appEditorViewForm: async ({ appEditorContainer }, use) => {
483491
const appEditorViewForm = appEditorContainer.getAppEditorViewForm();

apps/chat-e2e/src/tests/customApplications.test.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -888,7 +888,8 @@ dialTest(
888888
attachFilesModal,
889889
appEditorHeader,
890890
appEditorGeneralForm,
891-
appEditorPreview,
891+
appEditorGeneralInfoAgentPreview,
892+
appEditorAppSettingsAgentPreview,
892893
customApplicationBuilder,
893894
applicationApiHelper,
894895
uploadFromDeviceModal,
@@ -953,18 +954,19 @@ dialTest(
953954
await dialTest.step(
954955
'Verify the updated icon is displayed in the preview on the "General info" step',
955956
async () => {
956-
const previewIcon = appEditorPreview.previewIcon;
957+
const previewIcon = appEditorGeneralInfoAgentPreview.previewIcon;
957958
await baseAssertion.assertEntityIcon(previewIcon, expectedNewIconUrl);
958959
},
959960
);
960961

961962
await dialTest.step(
962-
'Navigate to "App settings" step and verify the updated icon in the preview',
963+
'Navigate to "App settings" step and verify the updated icon in the chat preview',
963964
async () => {
964965
await appEditorGeneralForm.goNext({ waitForResponses: false });
965-
const previewIconAppSettings = appEditorPreview.previewIcon;
966+
const previewChatIconAppSettings =
967+
appEditorAppSettingsAgentPreview.previewChatIcon;
966968
await baseAssertion.assertEntityIcon(
967-
previewIconAppSettings,
969+
previewChatIconAppSettings,
968970
expectedNewIconUrl,
969971
);
970972
},

apps/chat-e2e/src/ui/pages/appEditorPage.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ export class AppEditorPage extends BasePage {
1414
async waitForPageLoaded() {
1515
const appEditorContainer = this.getAppEditorContainer();
1616
const applicationGeneralForm = appEditorContainer.getAppEditorGeneralForm();
17-
const applicationPreview = appEditorContainer.getAppEditorPreview();
17+
const applicationPreview =
18+
appEditorContainer.getAppEditorGeneralInfoPreview();
1819
await this.appEditorContainer
1920
.getChatLoader()
2021
.waitForState({ state: 'hidden' });
@@ -26,7 +27,8 @@ export class AppEditorPage extends BasePage {
2627
async waitForPageLoadedForEdit() {
2728
const appEditorContainer = this.getAppEditorContainer();
2829
const applicationViewForm = appEditorContainer.getAppEditorViewForm();
29-
const applicationPreview = appEditorContainer.getAppEditorChatMode();
30+
const applicationPreview =
31+
appEditorContainer.getAppEditorAppSettingsPreview();
3032
await this.appEditorContainer
3133
.getChatLoader()
3234
.waitForState({ state: 'hidden' });

apps/chat-e2e/src/ui/selectors/dialogSelectors.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -248,9 +248,8 @@ export const ApplicationEditorHeader = {
248248
notSelectedStepIcon: '[data-qa="not-selected-step-icon"]',
249249
};
250250

251-
export const ApplicationPreviewSelector = {
251+
export const AppEditorGeneralInfoPreviewSelectors = {
252252
containerGeneralInfo: '[data-qa="app-preview-general-info"]',
253-
containerAppSettings: '[data-qa="app-settings-chat-mode"]',
254253
previewIconContainer: '[data-qa="entity-icon"]',
255254
previewAgentName: '[data-qa="agent-name"]',
256255
previewTopicsContainer: '[data-qa="app-topics"]',
@@ -259,6 +258,12 @@ export const ApplicationPreviewSelector = {
259258
previewAuthorValue: '[data-qa="author"]',
260259
};
261260

261+
export const AppEditorAppSettingsPreviewSelectors = {
262+
container: '[data-qa="app-preview-settings"]',
263+
chatPreviewContainer: '[data-qa="app-settings-chat-mode"]',
264+
previewIconContainer: '[data-qa="entity-icon"]',
265+
};
266+
262267
export const AddApplicationGeneralInfoFormSelector = {
263268
appGeneralFormContainer: '[data-qa="app-general-form"]',
264269
name: '#name',
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import { Tags } from '@/src/ui/domData';
2+
import {
3+
AppEditorAppSettingsPreviewSelectors,
4+
AppEditorGeneralInfoPreviewSelectors,
5+
} from '@/src/ui/selectors';
6+
import { BaseElement } from '@/src/ui/webElements';
7+
import { Locator, Page } from '@playwright/test';
8+
9+
export class AppEditorAppSettingsAgentPreview extends BaseElement {
10+
constructor(page: Page, parentLocator: Locator) {
11+
super(page, AppEditorAppSettingsPreviewSelectors.container, parentLocator);
12+
}
13+
14+
public appEditorChatMode = this.getChildElementBySelector(
15+
AppEditorAppSettingsPreviewSelectors.chatPreviewContainer,
16+
);
17+
18+
public previewChatIconContainer =
19+
this.appEditorChatMode.getChildElementBySelector(
20+
AppEditorGeneralInfoPreviewSelectors.previewIconContainer,
21+
);
22+
23+
public previewChatIcon =
24+
this.previewChatIconContainer.getChildElementBySelector(Tags.img);
25+
}

apps/chat-e2e/src/ui/webElements/appEditor/appEditorChatMode.ts

Lines changed: 0 additions & 9 deletions
This file was deleted.

apps/chat-e2e/src/ui/webElements/appEditor/appEditorContainer.ts

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
import { ChatSelectors } from '@/src/ui/selectors';
22
import { AppEditorGeneralForm, BaseElement } from '@/src/ui/webElements';
3-
import { AppEditorChatMode } from '@/src/ui/webElements/appEditor/appEditorChatMode';
3+
import { AppEditorAppSettingsAgentPreview } from '@/src/ui/webElements/appEditor/appEditorAppSettingsAgentPreview';
4+
import { AppEditorGeneralInfoAgentPreview } from '@/src/ui/webElements/appEditor/appEditorGeneralInfoAgentPreview';
45
import { AppEditorHeader } from '@/src/ui/webElements/appEditor/appEditorHeader';
5-
import { AppEditorPreview } from '@/src/ui/webElements/appEditor/appEditorPreview';
66
import { AppEditorViewForm } from '@/src/ui/webElements/appEditor/appEditorViewForm';
77
import { BaseLayoutContainer } from '@/src/ui/webElements/baseLayoutContainer';
88

99
export class AppEditorContainer extends BaseLayoutContainer<AppEditorHeader> {
1010
private appEditorHeader!: AppEditorHeader;
1111
private appEditorGeneralForm!: AppEditorGeneralForm;
1212
private appEditorViewForm!: AppEditorViewForm;
13-
private appEditorPreview!: AppEditorPreview;
14-
private appEditorChatMode!: AppEditorChatMode;
13+
private appEditorGeneralInfoPreview!: AppEditorGeneralInfoAgentPreview;
14+
private appEditorAppSettingsPreview!: AppEditorAppSettingsAgentPreview;
1515

1616
getHeader(): AppEditorHeader {
1717
if (!this.header) {
@@ -47,21 +47,24 @@ export class AppEditorContainer extends BaseLayoutContainer<AppEditorHeader> {
4747
return this.appEditorViewForm;
4848
}
4949

50-
getAppEditorPreview(): AppEditorPreview {
51-
if (!this.appEditorPreview) {
52-
this.appEditorPreview = new AppEditorPreview(this.page, this.rootLocator);
50+
getAppEditorGeneralInfoPreview(): AppEditorGeneralInfoAgentPreview {
51+
if (!this.appEditorGeneralInfoPreview) {
52+
this.appEditorGeneralInfoPreview = new AppEditorGeneralInfoAgentPreview(
53+
this.page,
54+
this.rootLocator,
55+
);
5356
}
54-
return this.appEditorPreview;
57+
return this.appEditorGeneralInfoPreview;
5558
}
5659

57-
getAppEditorChatMode(): AppEditorChatMode {
58-
if (!this.appEditorChatMode) {
59-
this.appEditorChatMode = new AppEditorChatMode(
60+
getAppEditorAppSettingsPreview(): AppEditorAppSettingsAgentPreview {
61+
if (!this.appEditorAppSettingsPreview) {
62+
this.appEditorAppSettingsPreview = new AppEditorAppSettingsAgentPreview(
6063
this.page,
6164
this.rootLocator,
6265
);
6366
}
64-
return this.appEditorChatMode;
67+
return this.appEditorAppSettingsPreview;
6568
}
6669

6770
getChatLoader(): BaseElement {

apps/chat-e2e/src/ui/webElements/appEditor/appEditorPreview.ts renamed to apps/chat-e2e/src/ui/webElements/appEditor/appEditorGeneralInfoAgentPreview.ts

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,45 @@
11
import { Tags } from '@/src/ui/domData';
2-
import { ApplicationPreviewSelector } from '@/src/ui/selectors';
2+
import { AppEditorGeneralInfoPreviewSelectors } from '@/src/ui/selectors';
33
import { BaseElement } from '@/src/ui/webElements';
44
import { Locator, Page } from '@playwright/test';
55

6-
export class AppEditorPreview extends BaseElement {
6+
export class AppEditorGeneralInfoAgentPreview extends BaseElement {
77
constructor(page: Page, parentLocator: Locator) {
8-
super(page, ApplicationPreviewSelector.containerGeneralInfo, parentLocator);
8+
super(
9+
page,
10+
AppEditorGeneralInfoPreviewSelectors.containerGeneralInfo,
11+
parentLocator,
12+
);
913
}
1014

1115
public previewIconContainer = this.getChildElementBySelector(
12-
ApplicationPreviewSelector.previewIconContainer,
16+
AppEditorGeneralInfoPreviewSelectors.previewIconContainer,
1317
);
1418

1519
public previewIcon = this.previewIconContainer.getChildElementBySelector(
1620
Tags.img,
1721
);
1822

1923
public previewName = this.getChildElementBySelector(
20-
ApplicationPreviewSelector.previewAgentName,
24+
AppEditorGeneralInfoPreviewSelectors.previewAgentName,
2125
);
2226

2327
public previewTopicsContainer = this.getChildElementBySelector(
24-
ApplicationPreviewSelector.previewTopicsContainer,
28+
AppEditorGeneralInfoPreviewSelectors.previewTopicsContainer,
2529
);
2630

2731
public previewInformationSection = this.getChildElementBySelector(
28-
ApplicationPreviewSelector.previewInformationSection,
32+
AppEditorGeneralInfoPreviewSelectors.previewInformationSection,
2933
);
3034

3135
public previewAuthorContainer =
3236
this.previewInformationSection.getChildElementBySelector(
33-
ApplicationPreviewSelector.previewAuthorContainer,
37+
AppEditorGeneralInfoPreviewSelectors.previewAuthorContainer,
3438
);
3539

3640
public previewAuthorValue =
3741
this.previewAuthorContainer.getChildElementBySelector(
38-
ApplicationPreviewSelector.previewAuthorValue,
42+
AppEditorGeneralInfoPreviewSelectors.previewAuthorValue,
3943
);
4044

4145
public topicElements = this.previewTopicsContainer.getChildElementBySelector(

apps/chat-e2e/src/ui/webElements/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ export * from './messageTemplateModal';
5959
export * from './appEditor/appEditorContainer';
6060
export * from './appEditor/appEditorHeader';
6161
export * from './appEditor/appEditorGeneralForm';
62-
export * from './appEditor/appEditorPreview';
62+
export * from './appEditor/appEditorGeneralInfoAgentPreview';
63+
export * from './appEditor/appEditorAppSettingsAgentPreview';
6364
export * from './appEditor/appEditorViewForm';
6465
export * from './notFound';

apps/chat/src/components/AppsEditor/Settings/index.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,7 @@ export const ApplicationSettings: React.FC<Props> = ({
321321
'w-0 overflow-hidden opacity-0': previewMode === PreviewMode.closed,
322322
},
323323
)}
324+
data-qa="app-preview-settings"
324325
>
325326
<div className="flex max-w-full items-center justify-between p-2">
326327
<div className="mr-2 flex min-w-0 shrink grow gap-2 text-primary">

0 commit comments

Comments
 (0)