mirror of
https://github.com/usebruno/bruno.git
synced 2026-06-11 09:51:30 +00:00
45 lines
1.7 KiB
TypeScript
45 lines
1.7 KiB
TypeScript
import { test, expect, closeElectronApp } from '../../playwright';
|
||
import { waitForReadyPage } from '../utils/page';
|
||
|
||
test('should persist cookies across app restarts', async ({ createTmpDir, launchElectronApp }) => {
|
||
// Create a temporary user-data directory so we control where the cookies store file is written.
|
||
const userDataPath = await createTmpDir('cookie-persistence');
|
||
|
||
const app1 = await launchElectronApp({ userDataPath });
|
||
const page1 = await waitForReadyPage(app1);
|
||
await page1.waitForSelector('[data-trigger="cookies"]');
|
||
|
||
// Open Cookies modal via the status-bar button.
|
||
await page1.click('[data-trigger="cookies"]');
|
||
|
||
// When no cookies are present the modal shows a centred "Add Cookie" button.
|
||
await page1.getByRole('button', { name: /Add Cookie/i }).click();
|
||
|
||
// Fill out the form.
|
||
await page1.fill('input[name="domain"]', 'example.com');
|
||
await page1.fill('input[name="path"]', '/');
|
||
await page1.fill('input[name="key"]', 'session');
|
||
await page1.fill('input[name="value"]', 'abc123');
|
||
await page1.check('input[name="secure"]');
|
||
await page1.check('input[name="httpOnly"]');
|
||
|
||
await page1.getByRole('button', { name: 'Save' }).click();
|
||
|
||
await expect(page1.getByText('example.com')).toBeVisible();
|
||
|
||
await closeElectronApp(app1);
|
||
|
||
// Second launch – verify the cookie was persisted and re-loaded
|
||
const app2 = await launchElectronApp({ userDataPath });
|
||
const page2 = await waitForReadyPage(app2);
|
||
|
||
// Open the Cookies modal again.
|
||
await page2.waitForSelector('[data-trigger="cookies"]');
|
||
await page2.click('[data-trigger="cookies"]');
|
||
|
||
// The domain we added earlier should still be present.
|
||
await expect(page2.getByText('example.com')).toBeVisible();
|
||
|
||
await closeElectronApp(app2);
|
||
});
|