Move fill local storage to driver

This commit is contained in:
HarelM
2026-07-09 14:11:49 +03:00
parent a9c3da0f40
commit cc317c20a1
2 changed files with 26 additions and 23 deletions
+25
View File
@@ -493,6 +493,31 @@ export class MaputnikDriver {
waitForExampleFileResponse: () => this.when.waitForResponse("example-style.json"),
clearLocalStorage: () => this.page.evaluate(() => window.localStorage.clear()),
/** fill localStorage until we get a QuotaExceededError */
fillLocalStorage: async () => {
await this.page.evaluate(() => {
let chunkSize = 1000;
const chunk = new Array(chunkSize).join("x");
let index = 0;
// Keep adding until we hit the quota
for (;;) {
try {
const key = `maputnik:fill-${index++}`;
window.localStorage.setItem(key, chunk);
} catch (e: any) {
// Verify it's a quota error
if (e.name === "QuotaExceededError") {
if (chunkSize <= 1) return;
chunkSize /= 2;
continue;
}
throw e; // Unexpected error
}
}
});
}
};
// ---- get -----------------------------------------------------------------
+1 -23
View File
@@ -391,29 +391,7 @@ describe("modals", () => {
test("handles quota exceeded error when opening style from URL", async ({ page }) => {
// Clear localStorage to start fresh
await when.clearLocalStorage();
// fill localStorage until we get a QuotaExceededError
await page.evaluate(() => {
let chunkSize = 1000;
const chunk = new Array(chunkSize).join("x");
let index = 0;
// Keep adding until we hit the quota
for (;;) {
try {
const key = `maputnik:fill-${index++}`;
window.localStorage.setItem(key, chunk);
} catch (e: any) {
// Verify it's a quota error
if (e.name === "QuotaExceededError") {
if (chunkSize <= 1) return;
chunkSize /= 2;
continue;
}
throw e; // Unexpected error
}
}
});
await when.fillLocalStorage();
// Open the style via URL input
await when.click("nav:open");