Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Macro: #3894 - Paste from clipboard in sequence mode #4330

Merged
merged 30 commits into from
Apr 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
384ed2b
#3894 Paste from clipboard in sequence mode
StarlaStarla Mar 21, 2024
eca28be
#3894 Paste from clipboard in sequence mode
StarlaStarla Mar 22, 2024
ed0ed0e
#3894 Paste from clipboard in sequence mode
StarlaStarla Mar 25, 2024
676fbe8
Merge branch 'master' of github.com:epam/ketcher into 3894-macro-past…
StarlaStarla Mar 25, 2024
2bb38cc
#3894 remove commented code and fix ci issue
StarlaStarla Mar 25, 2024
0f1627d
#3894 fix CodeQL issue
StarlaStarla Mar 25, 2024
17c9082
#3894 fix CodeQL issue and circular dependencies
StarlaStarla Mar 25, 2024
c11bdb0
#3894 remove unused code
StarlaStarla Mar 25, 2024
2d62c20
#3894 fix autotests
StarlaStarla Mar 26, 2024
960404e
#3894 add tests
StarlaStarla Mar 26, 2024
fc746e8
#3894 fix issues
StarlaStarla Mar 26, 2024
17768a4
#3894 fix issues
StarlaStarla Mar 27, 2024
da5ba44
#3916Copy fragment from existing sequence on canvas and paste
StarlaStarla Mar 27, 2024
b1edf3e
#3894 fix issue
StarlaStarla Mar 27, 2024
c8dc18e
Merge branch 'master' of github.com:epam/ketcher into 3894-macro-past…
StarlaStarla Mar 29, 2024
afcc95e
#3894 fix issues and auto tests
StarlaStarla Mar 29, 2024
28f9f51
#3894 add clipboard permissions config
StarlaStarla Mar 29, 2024
f741cb3
#3894 fix screenshots
StarlaStarla Mar 29, 2024
96e649e
#3894 fix issues and auto tests
StarlaStarla Mar 29, 2024
567bc5e
Merge branch 'master' of github.com:epam/ketcher into 3894-macro-past…
StarlaStarla Mar 29, 2024
1e76549
#3894 remove log
StarlaStarla Mar 29, 2024
a4a752d
- fixes after review
rrodionov91 Apr 12, 2024
3ec4b0d
Merge remote-tracking branch 'origin/master' into 3894-macro-paste-fr…
rrodionov91 Apr 12, 2024
afc9418
- fixes after review
rrodionov91 Apr 12, 2024
e06163b
- fixed circular dependency
rrodionov91 Apr 12, 2024
4a0500f
- fixed screenshots
rrodionov91 Apr 13, 2024
a682ab4
- fixed screenshots
rrodionov91 Apr 13, 2024
08a9ec9
- fixed screenshots and tests
rrodionov91 Apr 13, 2024
461651c
- fixes for tests flakiness
rrodionov91 Apr 15, 2024
7cc6697
- fix undo/redo for sequence type selector
rrodionov91 Apr 15, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions ketcher-autotests/playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,10 @@ const config: PlaywrightTestConfig = {
launchOptions: {
headless: true,
},
contextOptions: {
// chromium-specific permissions
permissions: ['clipboard-read', 'clipboard-write'],
},
},
},

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import { test } from '@playwright/test';
import {
takeEditorScreenshot,
waitForPageInit,
openFileAndAddToCanvasMacro,
zoomWithMouseWheel,
selectRectangleArea,
clickUndo,
} from '@utils';
import { turnOnMacromoleculesEditor } from '@utils/macromolecules';

