Skip to content

Commit

Permalink
chore: adjust to playwright 1.40
Browse files Browse the repository at this point in the history
  • Loading branch information
ruifigueira committed Nov 17, 2023
1 parent 38e7a6b commit 432b368
Show file tree
Hide file tree
Showing 12 changed files with 169 additions and 168 deletions.
4 changes: 3 additions & 1 deletion examples/recorder-crx/src/background.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,14 @@
import type { CrxApplication } from 'playwright-crx';
import { crx, _debug, _setUnderTest } from 'playwright-crx';

type Mode = 'none' | 'recording' | 'inspecting' | 'assertingText' | 'recording-inspecting' | 'standby' | 'assertingVisibility' | 'assertingValue';

// we must lazy initialize it
let crxAppPromise: Promise<CrxApplication> | undefined;

const attachedTabIds = new Set<number>();

async function changeAction(tabId: number, mode: 'none' | 'recording' | 'inspecting' | 'detached') {
async function changeAction(tabId: number, mode: Mode | 'detached') {
// detached basically implies recorder windows was closed
if (mode === 'detached' || mode === 'none') {
await Promise.all([
Expand Down
2 changes: 1 addition & 1 deletion examples/recorder-crx/src/contentscript.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ if (typeof chrome !== 'undefined' && chrome.runtime) {
case 'setMode': wnd.playwrightSetMode(msg.mode); break;
case 'setSources': wnd.playwrightSetSources(msg.sources); break;
case 'updateCallLogs': wnd.playwrightUpdateLogs(msg.callLogs); break;
case 'setSelector': wnd.playwrightSetSelector(msg.selector, msg.focus); break;
case 'setSelector': wnd.playwrightSetSelector(msg.selector, msg.userGesture); break;
case 'setFileIfNeeded': wnd.playwrightSetFileIfNeeded(msg.file); break;
}
});
Expand Down
164 changes: 72 additions & 92 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"clean": "npm run clean:pw && npm run clean:examples && npm run clean:tests && npm run clean:crx",
"test:install": "cd ./tests && npx playwright install --with-deps chromium",
"test": "cd ./tests && npx playwright test",
"test-ui": "cd ./tests && npx playwright test --ui"
"test-ui": "cd ./tests && npx playwright test --ui --timeout 0"
},
"workspaces": [
"examples/recorder-crx",
Expand Down
3 changes: 2 additions & 1 deletion src/client/crx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import type * as api from '../types/types';
import type * as channels from '../protocol/channels';
import { Page } from 'playwright-core/lib/client/page';
import type { BrowserContext } from 'playwright-core/lib/client/browserContext';
import { Mode } from '@recorder/recorderTypes';

function from<T>(obj: any): T {
return obj._object as T;
Expand Down Expand Up @@ -48,7 +49,7 @@ export class Crx extends ChannelOwner<channels.CrxChannel> implements api.Crx {
export class CrxRecorder extends EventEmitter {
private _channel: channels.CrxApplicationChannel;
private _hidden: boolean = true;
private _mode: 'none' | 'recording' | 'inspecting' = 'none';
private _mode: Mode = 'none';

constructor(channel: channels.CrxApplicationChannel) {
super();
Expand Down
2 changes: 1 addition & 1 deletion src/protocol/channels.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ export type CrxApplicationDetachedEvent = {
tabId: number,
};
export type CrxApplicationModeChangedEvent = {
mode: 'none' | 'recording' | 'inspecting',
mode: 'none' | 'recording' | 'inspecting' | 'assertingText' | 'recording-inspecting' | 'standby' | 'assertingVisibility' | 'assertingValue',
};
export type CrxApplicationAttachParams = {
tabId: number,
Expand Down
4 changes: 2 additions & 2 deletions src/protocol/validator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ scheme.CrxApplicationDetachedEvent = tObject({
tabId: tNumber,
});
scheme.CrxApplicationModeChangedEvent = tObject({
mode: tEnum(['none', 'recording', 'inspecting']),
mode: tEnum(['none', 'recording', 'inspecting', 'assertingText', 'recording-inspecting', 'standby', 'assertingVisibility', 'assertingValue']),
});
scheme.CrxApplicationAttachParams = tObject({
tabId: tNumber,
Expand Down Expand Up @@ -120,7 +120,7 @@ scheme.CrxApplicationNewPageResult = tObject({
page: tChannel(['Page']),
});
scheme.CrxApplicationShowRecorderParams = tObject({
mode: tOptional(tEnum(['none', 'recording', 'inspecting'])),
mode: tOptional(tEnum(['none', 'recording', 'inspecting', 'assertingText', 'recording-inspecting', 'standby', 'assertingVisibility', 'assertingValue'])),
language: tOptional(tString),
testIdAttributeName: tOptional(tString),
});
Expand Down
Loading

0 comments on commit 432b368

Please sign in to comment.