From aa7b8f4ca157f78675de2b8ef8e53f9d2de6866d Mon Sep 17 00:00:00 2001 From: Pooja Date: Wed, 1 Apr 2026 15:06:31 +0530 Subject: [PATCH] fix: autosave playwright test (#7641) * fix: autosave playwright test * fix --- tests/preferences/autosave/autosave.spec.ts | 8 +++++--- .../request/headers/header-validation.spec.ts | 4 +++- .../variable-tooltip/variable-tooltip.spec.ts | 18 ++++++++++-------- 3 files changed, 18 insertions(+), 12 deletions(-) diff --git a/tests/preferences/autosave/autosave.spec.ts b/tests/preferences/autosave/autosave.spec.ts index de42204c1..af65e9180 100644 --- a/tests/preferences/autosave/autosave.spec.ts +++ b/tests/preferences/autosave/autosave.spec.ts @@ -1,6 +1,8 @@ import { test, expect } from '../../../playwright'; import { createCollection, closeAllCollections, createRequest } from '../../utils/page'; +const saveShortcut = process.platform === 'darwin' ? 'Meta+s' : 'Control+s'; + test.describe('Autosave', () => { test.setTimeout(60000); @@ -25,7 +27,7 @@ test.describe('Autosave', () => { const urlEditor = page.locator('#request-url .CodeMirror'); await urlEditor.click(); await page.keyboard.type('https://api.example.com'); - await page.keyboard.press('Control+s'); + await page.keyboard.press(saveShortcut); // Verify no draft indicator const requestTab = page.locator('.request-tab').filter({ has: page.locator('.tab-label', { hasText: 'Test Request' }) }); @@ -131,7 +133,7 @@ test.describe('Autosave', () => { await expect(requestTab.locator('.has-changes-icon')).toBeVisible({ timeout: 2000 }); // Save the request - await page.keyboard.press('Control+s'); + await page.keyboard.press(saveShortcut); await expect(requestTab.locator('.has-changes-icon')).not.toBeVisible(); }); }); @@ -150,7 +152,7 @@ test.describe('Autosave', () => { const urlEditor = page.locator('#request-url .CodeMirror'); await urlEditor.click(); await page.keyboard.type('https://api.example.com'); - await page.keyboard.press('Control+s'); + await page.keyboard.press(saveShortcut); // Verify no draft indicator const requestTab = page.locator('.request-tab').filter({ has: page.locator('.tab-label', { hasText: 'Draft Request' }) }); diff --git a/tests/request/headers/header-validation.spec.ts b/tests/request/headers/header-validation.spec.ts index 9bf2f8975..50cc4e1e1 100644 --- a/tests/request/headers/header-validation.spec.ts +++ b/tests/request/headers/header-validation.spec.ts @@ -2,6 +2,8 @@ import { test, expect } from '../../../playwright'; import { closeAllCollections, createCollection, createRequest, openCollection, openRequest, saveRequest, selectRequestPaneTab } from '../../utils/page'; import { getTableCell } from '../../utils/page/locators'; +const saveShortcut = process.platform === 'darwin' ? 'Meta+s' : 'Control+s'; + test.describe.serial('Header Validation', () => { test.afterAll(async ({ page }) => { await closeAllCollections(page); @@ -89,7 +91,7 @@ test.describe.serial('Header Validation', () => { await expect(tooltip).toContainText('Header value cannot contain newlines'); // Save the request - await page.keyboard.press('Control+s'); + await page.keyboard.press(saveShortcut); }); }); }); diff --git a/tests/variable-tooltip/variable-tooltip.spec.ts b/tests/variable-tooltip/variable-tooltip.spec.ts index 635cfa28c..cf8eba4d8 100644 --- a/tests/variable-tooltip/variable-tooltip.spec.ts +++ b/tests/variable-tooltip/variable-tooltip.spec.ts @@ -11,6 +11,8 @@ import { } from '../utils/page'; import { buildCommonLocators } from '../utils/page/locators'; +const saveShortcut = process.platform === 'darwin' ? 'Meta+s' : 'Control+s'; + test.describe('Variable Tooltip', () => { test.afterEach(async ({ page }) => { if (!page.isClosed()) { @@ -44,7 +46,7 @@ test.describe('Variable Tooltip', () => { const urlEditor = page.locator('#request-url .CodeMirror'); await urlEditor.click(); await page.keyboard.type('https://api.example.com?key={{apiKey}}'); - await page.keyboard.press('Control+s'); + await page.keyboard.press(saveShortcut); }); await test.step('Test basic tooltip', async () => { @@ -76,7 +78,7 @@ test.describe('Variable Tooltip', () => { const headerValueEditor = headerRow.locator('.CodeMirror').nth(1); await headerValueEditor.click(); await page.keyboard.type('Bearer {{secretToken}}'); - await page.keyboard.press('Control+s'); + await page.keyboard.press(saveShortcut); // Test tooltip with secret const secretVar = headerValueEditor.locator('.cm-variable-valid').filter({ hasText: 'secretToken' }).first(); @@ -132,7 +134,7 @@ test.describe('Variable Tooltip', () => { const urlEditor = page.locator('#request-url .CodeMirror'); await urlEditor.click(); await page.keyboard.type('{{endpoint}}'); - await page.keyboard.press('Control+s'); + await page.keyboard.press(saveShortcut); }); await test.step('Test variable referencing other variables', async () => { @@ -243,7 +245,7 @@ test.describe('Variable Tooltip', () => { const urlEditor = locators.request.urlInput(); await urlEditor.click(); await page.keyboard.type('https://example.com'); - await page.keyboard.press('Control+s'); + await page.keyboard.press(saveShortcut); }); await test.step('Test process.env variable tooltip', async () => { @@ -255,7 +257,7 @@ test.describe('Variable Tooltip', () => { await urlEditor.click(); await page.keyboard.press('End'); await page.keyboard.type('?env={{process.env.HOME}}'); - await page.keyboard.press('Control+s'); + await page.keyboard.press(saveShortcut); // Hover over process.env variable const processEnvVar = urlEditor.locator('.cm-variable-valid, .cm-variable-invalid').filter({ hasText: 'process.env.HOME' }).first(); @@ -289,7 +291,7 @@ test.describe('Variable Tooltip', () => { const urlEditor = page.locator('#request-url .CodeMirror'); await urlEditor.click(); await page.keyboard.type('https://api.example.com'); - await page.keyboard.press('Control+s'); + await page.keyboard.press(saveShortcut); }); await test.step('Edit URL to create draft with undefined variable', async () => { @@ -397,7 +399,7 @@ test.describe('Variable Tooltip', () => { const urlEditor = page.locator('#request-url .CodeMirror'); await urlEditor.click(); await page.keyboard.type('https://api.example.com'); - await page.keyboard.press('Control+s'); + await page.keyboard.press(saveShortcut); }); await test.step('Test invalid variable name with space', async () => { @@ -414,7 +416,7 @@ test.describe('Variable Tooltip', () => { const cm = el.CodeMirror; cm.setValue('{\n "userId": "{{user id}}"\n}'); }); - await page.keyboard.press('Control+s'); + await page.keyboard.press(saveShortcut); // Hover over the invalid variable await page.mouse.move(0, 0);