const startX = 300;
const startY = 300;
const endX = 600;
const endY = 600;
test.describe('Flex mode copy&paste', () => {
test.beforeEach(async ({ page }) => {
await waitForPageInit(page);
await turnOnMacromoleculesEditor(page);
const ZOOM_OUT_VALUE = 400;

await openFileAndAddToCanvasMacro('KET/monomers-chains.ket', page);
await zoomWithMouseWheel(page, ZOOM_OUT_VALUE);
});

test('Copy & paste selection with rectangular tool and undo', async ({
page,
}) => {
await selectRectangleArea(page, startX, startY, endX, endY);
await page.keyboard.press('Control+c');

await page.mouse.move(-startX, 0);
await page.keyboard.press('Control+v');
await takeEditorScreenshot(page);

await clickUndo(page);
await takeEditorScreenshot(page);
});

test('Copy & paste selection with Shift + Click and undo', async ({
page,
}) => {
await page.keyboard.down('Shift');
await page.getByText('SMCC').locator('..').first().click();
await page.getByText('Test-6-Ch').locator('..').first().click();
await page.keyboard.up('Shift');
await page.keyboard.press('Control+c');

await page.mouse.move(startX, startY);
await page.keyboard.press('Control+v');
await takeEditorScreenshot(page);

await clickUndo(page);
await takeEditorScreenshot(page);
});
});
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@
import { test } from '@playwright/test';
import {
takeEditorScreenshot,
waitForPageInit,
openFileAndAddToCanvasMacro,
selectSequenceLayoutModeTool,
zoomWithMouseWheel,
scrollDown,
selectRectangleArea,
moveMouseAway,
clickUndo,
openPasteFromClipboard,
readFileContents,
} from '@utils';
import { turnOnMacromoleculesEditor } from '@utils/macromolecules';
import {
clickOnSequenceSymbol,
getSequenceSymbolLocator,
} from '@utils/macromolecules/sequence';

const ZOOM_OUT_VALUE = 400;
const SCROLL_DOWN_VALUE = 250;
test.describe('Sequence mode copy&paste for view mode', () => {
test.beforeEach(async ({ page }) => {
await waitForPageInit(page);
await turnOnMacromoleculesEditor(page);

await openFileAndAddToCanvasMacro('KET/monomers-chains.ket', page);
await selectSequenceLayoutModeTool(page);
await zoomWithMouseWheel(page, ZOOM_OUT_VALUE);
await scrollDown(page, SCROLL_DOWN_VALUE);
});

test('Copy & paste selection with rectangular tool', async ({ page }) => {
const startX = 100;
const startY = 100;
const endX = 500;
const endY = 500;

await selectRectangleArea(page, startX, startY, endX, endY);
await takeEditorScreenshot(page);
await page.keyboard.press('Control+c');
await page.keyboard.press('Control+v');
await takeEditorScreenshot(page);
});

test('Select entire chain with Ctrl+Lclick then copy and paste and undo', async ({
page,
}) => {
await page.keyboard.down('Control');
await getSequenceSymbolLocator(page, 'G').click();
await page.keyboard.up('Control');
await takeEditorScreenshot(page);
await page.keyboard.press('Control+c');
await page.keyboard.press('Control+v');
await takeEditorScreenshot(page);

await clickUndo(page);
await takeEditorScreenshot(page);
});
});

