diff --git a/l10n/bundle.l10n.de.json b/l10n/bundle.l10n.de.json index 9d36b1cbf..9e9942243 100644 --- a/l10n/bundle.l10n.de.json +++ b/l10n/bundle.l10n.de.json @@ -30,5 +30,7 @@ "SETTINGS": "EINSTELLUNGEN", "PROJECTS": "PROJEKTE", "TOOLS": "WERKZEUGE", - "SETUP": "KONFIGURATION" + "SETUP": "KONFIGURATION", + "Select All": "Alle auswählen", + "Unselect All": "Alle abwählen" } diff --git a/l10n/bundle.l10n.fr.json b/l10n/bundle.l10n.fr.json index 95eab9643..d6b408f2b 100644 --- a/l10n/bundle.l10n.fr.json +++ b/l10n/bundle.l10n.fr.json @@ -26,5 +26,7 @@ "Toggle Playwright Configs": "Basculer les configurations Playwright", "Update snapshots": "Mettre à jour les captures", "Update method" : "Mettre à jour la méthode", + "Select All": "Tout sélectionner", + "Unselect All": "Tout désélectionner", "When enabled, Playwright will reuse the browser instance between tests. This will disable parallel execution.": "Si cette option est activée, Playwright réutilisera l'instance du navigateur entre les tests. Cela désactivera l'exécution parallèle." } diff --git a/l10n/bundle.l10n.it.json b/l10n/bundle.l10n.it.json index 62f522c7d..c31a1d347 100644 --- a/l10n/bundle.l10n.it.json +++ b/l10n/bundle.l10n.it.json @@ -26,5 +26,7 @@ "Toggle Playwright Configs": "Attiva/disattiva Playwright Configs", "Update snapshots": "Aggiorna snapshots", "Update method" : "Aggiorna metodo", + "Select All": "Seleziona tutto", + "Unselect All": "Deseleziona tutto", "When enabled, Playwright will reuse the browser instance between tests. This will disable parallel execution.": "Quando attivata, Playwright riusa l'instanza browser tra i test. Questo disattiva l'esecuzione parallela." } diff --git a/l10n/bundle.l10n.json b/l10n/bundle.l10n.json index 536235bfb..be9db7b9d 100644 --- a/l10n/bundle.l10n.json +++ b/l10n/bundle.l10n.json @@ -26,5 +26,7 @@ "Toggle Playwright Configs": "Toggle Playwright Configs", "Update snapshots": "Update snapshots", "Update method" : "Update method", + "Select All": "Select All", + "Unselect All": "Unselect All", "When enabled, Playwright will reuse the browser instance between tests. This will disable parallel execution.": "When enabled, Playwright will reuse the browser instance between tests. This will disable parallel execution." } diff --git a/l10n/bundle.l10n.zh-CN.json b/l10n/bundle.l10n.zh-CN.json index 0bc52714c..1b85454f4 100644 --- a/l10n/bundle.l10n.zh-CN.json +++ b/l10n/bundle.l10n.zh-CN.json @@ -26,5 +26,7 @@ "Toggle Playwright Configs": "切换 Playwright 配置", "Update snapshots": "更新快照", "Update method" : "更新方法", + "Select All": "全选", + "Unselect All": "取消全选", "When enabled, Playwright will reuse the browser instance between tests. This will disable parallel execution.": "启用后,Playwright 将在测试之间重复使用浏览器实例。这将禁用并行执行。" } diff --git a/media/common.css b/media/common.css index 12d72c3da..bae0a3ee1 100644 --- a/media/common.css +++ b/media/common.css @@ -81,9 +81,22 @@ textarea { .section-header { font-size: 11px; - margin: 0 8px; + margin: 10px 8px 3px 8px; font-weight: 700; color: var(--vscode-editor-inlineValuesForeground); + + display: flex; + justify-content: space-between; + align-items: baseline; +} + +.section-toolbar > a { + border-radius: 5px; + font-size: 16px; +} + +.section-toolbar > a:hover { + background-color: var(--vscode-toolbar-hoverBackground); } .action, .combobox { diff --git a/media/settingsView.js b/media/settingsView.js index 1bfb86cf0..194189848 100644 --- a/media/settingsView.js +++ b/media/settingsView.js @@ -19,6 +19,9 @@ /** @type {Config} */ let selectConfig; +const selectAllButton = /** @type {HTMLAnchorElement} */ (document.getElementById('selectAll')); +const unselectAllButton = /** @type {HTMLAnchorElement} */ (document.getElementById('unselectAll')); + /** * @param {Array} projects */ @@ -41,7 +44,20 @@ function updateProjects(projects) { div.appendChild(label); projectsElement.appendChild(div); } + + const allEnabled = projects.every(p => p.enabled); + selectAllButton.hidden = allEnabled; + unselectAllButton.hidden = !allEnabled; +} + +/** + * @param {boolean} enabled + */ +function setAllProjectsEnabled(enabled) { + vscode.postMessage({ method: 'setAllProjectsEnabled', params: { configFile: selectConfig.configFile, enabled } }); } +selectAllButton.addEventListener('click', () => setAllProjectsEnabled(true)); +unselectAllButton.addEventListener('click', () => setAllProjectsEnabled(false)); for (const input of Array.from(document.querySelectorAll('input[type=checkbox]'))) { input.addEventListener('change', event => { diff --git a/src/settingsView.ts b/src/settingsView.ts index 56ac509e5..4f51303ef 100644 --- a/src/settingsView.ts +++ b/src/settingsView.ts @@ -80,6 +80,9 @@ export class SettingsView extends DisposableBase implements vscodeTypes.WebviewV } else if (data.method === 'setProjectEnabled') { const { configFile, projectName, enabled } = data.params; this._models.setProjectEnabled(configFile, projectName, enabled); + } else if (data.method === 'setAllProjectsEnabled') { + const { configFile, enabled } = data.params; + this._models.setAllProjectsEnabled(configFile, enabled); } else if (data.method === 'selectModel') { this._models.selectModel(data.params.configFile); } @@ -221,7 +224,17 @@ function htmlForWebview(vscode: vscodeTypes.VSCode, extensionUri: vscodeTypes.Ur -
${vscode.l10n.t('PROJECTS')}
+
+ ${vscode.l10n.t('PROJECTS')} + +
${vscode.l10n.t('SETUP')}
diff --git a/src/testModel.ts b/src/testModel.ts index 1d339f0ee..f4649d83d 100644 --- a/src/testModel.ts +++ b/src/testModel.ts @@ -740,6 +740,19 @@ export class TestModelCollection extends DisposableBase { this._didUpdate.fire(); } + setAllProjectsEnabled(configFile: string, enabled: boolean) { + const model = this._models.find(m => m.config.configFile === configFile); + if (!model) + return; + const projectsToUpdate = model.projects().filter(p => p.isEnabled !== enabled); + if (projectsToUpdate.length === 0) + return; + for (const project of projectsToUpdate) + project.isEnabled = enabled; + this._saveSettings(); + this._didUpdate.fire(); + } + testDirs(): Set { const result = new Set(); for (const model of this._models) { diff --git a/tests/settings.spec.ts b/tests/settings.spec.ts index af609f247..690390264 100644 --- a/tests/settings.spec.ts +++ b/tests/settings.spec.ts @@ -46,6 +46,52 @@ test('should toggle setting from webview', async ({ activate }) => { expect(configuration.get('reuseBrowser')).toBe(true); }); +test('should select-all/unselect-all', async ({ activate }) => { + const { vscode } = await activate({ + 'playwright.config.ts': ` + import { defineConfig } from '@playwright/test'; + export default defineConfig({ + projects: [ + { name: 'foo', testMatch: 'foo.ts' }, + { name: 'bar', testMatch: 'bar.ts' }, + ] + }); + `, + }); + + const webView = vscode.webViews.get('pw.extension.settingsView')!; + + await expect(webView.locator('body')).toMatchAriaSnapshot(` + - text: PROJECTS + - button "Select All" + - checkbox "foo" [checked] + - checkbox "bar" [checked=false] + `); + + await webView.getByRole('checkbox', { name: 'bar' }).check(); + + await expect(webView.locator('body')).toMatchAriaSnapshot(` + - button "Unselect All" + - checkbox "foo" [checked] + - checkbox "bar" [checked] + `); + + await webView.getByRole('button', { name: 'Unselect All' }).click(); + + await expect(webView.locator('body')).toMatchAriaSnapshot(` + - button "Select All" + - checkbox "foo" [checked=false] + - checkbox "bar" [checked=false] + `); + + await webView.getByRole('button', { name: 'Select All' }).click(); + await expect(webView.locator('body')).toMatchAriaSnapshot(` + - button "Unselect All" + - checkbox "foo" [checked] + - checkbox "bar" [checked] + `); +}); + test('should reflect changes to setting', async ({ activate }) => { const { vscode } = await activate({ 'playwright.config.js': `module.exports = {}`,