@@ -31,6 +31,8 @@ import {
3131 signIn ,
3232 timestamp ,
3333 waitForCommit ,
34+ openAgentPage ,
35+ fillSearchBox ,
3436} from './test-utils' ;
3537
3638test . describe ( 'data-browser' , async ( ) => {
@@ -62,7 +64,7 @@ test.describe('data-browser', async () => {
6264 } ) ;
6365
6466 // Sign out
65- await page . click ( 'text=user settings' ) ;
67+ await openAgentPage ( page ) ;
6668 await page . click ( '[data-test="sign-out"]' ) ;
6769 await expect ( page . locator ( 'text=Enter your Agent secret' ) ) . toBeVisible ( ) ;
6870 await page . reload ( ) ;
@@ -249,9 +251,6 @@ test.describe('data-browser', async () => {
249251 await page2 . keyboard . press ( 'Enter' ) ;
250252 // Both pages should see then new chat message
251253 await expect ( page . locator ( `text=${ teststring2 } ` ) ) . toBeVisible ( ) ;
252- // TODO: get rid of this reload! It should not be necessary
253- // For some reason the page does not see the new message
254- await page2 . reload ( ) ;
255254 await expect ( page2 . locator ( `text=${ teststring2 } ` ) ) . toBeVisible ( ) ;
256255 } ) ;
257256
@@ -342,7 +341,7 @@ test.describe('data-browser', async () => {
342341 // await expect(page.locator(currentDriveTitle)).toHaveText('Atomic Data');
343342
344343 // Cleanup drives for signed in user
345- await page . click ( 'text=user settings' ) ;
344+ await openAgentPage ( page ) ;
346345 await page . click ( 'text=Edit profile' ) ;
347346 await page . click ( '[data-test="input-drives-clear"]' ) ;
348347 await page . click ( '[data-test="save"]' ) ;
@@ -376,35 +375,24 @@ test.describe('data-browser', async () => {
376375 const shortnameInput = '[data-test="input-shortname"]' ;
377376 // Try entering a wrong slug
378377 await page . click ( shortnameInput ) ;
379- await page . keyboard . type ( 'not valid' ) ;
380- await expect ( page . locator ( 'text=Not a valid slug' ) ) . toBeVisible ( ) ;
378+ await page . keyboard . type ( 'not valid-' ) ;
379+ await page . locator ( shortnameInput ) . blur ( ) ;
380+ await expect ( page . getByText ( 'Invalid Slug' ) ) . toBeVisible ( ) ;
381381 await page . locator ( shortnameInput ) . fill ( '' ) ;
382382 await page . keyboard . type ( 'is-valid' ) ;
383383 await expect ( page . locator ( 'text=Not a valid slug' ) ) . not . toBeVisible ( ) ;
384384
385- // Add a new property
386- const input = page . locator (
387- '[placeholder="Select a property or enter a property URL..."]' ,
385+ await fillSearchBox (
386+ page ,
387+ 'Search for a property or enter a URL' ,
388+ 'https://atomicdata.dev/properties/invite/usagesLeft' ,
388389 ) ;
389- await input . click ( ) ;
390-
391- await expect ( page . locator ( 'text=Create property:' ) ) . toBeVisible ( ) ;
392- await input . fill ( 'https://atomicdata.dev/properties/invite/usagesLeft' ) ;
393390 await page . keyboard . press ( 'Enter' ) ;
394- await page . click ( '[title="Add this property"]' ) ;
395391 await expect ( page . locator ( 'text=Usages-left' ) . first ( ) ) . toBeVisible ( ) ;
396392 // Integer validation
397393 await page . click ( '[data-test="input-usages-left"]' ) ;
398- await page . keyboard . type ( 'asdf' + '1 ') ;
394+ await page . keyboard . type ( 'asdf1 ' ) ;
399395 await expect ( page . locator ( 'text=asdf' ) ) . not . toBeVisible ( ) ;
400- // Dropdown select
401- await page . click ( '[data-test="input-recommends-add-resource"]' ) ;
402- await page . locator ( 'text=append' ) . click ( ) ;
403- await expect (
404- page . locator (
405- '[data-test="input-recommends"] >> text=https://atomicdata.dev' ,
406- ) ,
407- ) . not . toBeVisible ( ) ;
408396
409397 // Try to save without a description
410398 page . locator ( 'button:has-text("Save")' ) . click ( ) ;
@@ -505,20 +493,27 @@ test.describe('data-browser', async () => {
505493 . locator ( '[title="Add an item to the recommends list"]' )
506494 . first ( )
507495 . click ( ) ;
508- await page . locator ( '[data-test="input-recommends"]' ) . click ( ) ;
509- await page . locator ( '[data-test="input-recommends"]' ) . fill ( 'test-prop' ) ;
510496
511497 // Create new Property using dialog
512- await page . locator ( 'text=Create property: test-prop' ) . click ( ) ;
498+
499+ const clickOption = await fillSearchBox (
500+ page ,
501+ 'Search for a property or enter a URL' ,
502+ 'test-prop' ,
503+ { nth : 0 } ,
504+ ) ;
505+
506+ await clickOption ( 'Create test-prop' ) ;
507+
513508 await expect ( page . locator ( 'h1:has-text("new property")' ) ) . toBeVisible ( ) ;
514- await page . locator ( '[data-test="input- datatype"]' ) . click ( ) ;
515- // click twice, first click is buggy, it closes the dropdown from earlier
516- await page . locator ( '[data-test="input-datatype"]' ) . click ( ) ;
517- await page
518- . locator (
519- 'li:has-text(" boolean - Either `true` or `false`. In JSON-AD, th...") ',
520- )
521- . click ( ) ;
509+ // Set datatype of new property to boolean
510+
511+ const selectDatatypeOption = await fillSearchBox (
512+ page ,
513+ 'Search for a datatype or enter a URL' ,
514+ ' boolean',
515+ ) ;
516+ await selectDatatypeOption ( 'boolean - Either `true` or `false`' ) ;
522517 await page . locator ( 'dialog textarea[name="yamdeContent"]' ) . click ( ) ;
523518 await page
524519 . locator ( 'dialog textarea[name="yamdeContent"]' )
0 commit comments