1- import { test as base , expect , type APIRequestContext , type Page , type Response } from '@playwright/test' ;
1+ import { test as base , expect , type APIRequestContext , type Page , type Request , type Response } from '@playwright/test' ;
22
33/**
44 * Live e2e for the ADR-0146 customization journey, walked through the Studio
@@ -12,9 +12,10 @@ import { test as base, expect, type APIRequestContext, type Page, type Response
1212 * type's list) — not what the canvas draws.
1313 * 2. Restore package original: the pair's draft and row are deleted at the
1414 * pair, and the three reads serve the shipped column set again.
15- * 3. Add `region__c`: Add field on the base object's Form writes an
16- * `object_extension` into the pair; once published, the base object is
17- * served with the field and the pair's own read and export carry it.
15+ * 3. Add `region__c`: Add field on the base object's Form, then the top
16+ * bar's Save (objectstack#36511), writes an `object_extension` into the
17+ * pair and publishes that one item there, so the base object is served
18+ * with the field at once and the pair's own read and export carry it.
1819 * 4. Uninstall the base: the uninstall door refuses the read-only showcase
1920 * with 422 `WRITABLE_PACKAGE_REQUIRED` and removes nothing. This is the
2021 * refusal `main` answers here, and the one asserted: `DELETE
@@ -230,19 +231,45 @@ test('a read-only base is customized, restored and extended through Studio, and
230231 await page . getByTestId ( 'add-field-label-input' ) . fill ( FIELD . label ) ;
231232 await expect ( page . getByTestId ( 'add-field-api-name-preview' ) ) . toContainText ( FIELD . name ) ;
232233
234+ // objectstack#36511 — the add stays on the page until the top bar's
235+ // Save: no write of the extension leaves before it is pressed.
236+ const extensionWrites : string [ ] = [ ] ;
237+ const onRequest = ( r : Request ) => {
238+ if ( r . method ( ) !== 'GET' && r . url ( ) . includes ( `/api/v1/meta/object_extension/${ OBJECT } ` ) ) {
239+ extensionWrites . push ( `${ r . method ( ) } ${ r . url ( ) } ` ) ;
240+ }
241+ } ;
242+ page . on ( 'request' , onRequest ) ;
243+ await page . getByTestId ( 'add-field-create' ) . click ( ) ;
244+ await expect ( page . getByTestId ( 'studio-save' ) ) . toBeVisible ( ) ;
245+ expect ( extensionWrites ) . toEqual ( [ ] ) ;
246+
247+ // Save writes the extension's draft into the pair, then publishes that
248+ // one item there: live at once, with no package publish.
233249 const drafted = page . waitForResponse (
234250 ( r ) => r . request ( ) . method ( ) === 'PUT' && r . url ( ) . includes ( `/api/v1/meta/object_extension/${ OBJECT } ?` ) ,
235251 ) ;
236- await page . getByTestId ( 'add-field-create' ) . click ( ) ;
252+ const published = page . waitForResponse (
253+ ( r ) => r . request ( ) . method ( ) === 'POST' && r . url ( ) . includes ( `/api/v1/meta/object_extension/${ OBJECT } /publish` ) ,
254+ ) ;
255+ await page . getByTestId ( 'studio-save' ) . click ( ) ;
237256 const draft = await drafted ;
238257 expect ( draft . ok ( ) , await draft . text ( ) ) . toBeTruthy ( ) ;
239258 expect ( new URL ( draft . url ( ) ) . searchParams . get ( 'package' ) ) . toBe ( PAIR ) ;
259+ expect ( new URL ( draft . url ( ) ) . searchParams . get ( 'mode' ) ) . toBe ( 'draft' ) ;
240260 expect ( draft . request ( ) . postDataJSON ( ) ) . toEqual ( {
241261 extend : OBJECT ,
242262 fields : { [ FIELD . name ] : { type : 'text' , label : FIELD . label } } ,
243263 } ) ;
244-
245- await publishPair ( page ) ;
264+ const publish = await published ;
265+ expect ( publish . ok ( ) , await publish . text ( ) ) . toBeTruthy ( ) ;
266+ expect ( new URL ( publish . url ( ) ) . searchParams . get ( 'package' ) ) . toBe ( PAIR ) ;
267+ // The Save left nothing to save, and no draft for the package publish.
268+ await expect ( page . getByTestId ( 'studio-save' ) ) . toHaveCount ( 0 ) ;
269+ page . off ( 'request' , onRequest ) ;
270+ expect ( extensionWrites . map ( ( w ) => w . split ( ' ' ) [ 0 ] ) ) . toEqual ( [ 'PUT' , 'POST' ] ) ;
271+ const pending = await request . get ( `${ API } /api/v1/meta/object_extension/${ OBJECT } ?state=draft&package=${ PAIR } ` ) ;
272+ expect ( pending . status ( ) , await pending . text ( ) ) . toBe ( 404 ) ;
246273 const object = await request . get ( `${ API } /api/v1/meta/object/${ OBJECT } ` ) ;
247274 expect ( object . ok ( ) , await object . text ( ) ) . toBeTruthy ( ) ;
248275 const objectBody = await object . json ( ) ;
0 commit comments