From bb1ba1911ea7c18fdea8c2a11f0df306bd713bb4 Mon Sep 17 00:00:00 2001 From: Nirmal Kumar R Date: Tue, 19 Nov 2024 17:52:58 +0530 Subject: [PATCH] e2e: Use the existing logged_in context for page --- tests/e2e/markdown-editor.test.e2e.ts | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/tests/e2e/markdown-editor.test.e2e.ts b/tests/e2e/markdown-editor.test.e2e.ts index 80516267fe..85a938cdf4 100644 --- a/tests/e2e/markdown-editor.test.e2e.ts +++ b/tests/e2e/markdown-editor.test.e2e.ts @@ -5,29 +5,37 @@ // @watch end import {expect} from '@playwright/test'; -import {test, load_logged_in_context, login, login_user} from './utils_e2e.ts'; +import {test, load_logged_in_context, login_user} from './utils_e2e.ts'; test.beforeAll(async ({browser}, workerInfo) => { await login_user(browser, workerInfo, 'user2'); }); test('Markdown image preview behaviour', async ({browser}, workerInfo) => { - const page = await login({browser}, workerInfo); + const context = await load_logged_in_context(browser, workerInfo, 'user2'); + // editing the root README.md file for image preview const editPath = '/user2/repo1/src/branch/master/README.md'; + const page = await context.newPage(); const response = await page.goto(editPath, {waitUntil: 'domcontentloaded'}); expect(response?.status()).toBe(200); + // click 'Edit file' tab await page.locator('[data-tooltip-content="Edit file"]').click(); + // this yields the monaco editor const editor = page.getByRole('presentation').nth(0); await editor.click(); + // clear all the content await page.keyboard.press('ControlOrMeta+KeyA'); + // add the image await page.keyboard.type('![Logo of Forgejo](./assets/logo.svg "Logo of Forgejo")'); + // click 'Preview' tab await page.locator('a[data-tab="preview"]').click(); + // check for the image preview via the expected attribute const preview = page.locator('div[data-tab="preview"] p[dir="auto"] a'); await expect(preview).toHaveAttribute('href', 'http://localhost:3003/user2/repo1/media/branch/master/assets/logo.svg'); });