@@ -2,6 +2,7 @@ import {sleep} from 'common/util/time'
22
33import { TEST_USER_DISPLAY_NAME } from '../../utils/seedDatabase'
44import { expect , test } from '../fixtures/signInFixture'
5+ import { getCardAgeGender , getCardName , getCardSeekingInfo , getCardStar } from '../pages/peoplePage'
56
67test . describe ( 'when given valid input' , ( ) => {
78 test ( 'should be able to sign in to an available account' , async ( {
@@ -17,11 +18,13 @@ test.describe('when given valid input', () => {
1718 await app . signinWithEmail ( account )
1819 await app . home . clickPeopleLink ( )
1920 const profile = await app . people . getProfileInfo ( )
20- await expect ( profile . star ) . toBeVisible ( )
21- await profile . star . click ( )
21+ const star = await getCardStar ( profile )
22+ const name = await getCardName ( profile )
23+ await expect ( star ) . toBeVisible ( )
24+ await star . click ( )
2225 await sleep ( 1000 )
2326 await app . people . clickSavedPeopleButton ( )
24- await app . people . verifySavedPerson ( profile . name )
27+ await app . people . verifySavedPerson ( name )
2528 } )
2629
2730 test . describe ( 'the applied filter should' , ( ) => {
@@ -42,9 +45,10 @@ test.describe('when given valid input', () => {
4245 Number ( filteredProfiles ?. split ( ' ' ) [ 0 ] ) ,
4346 )
4447
45- const results = await app . people . getProfileInfo ( )
46- if ( ! results ) return
47- await expect ( results . seeking ) . toContain ( 'Collaboration' )
48+ const profile = await app . people . getProfileInfo ( )
49+ if ( ! profile ) throw new Error ( 'No profile found' )
50+ const seeking = await getCardSeekingInfo ( profile )
51+ await expect ( seeking ) . toContain ( 'Collaboration' )
4852 } )
4953
5054 /**
@@ -57,17 +61,19 @@ test.describe('when given valid input', () => {
5761 await app . people . setDisplayFilter ( { filters : { Age : true } } )
5862
5963 const totalProfiles = await app . people . profileCountLocator . textContent ( )
60- const profileResults = await app . people . getProfileInfo ( )
61- const profileAge = parseInt ( profileResults . ageGender . match ( / \d + / ) ?. [ 0 ] ?? '0' )
64+ const profile = await app . people . getProfileInfo ( )
65+ const ageGender = await getCardAgeGender ( profile )
66+ if ( ! ageGender ) throw new Error ( 'Age not found' )
67+ const profileAge = parseInt ( ageGender . match ( / \d + / ) ?. [ 0 ] ?? '0' )
6268 const age = profileAge <= 60 ? profileAge : 60
63- console . log ( profileResults , age )
69+ console . log ( profile , age )
6470
6571 await app . people . setAgeRangeFilter ( { min : String ( age ) , max : String ( age ) } )
6672
67- const filterdProfiles = await app . people . profileCountLocator . textContent ( )
73+ const filteredProfiles = await app . people . profileCountLocator . textContent ( )
6874
69- if ( ! totalProfiles || ! filterdProfiles ) return
70- await expect ( parseInt ( totalProfiles ) ) . not . toEqual ( parseInt ( filterdProfiles ) )
75+ if ( ! totalProfiles || ! filteredProfiles ) return
76+ await expect ( parseInt ( totalProfiles ) ) . not . toEqual ( parseInt ( filteredProfiles ) )
7177 } )
7278
7379 test ( 'show profiles with the correct gender' , async ( { app, signedOutAccount : account } ) => {
@@ -185,36 +191,41 @@ test.describe('when given valid input', () => {
185191 await app . home . clickPeopleLink ( )
186192 await app . people . useSearch ( TEST_USER_DISPLAY_NAME )
187193 await sleep ( 1000 )
188- const results = await app . people . getProfileInfo ( )
189- console . log ( results )
190- const hideProfileButton = await results . profile . getByRole ( 'button' , {
194+ const profile = await app . people . getProfileInfo ( )
195+ if ( ! profile ) throw new Error ( 'Profile not found' )
196+ const name = await getCardName ( profile )
197+ console . log ( profile )
198+ const hideProfileButton = profile . getByRole ( 'button' , {
191199 name : 'Hide this profile' ,
192200 } )
193201 await expect ( hideProfileButton ) . toBeVisible ( )
194202 await hideProfileButton . click ( )
195203 await expect (
196- app . page . getByText ( `You won't see ${ results . name } in your search results anymore.` ) ,
204+ app . page . getByText ( `You won't see ${ name } in your search results anymore.` ) ,
197205 ) . toBeVisible ( )
198206 } )
199207
200208 test ( 'should be reversible using undo' , async ( { app, signedOutAccount : account } ) => {
201209 await app . signinWithEmail ( account )
202210 await app . home . clickPeopleLink ( )
203- const results = await app . people . getProfileInfo ( )
204- if ( ! results ) return
205- const hideProfileButton = await results . profile . getByRole ( 'button' , {
211+ await app . people . useSearch ( TEST_USER_DISPLAY_NAME )
212+ await sleep ( 1000 )
213+ const profile = await app . people . getProfileInfo ( )
214+ if ( ! profile ) throw new Error ( 'Profile not found' )
215+ const name = await getCardName ( profile )
216+ const hideProfileButton = profile . getByRole ( 'button' , {
206217 name : 'Hide this profile' ,
207218 } )
208219 await expect ( hideProfileButton ) . toBeVisible ( )
209220 await hideProfileButton . click ( )
210- const hideProfileMessage = await app . page . getByText (
211- `You won't see ${ results . name } in your search results anymore.` ,
221+ const hideProfileMessage = app . page . getByText (
222+ `You won't see ${ name } in your search results anymore.` ,
212223 )
213224 await expect ( hideProfileMessage ) . toBeVisible ( )
214225 await app . people . page . getByRole ( 'button' , { name : 'Undo' } ) . click ( )
215226 await expect ( hideProfileMessage ) . not . toBeVisible ( )
216- const profile = await app . people . page . getByRole ( 'heading' , { name : `${ results . name } ` } )
217- await expect ( profile ) . toBeVisible ( )
227+ const undoProfile = app . people . page . getByRole ( 'heading' , { name : `${ name } ` } )
228+ await expect ( undoProfile ) . toBeVisible ( )
218229 } )
219230
220231 test ( 'should be reversible using manage hidden profiles feature in settings' , async ( {
@@ -223,25 +234,29 @@ test.describe('when given valid input', () => {
223234 } ) => {
224235 await app . signinWithEmail ( account )
225236 await app . home . clickPeopleLink ( )
226- const results = await app . people . getProfileInfo ( )
227- if ( ! results ) return
228- const hideProfileButton = await results . profile . getByRole ( 'button' , {
237+ await app . people . useSearch ( TEST_USER_DISPLAY_NAME )
238+ await sleep ( 1000 )
239+ const profile = await app . people . getProfileInfo ( )
240+ if ( ! profile ) throw new Error ( 'Profile not found' )
241+ const name = await getCardName ( profile )
242+ if ( ! name ) throw new Error ( 'Name not found' )
243+ const hideProfileButton = profile . getByRole ( 'button' , {
229244 name : 'Hide this profile' ,
230245 } )
231246 await expect ( hideProfileButton ) . toBeVisible ( )
232247 await hideProfileButton . click ( )
233- const hideProfileMessage = await app . page . getByText (
234- `You won't see ${ results . name } in your search results anymore.` ,
248+ const hideProfileMessage = app . page . getByText (
249+ `You won't see ${ name } in your search results anymore.` ,
235250 )
236251 await expect ( hideProfileMessage ) . toBeVisible ( )
237252 await app . home . clickSettingsLink ( )
238253 await app . settings . clickManageHiddenProfilesButton ( )
239- await app . settings . verifyHiddenProfiles ( [ results . name ] )
240- await app . settings . unhideProfiles ( results . name )
254+ await app . settings . verifyHiddenProfiles ( [ name ] )
255+ await app . settings . unhideProfiles ( name )
241256 await app . settings . clickCloseButton ( )
242257 await app . home . clickPeopleLink ( )
243- const profile = await app . people . page . getByRole ( 'heading' , { name : `${ results . name } ` } )
244- await expect ( profile ) . toBeVisible ( )
258+ const undoProfile = app . people . page . getByRole ( 'heading' , { name : `${ name } ` } )
259+ await expect ( undoProfile ) . toBeVisible ( )
245260 } )
246261 } )
247262
@@ -252,7 +267,7 @@ test.describe('when given valid input', () => {
252267 signedInAccount : sender ,
253268 signedOutAccount : receiver ,
254269 } ) => {
255- const receiverApp = await app . contextManager . createContext ( )
270+ const receiverApp = await app . contextManager ! . createContext ( )
256271 await receiverApp . signinWithEmail ( receiver )
257272
258273 await app . home . clickMessagesLink ( )
@@ -269,7 +284,7 @@ test.describe('when given valid input', () => {
269284 signedInAccount : sender ,
270285 signedOutAccount : receiver ,
271286 } ) => {
272- const receiverApp = await app . contextManager . createContext ( )
287+ const receiverApp = await app . contextManager ! . createContext ( )
273288 await receiverApp . signinWithEmail ( receiver )
274289
275290 // To pass the min character limit for message intro (250 chars)
0 commit comments