fix: autosave playwright test (#7641)

* fix: autosave playwright test

* fix
This commit is contained in:
Pooja
2026-04-01 15:06:31 +05:30
committed by GitHub
parent bcc1b535ff
commit aa7b8f4ca1
3 changed files with 18 additions and 12 deletions

View File

@@ -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' }) });

View File

@@ -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);
});
});
});

View File

@@ -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);