To test interactions between different users (e.g., sharing an agent from User A to User B), you must manually create new browser contexts for each user within a single test.
Note: Because multi-user tests involve multiple browser instances interacting, you should set the test block to run sequentially using test.describe.configure({ mode: 'serial' }); to avoid race conditions during parallel execution.
import { TEST_USERS } from '../constants/test-users';
test.describe('Agent Sharing', () => {
// Ensure tests in this block run one after another
test.describe.configure({ mode: 'serial' });
test('user sharing workflow', async ({ browser }) => {
// User 1 setup
const user1Context = await browser.newContext({
storageState: TEST_USERS.editor.authFile,
});
const user1Page = await user1Context.newPage();
// ... User 1 performs actions ...
// User 2 setup
const user2Context = await browser.newContext({
storageState: TEST_USERS.editor2.authFile,
});
const user2Page = await user2Context.newPage();
// ... User 2 interacts with shared agent ...
});
});