yanweiyuan3
2023-08-09 588bc7829387dfc761cc25f06f77d4c81818bd10
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
/**
 * @file Collapsible form component base class (e.g. side panel)
 * @description Component extended from CollapsibleForm with additional methods
 * @author      Adrian Foo (adrian.foo@3ds.com), Wong Jia Hui (jiahui.wong@3ds.com)
 * @copyright   Dassault Systèmes
 */
import { Form } from '../e2elib/lib/src/pageobjects/form.component';
 
export class CollapsibleForm extends Form {
  /**
   * @override To include checking whether the form is not collapse before execute collapse action
   */
  public async collapse(): Promise<void> {
    const isFormCollapse = await this.isCollapse();
 
    if (!isFormCollapse) {
      await super.collapse();
    }
  }
 
  /**
   * @override To include checking whether the form is docked before execute the dock action
   */
  public async dock(): Promise<void> {
    const isOpen = await this.isOpen();
    const isDocked = await this.isdocked();
 
    if (isOpen && !isDocked) {
      await super.dock();
    }
  }
 
  /**
   * @override
   */
  public async isFocused(): Promise<boolean> {
    try {
      const isFocused = await super.isFocused();
      return isFocused;
    } catch {
      return false;
    }
  }
 
  /**
   * @override To include checking whether the form is collapse before execute restore action
   */
  public async restore(): Promise<void> {
    const isFormCollapse = await this.isCollapse();
    const isFocused = await this.isFocused();
 
    if (isFormCollapse || !isFocused) {
      await super.restore();
    }
    await this.waitUntilPresent();
  }
}