File tree Expand file tree Collapse file tree 2 files changed +39
-0
lines changed Expand file tree Collapse file tree 2 files changed +39
-0
lines changed Original file line number Diff line number Diff line change 1
1
import { CartDropdown } from "./cart-dropdown"
2
2
import { NavMenu } from "./nav-menu"
3
3
import { Page , Locator } from "@playwright/test"
4
+ import { SearchModal } from "./search-modal"
4
5
5
6
export class BasePage {
6
7
page : Page
7
8
navMenu : NavMenu
8
9
cartDropdown : CartDropdown
10
+ searchModal : SearchModal
9
11
accountLink : Locator
10
12
searchLink : Locator
11
13
storeLink : Locator
@@ -15,6 +17,7 @@ export class BasePage {
15
17
this . page = page
16
18
this . navMenu = new NavMenu ( page )
17
19
this . cartDropdown = new CartDropdown ( page )
20
+ this . searchModal = new SearchModal ( page )
18
21
this . accountLink = page . getByTestId ( "nav-account-link" )
19
22
this . storeLink = page . getByTestId ( "nav-store-link" )
20
23
this . searchLink = page . getByTestId ( "nav-search-link" )
Original file line number Diff line number Diff line change
1
+ import { Page , Locator } from "@playwright/test"
2
+ import { BaseModal } from "./base-modal"
3
+ import { NavMenu } from "./nav-menu"
4
+
5
+ export class SearchModal extends BaseModal {
6
+ searchInput : Locator
7
+ searchResults : Locator
8
+ noSearchResultsContainer : Locator
9
+ searchResult : Locator
10
+ searchResultTitle : Locator
11
+
12
+ constructor ( page : Page ) {
13
+ super ( page , page . getByTestId ( "search-modal-container" ) )
14
+ this . searchInput = this . container . getByTestId ( "search-input" )
15
+ this . searchResults = this . container . getByTestId ( "search-results" )
16
+ this . noSearchResultsContainer = this . container . getByTestId (
17
+ "no-search-results-container"
18
+ )
19
+ this . searchResult = this . container . getByTestId ( "search-result" )
20
+ this . searchResultTitle = this . container . getByTestId ( "search-result-title" )
21
+ }
22
+
23
+ async open ( ) {
24
+ const menu = new NavMenu ( this . page )
25
+ await menu . open ( )
26
+ await menu . searchLink . click ( )
27
+ await this . container . waitFor ( { state : "visible" } )
28
+ }
29
+
30
+ async close ( ) {
31
+ const viewport = this . page . viewportSize ( )
32
+ const y = viewport ? viewport . height / 2 : 100
33
+ await this . page . mouse . click ( 1 , y , { clickCount : 2 , delay : 100 } )
34
+ await this . container . waitFor ( { state : "hidden" } )
35
+ }
36
+ }
You can’t perform that action at this time.
0 commit comments