test.describe('Sequence mode copy&paste for edit mode', () => {
test.beforeEach(async ({ page }) => {
await waitForPageInit(page);
await turnOnMacromoleculesEditor(page);

await openFileAndAddToCanvasMacro('KET/monomers-chains.ket', page);
await selectSequenceLayoutModeTool(page);
await zoomWithMouseWheel(page, ZOOM_OUT_VALUE);
await getSequenceSymbolLocator(page, 'G').click({ button: 'right' });
await page.getByTestId('edit_sequence').click();
});

test('Copy & paste selection with LClick+drag and undo', async ({ page }) => {
await getSequenceSymbolLocator(page, 'G').hover();
await page.mouse.down();
const gNthNumber = 1;
await getSequenceSymbolLocator(page, 'G', gNthNumber).hover();

await page.mouse.up();
await moveMouseAway(page);
await takeEditorScreenshot(page);

await page.keyboard.press('Control+c');
const cNthNumber = 5;
await getSequenceSymbolLocator(page, 'C', cNthNumber).click();
await page.keyboard.press('Control+v');
await takeEditorScreenshot(page);

await clickUndo(page);
await takeEditorScreenshot(page);
});

test('Select letters with Shift & ArrowLeft then paste ket from clipboard and undo', async ({
page,
}) => {
const fileContent = await readFileContents(
'tests/test-data/KET/single-fragment-for-paste.ket',
);
await openPasteFromClipboard(page, fileContent);
await page.keyboard.press('Control+a');
await page.keyboard.press('Control+c');
await page.getByTitle('Close window').click();

await clickOnSequenceSymbol(page, 'G');
const arrowCount = 8;
await page.keyboard.down('Shift');
for (let i = 0; i < arrowCount; i++) {
await page.keyboard.press('ArrowLeft');
}
await page.keyboard.up('Shift');
await takeEditorScreenshot(page);

await page.keyboard.press('Control+v');
await takeEditorScreenshot(page);

await clickUndo(page);
await clickUndo(page);
await takeEditorScreenshot(page);
});

test('Select letters with Shift & ArrowRight then paste sequence from clipboard and undo', async ({
page,
}) => {
await openPasteFromClipboard(page, 'atc');
await page.keyboard.press('Control+a');
await page.keyboard.press('Control+c');
await page.getByTitle('Close window').click();

await clickOnSequenceSymbol(page, 'G');
const arrowCount = 10;
await page.keyboard.down('Shift');
for (let i = 0; i < arrowCount; i++) {
await page.keyboard.press('ArrowRight');
}
await page.keyboard.up('Shift');
await moveMouseAway(page);

await takeEditorScreenshot(page);

await page.keyboard.press('Control+v');
await takeEditorScreenshot(page);

await clickUndo(page);
await clickUndo(page);
await takeEditorScreenshot(page);
});
});
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
import { test } from '@playwright/test';
import {
takeEditorScreenshot,
waitForPageInit,
openFileAndAddToCanvasMacro,
zoomWithMouseWheel,
scrollDown,
selectRectangleArea,
clickUndo,
selectSnakeLayoutModeTool,
} from '@utils';
import { turnOnMacromoleculesEditor } from '@utils/macromolecules';

test.describe('Snake mode copy&paste', () => {
test.beforeEach(async ({ page }) => {
await waitForPageInit(page);
await turnOnMacromoleculesEditor(page);
const ZOOM_OUT_VALUE = 400;
const SCROLL_DOWN_VALUE = 250;

await openFileAndAddToCanvasMacro('KET/monomers-chains.ket', page);
await selectSnakeLayoutModeTool(page);
await zoomWithMouseWheel(page, ZOOM_OUT_VALUE);
await scrollDown(page, SCROLL_DOWN_VALUE);
});

test('Copy & paste selection with rectangular tool and undo', async ({
page,
}) => {
const startX = 200;
const startY = 200;
const endX = 500;
const endY = 400;

await selectRectangleArea(page, startX, startY, endX, endY);
await takeEditorScreenshot(page);

await page.keyboard.press('Control+c');
await page.keyboard.press('Control+v');
await takeEditorScreenshot(page);

await clickUndo(page);
await takeEditorScreenshot(page);
});

test('Copy & paste selection with Shift + Click and undo', async ({
page,
}) => {
await page.keyboard.down('Shift');
await page.getByText('D').locator('..').first().click();
await page.getByText('F').locator('..').first().click();
await page.keyboard.up('Shift');
await page.keyboard.press('Control+c');
await takeEditorScreenshot(page);

await page.keyboard.press('Control+v');
await takeEditorScreenshot(page);

await clickUndo(page);
await takeEditorScreenshot(page);
});
});
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
} from '@utils';
import { turnOnMacromoleculesEditor } from '@utils/macromolecules';
import { PHOSPHATE, SUGAR } from '@constants/testIdConstants';
import { clickOnSequenceSymbol } from '@utils/macromolecules/sequence';

