-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
49 additions
and
5 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
const puppeteer = require('puppeteer'); | ||
const { EXTENSION_PATH, EXTENSION_ID } = require('./util'); | ||
|
||
let browser; | ||
|
||
beforeEach(async () => { | ||
browser = await puppeteer.launch({ | ||
headless: false, | ||
args: [ | ||
`--disable-extensions-except=${EXTENSION_PATH}`, | ||
`--load-extension=${EXTENSION_PATH}`, | ||
], | ||
}); | ||
}); | ||
|
||
afterEach(async () => { | ||
await browser.close(); | ||
browser = undefined; | ||
}); | ||
|
||
test('test auth redirect correctly', async () => { | ||
const page = await browser.newPage(); | ||
await page.goto(`chrome-extension://${EXTENSION_ID}/index.html#/popup`); | ||
await page.waitForSelector('button', { timeout: 5000 }); | ||
|
||
// Use evaluate to set token in browser.storage.local | ||
await page.evaluate(() => { | ||
chrome.storage.local.set({ auth_flow_active: 'true' }); | ||
chrome.storage.local.set({ token: 'mock token' }); | ||
}); | ||
|
||
// Wait for the redirect | ||
await page.waitForFunction( | ||
() => window.location.hash === '#/auth-redirect', // Use hash to check redirect | ||
{ timeout: 10000 } | ||
); | ||
|
||
await browser.close(); | ||
}); |
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,4 @@ | ||
const EXTENSION_PATH = '../dist'; | ||
const EXTENSION_ID = 'bnhhcpdgpabghbipjeocenbhompjlmll'; | ||
|
||
module.exports = { EXTENSION_PATH, EXTENSION_ID }; |