redux-devtools/extension/test/chrome/extension.spec.js
Nathan Bierema 83b2c19a11
Upgrade to Manifest V3 (#1714)
* Update Chrome manifest.json

* Remove use of window in background

* Test devpanel

* Inject pageScript using new API

* Keep connection from devpanel to background alive

* Keep connection from content script to background alive

* Replace page action with action

* Cleanup syncOptions

* Update options to not rely on background page access

* Start work on updating popup

* Updates

* Remove window

* Get opening in a separate window working

* Remove pageScriptWrap

* Add socket to panelStore

* Fix tests

* Try to use MV3 for Firefox

* Fix path

* Fix Chrome E2E tests

* Revert unintentional change

* Skip Electron tests for now

Looks like they're still working through stuff in https://github.com/electron/electron/issues/41613

* Better image centering

The Firefox popup did not like the old CSS. This is still not perfect, but it's better than it was.

* Create shaggy-taxis-cross.md
2024-08-17 19:11:46 +00:00

77 lines
2.2 KiB
JavaScript

import { resolve } from 'path';
import webdriver from 'selenium-webdriver';
import chrome from 'selenium-webdriver/chrome';
import { switchMonitorTests, delay } from '../utils/e2e';
const path = resolve(__dirname, '..', '..', 'dist');
const extensionId = 'lmhkpmbekcpmknklioeibfkpmmfibljd';
const actionsPattern =
/^@@INIT(.|\n)+@@reduxReactRouter\/routerDidChange(.|\n)+@@reduxReactRouter\/initRoutes(.|\n)+$/;
describe('Chrome extension', function () {
let driver;
beforeAll(async () => {
driver = new webdriver.Builder()
.setChromeOptions(
new chrome.Options()
.setBrowserVersion('stable')
.addArguments(`load-extension=${path}`),
)
.forBrowser('chrome')
.build();
});
afterAll(async () => {
await driver.quit();
});
it("should open extension's window", async () => {
await driver.get(`chrome-extension://${extensionId}/devpanel.html`);
const url = await driver.getCurrentUrl();
expect(url).toBe(`chrome-extension://${extensionId}/devpanel.html`);
});
it('should match document title', async () => {
const title = await driver.getTitle();
expect(title).toBe('Redux DevTools');
});
it('should get actions list', async () => {
const url = 'https://zalmoxisus.github.io/examples/router/';
await driver.executeScript(`window.open('${url}')`);
await delay(2000);
const tabs = await driver.getAllWindowHandles();
await driver.switchTo().window(tabs[1]);
expect(await driver.getCurrentUrl()).toMatch(url);
await driver.switchTo().window(tabs[0]);
await delay(1000);
const result = await driver.wait(
driver
.findElement(webdriver.By.xpath('//div[@data-testid="actionListRows"]'))
.getText()
.then((val) => {
return actionsPattern.test(val);
}),
15000,
"it doesn't match actions pattern",
);
expect(result).toBeTruthy();
});
it("should contain inspector monitor's component", async () => {
const val = await driver
.findElement(webdriver.By.xpath('//div[@data-testid="inspector"]'))
.getText();
expect(val).toBeDefined();
});
Object.keys(switchMonitorTests).forEach((description) =>
it(description, () => switchMonitorTests[description](driver)),
);
});