Skip to content

Commit 78545f1

Browse files
authored
chore: implement locators drawer (#568)
1 parent 6c30165 commit 78545f1

21 files changed

+385
-109
lines changed

l10n/bundle.l10n.de.json

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"Can't record while running tests": "Aufzeichnung während der Ausführung von Tests nicht möglich",
55
"Clear cache": "Cache leeren",
66
"Close all browsers": "Alle Browser schließen",
7+
"Locator": "Locator",
78
"No Playwright tests found.": "Keine Playwright-Tests gefunden.",
89
"Pick locator": "Locator auswählen",
910
"Playwright Test v{0} or newer is required": "Playwright Test v{0} oder neuer ist erforderlich",

l10n/bundle.l10n.fr.json

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"Can't record while running tests": "Impossible d'enregistrer pendant l'exécution des tests",
55
"Clear cache": "Vider le cache",
66
"Close all browsers": "Fermer tous les navigateurs",
7+
"Locator": "Locator",
78
"No Playwright tests found.": "Aucun test Playwright trouvé.",
89
"Pick locator": "Trouver locator",
910
"Playwright Test v{0} or newer is required": "Playwright Test v{0} ou plus est nécessaire",

l10n/bundle.l10n.it.json

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"Can't record while running tests": "Non e' possibile registrare mentre si eseguono i test",
55
"Clear cache": "Pulire la cache",
66
"Close all browsers": "Chiudere tutti i browser",
7+
"Locator": "Locator",
78
"No Playwright tests found.": "0 Playwright test trovati.",
89
"Pick locator": "Seleziona il locator",
910
"Playwright Test v{0} or newer is required": "Playwright Test v{0} o una piu' recenbte e' richiesta",

l10n/bundle.l10n.json

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"Can't record while running tests": "Can't record while running tests",
55
"Clear cache": "Clear cache",
66
"Close all browsers": "Close all browsers",
7+
"Locator": "Locator",
78
"No Playwright tests found.": "No Playwright tests found.",
89
"Pick locator": "Pick locator",
910
"Playwright Test v{0} or newer is required": "Playwright Test v{0} or newer is required",

l10n/bundle.l10n.zh-CN.json

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"Can't record while running tests": "运行测试时不能录制",
55
"Clear cache": "清除缓存",
66
"Close all browsers": "关闭全部 Playwright 浏览器",
7+
"Locator": "定位器",
78
"No Playwright tests found.": "没有找到 Playwright Test",
89
"Pick locator": "拾取选择器",
910
"Playwright Test v{0} or newer is required": "需要 v{0} 或以上版本的 Playwright Test",

media/locatorsView.css

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/**
2+
* Copyright (c) Microsoft Corporation.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
.section {
18+
margin: 10px;
19+
display: flex;
20+
flex-direction: column;
21+
}
22+
23+
.section label {
24+
margin-bottom: 5px;
25+
}
26+
27+
p.error {
28+
color: var(--vscode-errorForeground);
29+
}

media/settingsView.css

-20
Original file line numberDiff line numberDiff line change
@@ -14,19 +14,6 @@
1414
* limitations under the License.
1515
*/
1616

17-
body {
18-
margin: 0;
19-
padding: 0;
20-
}
21-
22-
svg {
23-
transform: scale(0.3);
24-
fill: var(--vscode-editor-foreground);
25-
margin: -18px;
26-
width: 56px;
27-
pointer-events: none;
28-
}
29-
3017
.list {
3118
display: flex;
3219
flex-direction: column;
@@ -89,13 +76,6 @@ body[data-vscode-theme-kind=vscode-dark] div.separator {
8976
border-color: rgba(204, 204, 204, 0.2);
9077
}
9178

92-
.section-header {
93-
font-size: 11px;
94-
margin: 10px 0 3px 8px;
95-
font-weight: 700;
96-
color: var(--vscode-editor-inlineValuesForeground);
97-
}
98-
9979
.action-indent {
10080
width: 4px;
10181
height: 4px;

media/theme.css

+64
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
/**
2+
* Copyright (c) Microsoft Corporation.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
body {
18+
margin: 0;
19+
padding: 0;
20+
}
21+
22+
svg {
23+
transform: scale(0.3);
24+
fill: var(--vscode-editor-foreground);
25+
margin: -18px;
26+
width: 56px;
27+
pointer-events: none;
28+
}
29+
30+
input, textarea {
31+
background-color: var(--vscode-input-background);
32+
color: var(--vscode-input-foreground);
33+
border-width: 1px;
34+
border-style: solid;
35+
border-color: var(--vscode-input-border, transparent);
36+
border-radius: 2px;
37+
padding: 2px 6px;
38+
}
39+
40+
input {
41+
font-family: system-ui, Ubuntu, "Droid Sans", sans-serif, "Droid Sans Mono", "monospace", monospace;
42+
font-size: 13px;
43+
line-height: 20px;
44+
letter-spacing: 0px;
45+
}
46+
47+
input:focus, textarea:focus {
48+
opacity: 1;
49+
outline-color: var(--vscode-focusBorder);
50+
outline-offset: -1px;
51+
outline-style: solid;
52+
outline-width: 1px;
53+
}
54+
55+
textarea {
56+
font-size: 12px;
57+
}
58+
59+
.section-header {
60+
font-size: 11px;
61+
margin: 10px 0 3px 8px;
62+
font-weight: 700;
63+
color: var(--vscode-editor-inlineValuesForeground);
64+
}

package.json

+16
Original file line numberDiff line numberDiff line change
@@ -126,13 +126,29 @@
126126
}
127127
}
128128
},
129+
"viewsContainers": {
130+
"panel": [
131+
{
132+
"id": "playwrightContainer",
133+
"title": "Playwright",
134+
"icon": "images/playwright-logo.png"
135+
}
136+
]
137+
},
129138
"views": {
130139
"test": [
131140
{
132141
"type": "webview",
133142
"id": "pw.extension.settingsView",
134143
"name": "%views.test.pw.extension.settingsView%"
135144
}
145+
],
146+
"playwrightContainer": [
147+
{
148+
"type": "webview",
149+
"id": "pw.extension.locatorsView",
150+
"name": "%views.test.pw.extension.locatorsView%"
151+
}
136152
]
137153
}
138154
},

package.nls.de.json

+1
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,6 @@
1919
"configuration.playwright.reuseBrowser": "Browser zwischen Tests anzeigen & wiederverwenden.",
2020
"configuration.playwright.showTrace": "Trace Viewer anzeigen.",
2121
"configuration.playwright.runGlobalSetupOnEachRun": "Globales Setup nicht wiederverwenden.",
22+
"views.test.pw.extension.locatorsView": "Locator",
2223
"views.test.pw.extension.settingsView": "Playwright"
2324
}

package.nls.fr.json

+1
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,6 @@
1919
"configuration.playwright.reuseBrowser": "Afficher et réutiliser le navigateur entre les tests.",
2020
"configuration.playwright.showTrace": "Afficher les traces avec Trace Viewer.",
2121
"configuration.playwright.runGlobalSetupOnEachRun": "Ne pas réutiliser la setup globale.",
22+
"views.test.pw.extension.locatorsView": "Localisateurs",
2223
"views.test.pw.extension.settingsView": "Playwright"
2324
}

package.nls.it.json

+1
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,6 @@
1919
"configuration.playwright.reuseBrowser": "Mostra & riusa il browser tra i test",
2020
"configuration.playwright.showTrace": "Mostra il Trace Viewer.",
2121
"configuration.playwright.runGlobalSetupOnEachRun": "Esegui il global setup ad ogni run.",
22+
"views.test.pw.extension.locatorsView": "Localizzatori",
2223
"views.test.pw.extension.settingsView": "Playwright"
2324
}

package.nls.json

+1
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,6 @@
1919
"configuration.playwright.reuseBrowser": "Show & reuse browser between tests.",
2020
"configuration.playwright.showTrace": "Show Trace Viewer.",
2121
"configuration.playwright.runGlobalSetupOnEachRun": "Run global setup on each run.",
22+
"views.test.pw.extension.locatorsView": "Locators",
2223
"views.test.pw.extension.settingsView": "Playwright"
2324
}

package.nls.zh-CN.json

+1
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,6 @@
1919
"configuration.playwright.reuseBrowser": "在测试用例间显示并复用 Playwright 浏览器",
2020
"configuration.playwright.showTrace": "显示 Playwright 浏览器的跟踪",
2121
"configuration.playwright.runGlobalSetupOnEachRun": "不要重复使用全局设置",
22+
"views.test.pw.extension.locatorsView": "定位器",
2223
"views.test.pw.extension.settingsView": "Playwright"
2324
}

src/debugHighlight.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ export class DebugHighlight {
118118
return;
119119
const result = await locatorToHighlight(this._debugSessions, document, position, token);
120120
if (result)
121-
this._reusedBrowser.highlight(result);
121+
this._reusedBrowser.highlight(result).catch(() => {});
122122
else
123123
this._hideHighlight();
124124
}

src/extension.ts

+4
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ import { WorkspaceChange, WorkspaceObserver } from './workspaceObserver';
3030
import { registerTerminalLinkProvider } from './terminalLinkProvider';
3131
import { RunHooks, TestConfig } from './playwrightTestTypes';
3232
import { ansi2html } from './ansi2html';
33+
import { LocatorsView } from './locatorsView';
3334

3435
const stackUtils = new StackUtils({
3536
cwd: '/ensure_absolute_paths'
@@ -69,6 +70,7 @@ export class Extension implements RunHooks {
6970
private _reusedBrowser: ReusedBrowser;
7071
private _settingsModel: SettingsModel;
7172
private _settingsView!: SettingsView;
73+
private _locatorsView!: LocatorsView;
7274
private _diagnostics: vscodeTypes.DiagnosticCollection;
7375
private _treeItemObserver: TreeItemObserver;
7476
private _runProfile: vscodeTypes.TestRunProfile;
@@ -149,6 +151,7 @@ export class Extension implements RunHooks {
149151
async activate() {
150152
const vscode = this._vscode;
151153
this._settingsView = new SettingsView(vscode, this._settingsModel, this._models, this._reusedBrowser, this._context.extensionUri);
154+
this._locatorsView = new LocatorsView(vscode, this._reusedBrowser, this._context.extensionUri);
152155
const messageNoPlaywrightTestsFound = this._vscode.l10n.t('No Playwright tests found.');
153156
this._disposables = [
154157
this._debugHighlight,
@@ -232,6 +235,7 @@ export class Extension implements RunHooks {
232235
this._models.onUpdated(() => this._modelsUpdated()),
233236
this._treeItemObserver.onTreeItemSelected(item => this._treeItemSelected(item)),
234237
this._settingsView,
238+
this._locatorsView,
235239
this._testController,
236240
this._runProfile,
237241
this._debugProfile,

0 commit comments

Comments
 (0)