-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathai-assistant.page.ts
More file actions
59 lines (49 loc) · 2.17 KB
/
ai-assistant.page.ts
File metadata and controls
59 lines (49 loc) · 2.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
import { Page, Locator } from '@playwright/test';
/**
* AI Assistant Page Object
*
* Encapsulates locators and interactions for the AI Assistant page at /ai/assistant.
* Handles both enabled state (chat UI) and disabled state (info banner).
*/
export class AiAssistantPage {
readonly page: Page;
readonly url = '/ai/assistant';
// ── Disabled state ────────────────────────────────────────────────────────
readonly disabledBanner: Locator;
// ── Enabled state — chat UI ───────────────────────────────────────────────
readonly chatCard: Locator;
readonly messageInput: Locator;
readonly sendButton: Locator;
readonly clearButton: Locator;
readonly messages: Locator;
readonly loadingRow: Locator;
readonly errorRow: Locator;
readonly emptyState: Locator;
constructor(page: Page) {
this.page = page;
this.disabledBanner = page.locator('.ai-disabled-banner, .disabled-card').first();
this.chatCard = page.locator('mat-card').first();
this.messageInput = page.locator('input[placeholder*="AI assistant"], input[placeholder*="anything"]').first();
this.sendButton = page.locator('button').filter({ hasText: /^send$/i }).first();
this.clearButton = page.locator('button[mat-icon-button]').filter({ hasText: /delete_sweep/i }).first();
this.messages = page.locator('.message');
this.loadingRow = page.locator('.loading-row');
this.errorRow = page.locator('.error-row');
this.emptyState = page.locator('.empty-state');
}
async goto() {
await this.page.goto(this.url);
await this.page.waitForLoadState('networkidle');
}
async isDisabled(): Promise<boolean> {
return await this.disabledBanner.isVisible({ timeout: 3000 }).catch(() => false);
}
async sendMessage(message: string) {
await this.messageInput.fill(message);
await this.page.keyboard.press('Enter');
await this.page.waitForTimeout(500);
}
async getMessageCount(): Promise<number> {
return await this.messages.count();
}
}