.agents/skills/scout-ui-testing/references/scout-browser-auth.md
Use the browserAuth fixture to authenticate UI tests without manual UI logins.
loginAsAdmin()loginAsPrivilegedUser()loginAsViewer()loginAs(role: string)loginWithCustomRole(role: KibanaRole)These methods are async and must be awaited.
import { tags } from '@kbn/scout'; // or the module's Scout package (e.g. @kbn/scout-search)
import { expect } from '@kbn/scout/ui'; // or '@kbn/scout-search/ui', etc.
import { test } from '../fixtures';
test.describe('my suite', { tag: tags.deploymentAgnostic }, () => {
test.beforeEach(async ({ browserAuth }) => {
await browserAuth.loginAsViewer();
});
test('does something', async ({ page }) => {
await expect(page.testSubj.locator('someElement')).toBeVisible();
});
});
Use loginWithCustomRole() for one-off permission sets. If a custom role is
used across multiple tests, extend the browserAuth fixture in the plugin's
test/scout*/ui/fixtures and add a helper like loginAsMyRole().