test.describe('Sequence mode edit in RNA Builder', () => {
test.beforeEach(async ({ page }) => {
Expand All @@ -23,8 +24,8 @@ test.describe('Sequence mode edit in RNA Builder', () => {
});

test('Select one nucleotide and modify sugar', async ({ page }) => {
await page.getByText('T').first().click();
await page.getByText('T').first().click({ button: 'right' });
await clickOnSequenceSymbol(page, 'T');
await clickOnSequenceSymbol(page, 'T', { button: 'right' });
// should see correct context menu title and available 'modify_in_rna_builder' button
await takeEditorScreenshot(page);
await page.getByTestId('modify_in_rna_builder').click();
Expand All @@ -47,8 +48,8 @@ test.describe('Sequence mode edit in RNA Builder', () => {
});

test('Select one nucleotide and cancel modification', async ({ page }) => {
await page.getByText('T').first().click();
await page.getByText('T').first().click({ button: 'right' });
await clickOnSequenceSymbol(page, 'T');
await clickOnSequenceSymbol(page, 'T', { button: 'right' });
await page.getByTestId('modify_in_rna_builder').click();
await page.getByTestId(SUGAR).click();
await page.getByTestId('25R___2,5-Ribose').click();
Expand All @@ -70,7 +71,7 @@ test.describe('Sequence mode edit in RNA Builder', () => {
const endY = 200;
await selectRectangleArea(page, startX, startY, endX, endY);
await takeEditorScreenshot(page);
await page.getByText('T').first().click({ button: 'right' });
await clickOnSequenceSymbol(page, 'T', { button: 'right' });
// should see correct context menu title and available 'modify_in_rna_builder' button
await takeEditorScreenshot(page);
await page.getByTestId('modify_in_rna_builder').click();
Expand All @@ -96,11 +97,11 @@ test.describe('Sequence mode edit in RNA Builder', () => {
page,
}) => {
await page.keyboard.down('Control');
await page.getByText('T').first().click();
await clickOnSequenceSymbol(page, 'T');
await page.keyboard.up('Control');
// should see the whole chain selected
await takeEditorScreenshot(page);
await page.getByText('T').first().click({ button: 'right' });
await clickOnSequenceSymbol(page, 'T', { button: 'right' });
// should see correct context menu title and disabled 'modify_in_rna_builder' button
await takeEditorScreenshot(page);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ import {
startNewSequence,
switchSequenceEnteringType,
takeEditorScreenshot,
typeAllEnglishAlphabet,
typePeptideAlphabet,
typeRNADNAAlphabet,
waitForPageInit,
} from '@utils';
import { turnOnMacromoleculesEditor } from '@utils/macromolecules';
Expand All @@ -20,16 +21,14 @@ test.describe('Sequence edit mode', () => {

test('Add/edit sequence', async ({ page }) => {
await startNewSequence(page);
await typeAllEnglishAlphabet(page);
await typeRNADNAAlphabet(page);
await switchSequenceEnteringType(page, SequenceType.DNA);
await typeAllEnglishAlphabet(page);
await typeRNADNAAlphabet(page);
await switchSequenceEnteringType(page, SequenceType.PEPTIDE);
await typeAllEnglishAlphabet(page);
await typePeptideAlphabet(page);
await page.keyboard.press('Enter');
await typeAllEnglishAlphabet(page);
await typePeptideAlphabet(page);
await takeEditorScreenshot(page);
// remove after fix the bug about opening sequence type dropdown on pressing Enter
await page.keyboard.press('Escape');
await selectSnakeLayoutModeTool(page);
await takeEditorScreenshot(page);
});
Expand Down
Loading
Loading