E2E/Playwright: Fix unclosed browser context around in Playwright (#35258)

* test: fix user details and attribute tests

* test: fix unclosed browser contexts
This commit is contained in:
sabril 2026-02-12 14:51:50 +08:00 committed by GitHub
parent 68c1c072dd
commit 671e2b7640
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -14,11 +14,10 @@ import {resolvePlaywrightPath} from './util';
export class TestBrowser {
readonly browser: Browser;
context: BrowserContext | null;
private contexts: BrowserContext[] = [];
constructor(browser: Browser) {
this.browser = browser;
this.context = null;
}
async login(user: UserProfile) {
@ -40,7 +39,7 @@ export class TestBrowser {
const threadsPage = new pages.ThreadsPage(page);
const contentReviewPage = new pages.ContentReviewPage(page);
this.context = context;
this.contexts.push(context);
return {
context,
@ -55,9 +54,10 @@ export class TestBrowser {
}
async close() {
if (this.context) {
await this.context.close();
for (const context of this.contexts) {
await context.close();
}
this.contexts = [];
}
}