@@ -3,7 +3,6 @@ const { test, expect, selectors, devices } = require('@playwright/test')
3
3
const url = process . env . PLAYWRIGHT_TEST_URL
4
4
? process . env . PLAYWRIGHT_TEST_URL . replace ( / [ ^ / ] $ / , '$&/' )
5
5
: 'https://git-scm.com/'
6
- const isRailsApp = process . env . PLAYWRIGHT_ASSUME_RAILS_APP === 'true'
7
6
8
7
// Whenever a test fails, attach a screenshot to diagnose failures better
9
8
test . afterEach ( async ( { page } , testInfo ) => {
@@ -24,11 +23,7 @@ test.afterEach(async ({ page }, testInfo) => {
24
23
25
24
test ( 'generator is Hugo' , async ( { page} ) => {
26
25
await page . goto ( url )
27
- if ( isRailsApp ) {
28
- await expect ( page . locator ( 'meta[name="generator"]' ) ) . toHaveCount ( 0 )
29
- } else {
30
- await expect ( page . locator ( 'meta[name="generator"]' ) ) . toHaveAttribute ( 'content' , / ^ H u g o / )
31
- }
26
+ await expect ( page . locator ( 'meta[name="generator"]' ) ) . toHaveAttribute ( 'content' , / ^ H u g o / )
32
27
} )
33
28
34
29
async function pretendPlatform ( page , browserName , userAgent , platform ) {
@@ -122,23 +117,31 @@ test('search', async ({ page }) => {
122
117
await expect ( searchResults . getByRole ( "link" ) ) . not . toHaveCount ( 0 )
123
118
await expect ( searchResults . getByRole ( "link" ) . nth ( 0 ) ) . toHaveText ( 'git-commit' )
124
119
120
+ // Expect the search page to show up
121
+ await searchBox . press ( 'Enter' )
122
+ await expect ( page ) . toHaveURL ( / \/ s e a r c h / )
123
+ const filters = await page . getByRole ( 'group' , { name : 'Filters' } )
124
+ await expect ( filters ) . toBeVisible ( )
125
+ await expect ( filters . filter ( { hasText : 'Category' } ) ) . toBeVisible ( )
126
+
127
+ await expect ( page . getByText ( / r e s u l t s f o r c o m m i t / ) ) . toContainText ( / ^ \d + r e s u l t s f o r c o m m i t $ / )
128
+
129
+ const searchLinks = await page
130
+ . getByRole ( 'listItem' )
131
+ . filter ( { has : page . getByRole ( 'link' , { name : 'commit' } ) } )
132
+ await expect ( searchLinks ) . not . toHaveCount ( 0 )
133
+
134
+ await expect ( page . getByRole ( 'button' , { name : 'Load more results' } ) ) . toBeVisible ( )
135
+
125
136
// On localized pages, the search results should be localized as well
126
137
await page . goto ( `${ url } docs/git-commit/fr` )
127
138
await searchBox . fill ( 'add' )
128
139
await searchBox . press ( 'Shift' )
129
- if ( isRailsApp ) {
130
- await expect ( searchResults . getByRole ( "link" ) . nth ( 0 ) ) . toHaveAttribute ( 'href' , / \/ d o c s \/ g i t - a d d $ / )
131
- } else {
132
- await expect ( searchResults . getByRole ( "link" ) . nth ( 0 ) ) . toHaveAttribute ( 'href' , / \/ d o c s \/ g i t - a d d \/ f r ( \. h t m l ) ? $ / )
133
- }
140
+ await expect ( searchResults . getByRole ( "link" ) . nth ( 0 ) ) . toHaveAttribute ( 'href' , / \/ d o c s \/ g i t - a d d \/ f r ( \. h t m l ) ? $ / )
134
141
135
142
// pressing the Enter key should navigate to the full search results page
136
143
await searchBox . press ( 'Enter' )
137
- if ( isRailsApp ) {
138
- await expect ( page ) . toHaveURL ( / \/ s e a r c h / )
139
- } else {
140
- await expect ( page ) . toHaveURL ( / \/ s e a r c h .* l a n g u a g e = f r / )
141
- }
144
+ await expect ( page ) . toHaveURL ( / \/ s e a r c h .* l a n g u a g e = f r / )
142
145
} )
143
146
144
147
test ( 'manual pages' , async ( { page } ) => {
@@ -152,11 +155,7 @@ test('manual pages', async ({ page }) => {
152
155
// Verify that the drop-downs are shown when clicked
153
156
const previousVersionDropdown = page . locator ( '#previous-versions-dropdown' )
154
157
await expect ( previousVersionDropdown ) . toBeHidden ( )
155
- if ( isRailsApp ) {
156
- await page . getByRole ( 'link' , { name : / V e r s i o n \d + \. \d + \. \d + / } ) . click ( )
157
- } else {
158
- await page . getByRole ( 'link' , { name : 'Latest version' } ) . click ( )
159
- }
158
+ await page . getByRole ( 'link' , { name : 'Latest version' } ) . click ( )
160
159
await expect ( previousVersionDropdown ) . toBeVisible ( )
161
160
162
161
const topicsDropdown = page . locator ( '#topics-dropdown' )
@@ -188,14 +187,8 @@ test('manual pages', async ({ page }) => {
188
187
// Ensure that the French mis-translation of `git remote renom` is not present
189
188
await page . goto ( `${ url } docs/git-remote/fr` )
190
189
const synopsis = page . locator ( 'xpath=//h2[contains(text(), "SYNOPSIS")]/following-sibling::*[1]' ) . first ( )
191
- if ( isRailsApp ) {
192
- // This is a bug in the Rails app, and it is unclear what the root cause is
193
- await expect ( synopsis ) . not . toHaveText ( / g i t r e m o t e r e n a m e .* < a n c i e n > < n o u v e a u > / )
194
- await expect ( synopsis ) . toHaveText ( / g i t r e m o t e r e n o m .* < a n c i e n > < n o u v e a u > / )
195
- } else {
196
- await expect ( synopsis ) . toHaveText ( / g i t r e m o t e r e n a m e .* < a n c i e n > < n o u v e a u > / )
197
- await expect ( synopsis ) . not . toHaveText ( / g i t r e m o t e r e n o m .* < a n c i e n > < n o u v e a u > / )
198
- }
190
+ await expect ( synopsis ) . toHaveText ( / g i t r e m o t e r e n a m e .* < a n c i e n > < n o u v e a u > / )
191
+ await expect ( synopsis ) . not . toHaveText ( / g i t r e m o t e r e n o m .* < a n c i e n > < n o u v e a u > / )
199
192
} )
200
193
201
194
test ( 'book' , async ( { page } ) => {
@@ -245,12 +238,7 @@ test('book', async ({ page }) => {
245
238
246
239
// Navigate to a page whose URL contains a question mark
247
240
await page . goto ( `${ url } book/az/v2/Başlanğıc-Git-Nədir?` )
248
- if ( isRailsApp ) {
249
- await expect ( page ) . toHaveURL ( / b o o k \/ a z \/ v 2 $ / )
250
- await page . goto ( `${ url } book/az/v2/Başlanğıc-Git-Nədir%3F` )
251
- } else {
252
- await expect ( page ) . toHaveURL ( / B a % C 5 % 9 F l a n % C 4 % 9 F % C 4 % B 1 c - G i t - N % C 9 % 9 9 d i r % 3 F / )
253
- }
241
+ await expect ( page ) . toHaveURL ( / B a % C 5 % 9 F l a n % C 4 % 9 F % C 4 % B 1 c - G i t - N % C 9 % 9 9 d i r % 3 F / )
254
242
await expect ( page . getByRole ( 'document' ) ) . toHaveText ( / S n a p s h o t ’ l a r , F ə r q l ə r Y o x / )
255
243
256
244
// the repository URL now points to the Azerbaijani translation
0 commit comments