1
1
import { expect , takeSnapshot , test } from "@chromatic-com/playwright"
2
2
import { Page } from "@playwright/test"
3
3
4
- import { breakpointAsNumber } from "@/lib/utils/screen"
5
-
6
4
import { DEFAULT_LOCALE } from "@/lib/constants"
7
5
8
6
import { testData } from "./fixtures/testData"
@@ -58,7 +56,6 @@ test.describe("Global", () => {
58
56
} )
59
57
60
58
test ( "switches to Chinese (mobile)" , async ( { page } ) => {
61
- await page . setViewportSize ( { width : breakpointAsNumber . sm , height : 800 } )
62
59
const isMobile = await homePage . isMobileViewport ( )
63
60
test . skip ( ! isMobile , "This test is for mobile viewports only" )
64
61
@@ -73,11 +70,12 @@ test.describe("Global", () => {
73
70
74
71
test . beforeEach ( async ( { page } ) => {
75
72
homePage = new HomePage ( page )
73
+ await waitForPageReady ( page )
76
74
} )
77
75
78
76
async function switchToArabic ( page : Page , homePage : HomePage ) {
79
77
await homePage . switchToLanguage ( "ar" , / ^ ا ل ع ر ب ي ة A r a b i c / i)
80
- await expect ( page ) . toHaveURL ( / \/ a r ( \/ | $ ) / )
78
+ await homePage . assertUrlMatches ( / \/ a r ( \/ | $ ) / )
81
79
await expect (
82
80
page . getByRole ( "heading" , { level : 1 , name : / إ ي ث ر ي و م / i } )
83
81
) . toBeVisible ( )
@@ -95,12 +93,12 @@ test.describe("Global", () => {
95
93
await homePage . goto ( )
96
94
await waitForPageReady ( page )
97
95
98
- await expect ( page ) . toHaveURL ( `/${ DEFAULT_LOCALE } /` )
96
+ await homePage . assertUrlMatches ( `/${ DEFAULT_LOCALE } /` )
99
97
100
98
await homePage . openLanguagePickerDesktop ( )
101
99
await switchToArabic ( page , homePage )
102
100
103
- await expect ( page ) . toHaveURL ( / \/ a r ( \/ | $ ) / )
101
+ await homePage . assertUrlMatches ( / \/ a r ( \/ | $ ) / )
104
102
105
103
const logo = page . getByTestId ( "nav-logo" )
106
104
const searchBtn = page . getByTestId ( "search-input-button" )
0 commit comments