@@ -80,6 +80,34 @@ test.describe('Share link and download', () => {
8080 await expect ( page . locator ( '[data-testid="item-net-price-input"]' ) . first ( ) ) . toHaveValue ( '150' ) ;
8181 } ) ;
8282
83+ test ( 'payment URL persists in shared URL' , async ( { page, context } ) => {
84+ await context . grantPermissions ( [ 'clipboard-read' , 'clipboard-write' ] ) ;
85+
86+ await page . locator ( '[data-testid="payment-url-input"]' ) . fill ( 'https://example.com/pay/invoice-123' ) ;
87+ await page . locator ( '[data-testid="share-invoice-link-button"]' ) . click ( ) ;
88+
89+ const toast = page . locator ( '[data-testid="toast"]' ) ;
90+ await expect ( toast ) . toContainText ( 'Invoice link copied to clipboard!' ) ;
91+ await expect ( toast ) . toHaveClass ( / s u c c e s s / ) ;
92+ await expect ( toast ) . not . toContainText ( 'QR code not included' ) ;
93+
94+ const sharedUrl = page . url ( ) ;
95+ await page . evaluate ( ( ) => localStorage . clear ( ) ) ;
96+ await page . goto ( sharedUrl ) ;
97+ await page . waitForSelector ( '[data-testid="items-container"]' ) ;
98+
99+ await expect ( page . locator ( '[data-testid="payment-url-input"]' ) ) . toHaveValue ( 'https://example.com/pay/invoice-123' ) ;
100+ } ) ;
101+
102+ test ( 'payment URL persists after reload' , async ( { page } ) => {
103+ await page . locator ( '[data-testid="payment-url-input"]' ) . fill ( 'https://example.com/pay/reload-test' ) ;
104+ await page . waitForTimeout ( 700 ) ;
105+ await page . reload ( ) ;
106+ await page . waitForSelector ( '[data-testid="items-container"]' ) ;
107+
108+ await expect ( page . locator ( '[data-testid="payment-url-input"]' ) ) . toHaveValue ( 'https://example.com/pay/reload-test' ) ;
109+ } ) ;
110+
83111 test ( 'share shows success toast' , async ( { page, context } ) => {
84112 await context . grantPermissions ( [ 'clipboard-read' , 'clipboard-write' ] ) ;
85113
@@ -112,6 +140,22 @@ test.describe('Share link and download', () => {
112140 expect ( filename ) . toMatch ( / \. p d f $ / ) ;
113141 } ) ;
114142
143+ test ( 'download with payment URL triggers PDF generation' , async ( { page } ) => {
144+ await page . locator ( '[data-testid="seller-name-input"]' ) . fill ( 'Test Seller' ) ;
145+ await page . locator ( '[data-testid="seller-email-input"]' ) . fill ( 'seller@test.com' ) ;
146+ await page . locator ( '[data-testid="seller-address-input"]' ) . fill ( '123 Test St' ) ;
147+ await page . locator ( '[data-testid="buyer-name-input"]' ) . fill ( 'Test Buyer' ) ;
148+ await page . locator ( '[data-testid="buyer-email-input"]' ) . fill ( 'buyer@test.com' ) ;
149+ await page . locator ( '[data-testid="buyer-address-input"]' ) . fill ( '456 Test Ave' ) ;
150+ await page . locator ( '[data-testid="payment-url-input"]' ) . fill ( 'https://example.com/pay/invoice-123' ) ;
151+
152+ const downloadPromise = page . waitForEvent ( 'download' ) ;
153+ await page . locator ( '[data-testid="download-invoice-button"]' ) . click ( ) ;
154+
155+ const download = await downloadPromise ;
156+ expect ( download . suggestedFilename ( ) ) . toMatch ( / \. p d f $ / ) ;
157+ } ) ;
158+
115159 test ( 'share with logo shows error toast' , async ( { page, context } ) => {
116160 await context . grantPermissions ( [ 'clipboard-read' , 'clipboard-write' ] ) ;
117161
0 commit comments