alxndrsn commented on code in PR #9212:
URL: https://github.com/apache/pouchdb/pull/9212#discussion_r3073233932
##########
tests/multitab/user_agent.js:
##########
@@ -0,0 +1,53 @@
+'use strict';
+
+const playwright = require('playwright');
+
+const ADAPTERS = process.env.ADAPTERS || 'indexeddb';
+const CLIENT = process.env.CLIENT || 'firefox';
+const SHELL_URL = 'http://127.0.0.1:8000/tests/multitab/shell.html';
+
+class UserAgent {
+ static async start() {
+ let browser = await playwright[CLIENT].launch();
+ let context = await browser.newContext();
+ return new UserAgent(ADAPTERS, browser, context);
+ }
+
+ constructor(adapter, browser, context) {
+ this._adapter = adapter;
+ this._browser = browser;
+ this._context = context;
+ this._pages = new Map();
+ }
+
+ async stop() {
+ await this._browser.close();
+ }
+
+ async eval(pageId, fn) {
+ let page = await this._getPage(pageId);
+ return page.evaluate(fn);
+ }
+
+ _getPage(id) {
+ if (!this._pages.has(id)) {
+ this._pages.set(id, this._setupPage());
+ }
+ return this._pages.get(id);
+ }
+
+ async _setupPage() {
+ let page = await this._context.newPage();
+ await page.goto(SHELL_URL);
+
+ if (this._adapter === 'idb') {
+ await page.evaluate(() => window.__pouch__ = new PouchDB('testdb', {
adapter: 'idb' }));
+ } else if (this._adapter === 'indexeddb') {
+ await page.evaluate(() => window.__pouch__ = new PouchDB('testdb', {
adapter: 'indexeddb' }));
+ }
Review Comment:
It definitely seems reasonable to run all browser-based adapters, although
you may uncover more bugs :face_with_peeking_eye:
If that's the case, I'd skip those tests for now, and create separate issues.
Either way I think it's helpful for this setup to throw a clear error if
asked to initialise an adapter that it doesn't have code for.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]