Explorar o código

feat: Enhance Vim keymap tests by adding command mode functionality and restructuring test setup

Shun Miyazawa hai 2 meses
pai
achega
a53ccef791
Modificáronse 1 ficheiros con 30 adicións e 9 borrados
  1. 30 9
      apps/app/playwright/23-editor/vim-keymap.spec.ts

+ 30 - 9
apps/app/playwright/23-editor/vim-keymap.spec.ts

@@ -28,18 +28,24 @@ const changeKeymap = async (page: Page, keymap: string) => {
 };
 
 test.describe('Vim keymap mode', () => {
-  test('Insert mode should persist while typing multiple characters', async ({
-    page,
-  }) => {
-    const testText = 'Hello World';
-    const testPagePath = '/Sandbox/vim-keymap-test-page';
-
-    await page.goto(testPagePath);
+  test.beforeEach(async ({ page }) => {
+    await page.goto('/Sandbox/vim-keymap-test-page');
 
     // Open Editor
     await expect(page.getByTestId('editor-button')).toBeVisible();
     await page.getByTestId('editor-button').click();
     await expect(page.getByTestId('grw-editor-navbar-bottom')).toBeVisible();
+  });
+
+  test.afterAll(async ({ page }) => {
+    // Restore keymap to default
+    await changeKeymap(page, 'default');
+  });
+
+  test('Insert mode should persist while typing multiple characters', async ({
+    page,
+  }) => {
+    const testText = 'Hello World';
 
     // Change to Vim keymap
     await changeKeymap(page, 'vim');
@@ -52,8 +58,23 @@ test.describe('Vim keymap mode', () => {
 
     // Append text
     await appendTextToEditorUntilContains(page, testText);
+  });
 
-    // Change back to default keymap
-    await changeKeymap(page, 'default');
+  test('Write command (:w) should save the page successfully', async ({
+    page,
+  }) => {
+    //  Enter normal mode
+    await page.keyboard.press('Escape');
+
+    // Enter command mode
+    await page.keyboard.type(':');
+    await expect(page.locator('.cm-vim-panel')).toBeVisible();
+
+    // Type write command and execute
+    await page.keyboard.type('w');
+    await page.keyboard.press('Enter');
+
+    // Expect a success toaster to be displayed
+    await expect(page.locator('.Toastify__toast--success')).toBeVisible();
   });
 });