@@ -3,7 +3,6 @@ const { test, expect, selectors, devices } = require('@playwright/test')
33const url = process . env . PLAYWRIGHT_TEST_URL
44 ? process . env . PLAYWRIGHT_TEST_URL . replace ( / [ ^ / ] $ / , '$&/' )
55 : 'https://git-scm.com/'
6- const isRailsApp = process . env . PLAYWRIGHT_ASSUME_RAILS_APP === 'true'
76
87// Whenever a test fails, attach a screenshot to diagnose failures better
98test . afterEach ( async ( { page } , testInfo ) => {
@@ -24,11 +23,7 @@ test.afterEach(async ({ page }, testInfo) => {
2423
2524test ( 'generator is Hugo' , async ( { page} ) => {
2625 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 / )
3227} )
3328
3429async function pretendPlatform ( page , browserName , userAgent , platform ) {
@@ -122,23 +117,31 @@ test('search', async ({ page }) => {
122117 await expect ( searchResults . getByRole ( "link" ) ) . not . toHaveCount ( 0 )
123118 await expect ( searchResults . getByRole ( "link" ) . nth ( 0 ) ) . toHaveText ( 'git-commit' )
124119
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+
125136 // On localized pages, the search results should be localized as well
126137 await page . goto ( `${ url } docs/git-commit/fr` )
127138 await searchBox . fill ( 'add' )
128139 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 ) ? $ / )
134141
135142 // pressing the Enter key should navigate to the full search results page
136143 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 / )
142145} )
143146
144147test ( 'manual pages' , async ( { page } ) => {
@@ -152,11 +155,7 @@ test('manual pages', async ({ page }) => {
152155 // Verify that the drop-downs are shown when clicked
153156 const previousVersionDropdown = page . locator ( '#previous-versions-dropdown' )
154157 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 ( )
160159 await expect ( previousVersionDropdown ) . toBeVisible ( )
161160
162161 const topicsDropdown = page . locator ( '#topics-dropdown' )
@@ -188,14 +187,8 @@ test('manual pages', async ({ page }) => {
188187 // Ensure that the French mis-translation of `git remote renom` is not present
189188 await page . goto ( `${ url } docs/git-remote/fr` )
190189 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 > / )
199192} )
200193
201194test ( 'book' , async ( { page } ) => {
@@ -245,12 +238,7 @@ test('book', async ({ page }) => {
245238
246239 // Navigate to a page whose URL contains a question mark
247240 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 / )
254242 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 / )
255243
256244 // the repository URL now points to the Azerbaijani translation
0 commit comments