-
-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Make e2e tests run headless * Update test workflow for running headless tests
- Loading branch information
1 parent
d812ad4
commit 9a55140
Showing
11 changed files
with
118 additions
and
263 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import { TargetType } from "puppeteer"; | ||
|
||
async function getServiceWorker() { | ||
const workerTarget = await browser.waitForTarget( | ||
(target) => target.type() === TargetType.SERVICE_WORKER | ||
); | ||
|
||
return (await workerTarget.worker())!; | ||
} | ||
|
||
/** | ||
* This is used to make headless testing possible. Because in Chrome for Testing | ||
* `document.execCommand` doesn't work we need a way to test without using the | ||
* real clipboard. It reads and writes from and to local storage. | ||
*/ | ||
export const storageClipboard = { | ||
async readText() { | ||
const worker = await getServiceWorker(); | ||
const { clipboard } = (await worker.evaluate(async () => | ||
chrome.storage.local.get("clipboard") | ||
)) as { clipboard: string }; | ||
|
||
return clipboard; | ||
}, | ||
async writeText(text: string) { | ||
const worker = await getServiceWorker(); | ||
|
||
await worker.evaluate(async (text) => { | ||
await chrome.storage.local.set({ clipboard: text }); | ||
}, text); | ||
}, | ||
}; | ||
|
||
export async function runTestRequest(request: string) { | ||
const worker = await getServiceWorker(); | ||
|
||
await worker.evaluate(async (request) => { | ||
await chrome.storage.local.set({ clipboard: request }); | ||
dispatchEvent(new CustomEvent("handle-test-request")); | ||
}, request); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.