-
Notifications
You must be signed in to change notification settings - Fork 187
/
Copy pathmacro-micro-switcher.spec.ts
2266 lines (2106 loc) · 76.5 KB
/
macro-micro-switcher.spec.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/* eslint-disable no-magic-numbers */
import {
enterSequence,
turnOnMacromoleculesEditor,
turnOnMicromoleculesEditor,
} from '@utils/macromolecules';
import { Page, test, expect, BrowserContext, chromium } from '@playwright/test';
import {
FILE_TEST_DATA,
TopPanelButton,
clickInTheMiddleOfTheScreen,
dragMouseTo,
openFileAndAddToCanvas,
openFileAndAddToCanvasMacro,
pressButton,
selectTopPanelButton,
takeEditorScreenshot,
takeMonomerLibraryScreenshot,
takePageScreenshot,
waitForLoad,
waitForRender,
moveMouseToTheMiddleOfTheScreen,
selectOptionInDropdown,
waitForSpinnerFinishedWork,
selectRing,
RingButton,
moveMouseAway,
selectAtomInToolbar,
AtomButton,
selectFunctionalGroups,
FunctionalGroups,
selectSaltsAndSolvents,
SaltsAndSolvents,
selectSingleBondTool,
drawBenzeneRing,
selectSnakeLayoutModeTool,
selectEraseTool,
clickUndo,
clickOnAtom,
getKet,
saveToFile,
receiveFileComparisonData,
getMolfile,
selectSequenceLayoutModeTool,
switchSequenceEnteringType,
SequenceType,
selectLeftPanelButton,
LeftPanelButton,
selectDropdownTool,
openFileAndAddToCanvasAsNewProject,
getSdf,
getCdx,
openFile,
getCdxml,
getCml,
clickOnFileFormatDropdown,
takeTopToolbarScreenshot,
setAttachmentPoints,
selectClearCanvasTool,
waitForIndigoToLoad,
waitForKetcherInit,
} from '@utils';
import {
addSuperatomAttachmentPoint,
removeSuperatomAttachmentPoint,
} from '@utils/canvas/atoms/superatomAttachmentPoints';
import { bondTwoMonomersPointToPoint } from '@utils/macromolecules/polymerBond';
import { clickOnSequenceSymbol } from '@utils/macromolecules/sequence';
import { miewApplyButtonIsEnabled } from '@utils/common/loaders/waitForMiewApplyButtonIsEnabled';
import { pageReload } from '@utils/common/helpers';
import { Peptides } from '@utils/selectors/macromoleculeEditor';
const topLeftCorner = {
x: -325,
y: -235,
};
async function zoomWithMouseWheel(page: Page, scrollValue: number) {
await waitForRender(page, async () => {
await page.keyboard.down('Control');
await page.mouse.wheel(0, scrollValue);
await page.keyboard.up('Control');
});
}
async function scrollHorizontally(page: Page, scrollValue: number) {
await waitForRender(page, async () => {
await page.mouse.wheel(scrollValue, 0);
});
}
async function pasteFromClipboard(
page: Page,
fileFormats: string,
filename = '.ket',
) {
await selectTopPanelButton(TopPanelButton.Open, page);
await page.getByText('Paste from clipboard').click();
await page.getByRole('dialog').getByRole('textbox').fill(fileFormats);
await selectOptionInDropdown(filename, page);
await waitForLoad(page, async () => {
await pressButton(page, 'Add to Canvas');
});
}
async function addToFavoritesMonomers(page: Page) {
await page.getByTestId(Peptides.BetaAlanine).getByText('★').click();
await page
.getByTestId('Phe4Me___p-Methylphenylalanine')
.getByText('★')
.click();
await page.getByTestId('meM___N-Methyl-Methionine').getByText('★').click();
await page.getByTestId('RNA-TAB').click();
await page.getByTestId('summary-Sugars').click();
await page.getByTestId('25R___2,5-Ribose').getByText('★').click();
await page.getByTestId('summary-Bases').click();
await page.getByTestId('baA___N-benzyl-adenine').getByText('★').click();
await page.getByTestId('summary-Phosphates').click();
await page.getByTestId('bP___Boranophosphate').getByText('★').click();
await page.getByTestId('CHEM-TAB').click();
await page.getByTestId('Test-6-Ch___Test-6-AP-Chem').getByText('★').click();
}
async function setAtomAndBondSettings(page: Page) {
await page.getByTestId('settings-button').click();
await page.getByText('Atoms', { exact: true }).click();
await page.getByText('Terminal and Hetero').click();
await page.getByTestId('On-option').click();
await page.getByText('Bonds', { exact: true }).click();
await page
.locator('fieldset')
.filter({ hasText: 'Aromatic Bonds as' })
.getByRole('textbox')
.nth(1)
.click();
await page
.locator('fieldset')
.filter({ hasText: 'Aromatic Bonds as' })
.getByRole('textbox')
.nth(1)
.fill('05');
await page.getByTestId('OK').click();
}
async function openCdxFile(page: Page) {
await selectTopPanelButton(TopPanelButton.Open, page);
await openFile(
'CDX/one-attachment-point-added-in-micro-mode-expected.cdx',
page,
);
await selectOptionInDropdown(
'CDX/one-attachment-point-added-in-micro-mode-expected.cdx',
page,
);
await pressButton(page, 'Open as New Project');
}
async function openCdxmlFile(page: Page) {
await selectTopPanelButton(TopPanelButton.Open, page);
await openFile(
'CDXML/one-attachment-point-added-in-micro-mode-expected.cdxml',
page,
);
await selectOptionInDropdown(
'CDXML/one-attachment-point-added-in-micro-mode-expected.cdxml',
page,
);
await pressButton(page, 'Open as New Project');
}
enum FileFormat {
SVGDocument = 'SVG Document',
PNGImage = 'PNG Image',
}
async function saveFileAsPngOrSvgFormat(page: Page, FileFormat: string) {
await selectTopPanelButton(TopPanelButton.Save, page);
await clickOnFileFormatDropdown(page);
await page.getByRole('option', { name: FileFormat }).click();
}
async function open3DViewer(page: Page, waitForButtonIsEnabled = true) {
await waitForRender(page, async () => {
await selectTopPanelButton(TopPanelButton.ThreeD, page);
});
if (waitForButtonIsEnabled) {
await miewApplyButtonIsEnabled(page);
}
}
let page: Page;
let sharedContext: BrowserContext;
test.beforeAll(async ({ browser }) => {
try {
sharedContext = await browser.newContext();
} catch (error) {
console.error('Error on creation browser context:', error);
console.log('Restarting browser...');
await browser.close();
browser = await chromium.launch();
sharedContext = await browser.newContext();
}
// Reminder: do not pass page as async
page = await sharedContext.newPage();
await page.goto('', { waitUntil: 'domcontentloaded' });
await waitForKetcherInit(page);
await waitForIndigoToLoad(page);
await turnOnMacromoleculesEditor(page);
});
test.afterEach(async () => {
await page.keyboard.press('Escape');
await page.keyboard.press('Control+0');
await selectClearCanvasTool(page);
});
test.afterAll(async ({ browser }) => {
await page.close();
await sharedContext.close();
await browser.contexts().forEach((someContext) => {
someContext.close();
});
});
test.describe('Macro-Micro-Switcher', () => {
test(
'Check that preview window of macro structure does not change in micro mode ',
{ tag: ['@IncorrectResultBecauseOfBug'] },
async () => {
/*
Test case: https://github.com/epam/ketcher/issues/3603
Description: Preview window of macro structure doesn't change in micro mode
Test working incorrect now because we have bug https://github.com/epam/ketcher/issues/3603
*/
const scrollValue = -400;
const moleculeLabels = ['A', '25R', 'baA', 'Test-6-Ph', 'Test-6-Ch'];
await openFileAndAddToCanvasMacro('KET/five-monomers.ket', page);
await turnOnMicromoleculesEditor(page);
await scrollHorizontally(page, scrollValue);
for (const label of moleculeLabels) {
await waitForRender(page, async () => {
await page.getByText(label, { exact: true }).hover();
});
await takeEditorScreenshot(page);
}
},
);
test('Check that macromolecule structures in micromode are represented as S-Groups with bonds', async () => {
/*
Test case: Macro-Micro-Switcher
Description: Macromolecule structures in micromode are represented as S-Groups with bonds
*/
await turnOnMacromoleculesEditor(page);
await openFileAndAddToCanvasMacro(
'KET/three-monomers-connected-with-bonds.ket',
page,
);
await turnOnMicromoleculesEditor(page);
await page.getByText('Edc').hover();
await takeEditorScreenshot(page);
});
test('Micromolecules in macromode will be represented as CHEMs with generated name(F1, F2, ...Fn)', async () => {
/*
Test case: Macro-Micro-Switcher
Description: Micromolecules in macromode represented as CHEMs with generated name(F1, F2, ...Fn)
*/
await turnOnMicromoleculesEditor(page);
await openFileAndAddToCanvas(
'KET/eight-micromolecules.ket',
page,
topLeftCorner.x,
topLeftCorner.y,
);
await turnOnMacromoleculesEditor(page);
await takeEditorScreenshot(page);
});
test('Check that After hiding Library in Macro mode possible to see Show Library button', async () => {
/*
Test case: Macro-Micro-Switcher
Description: After hiding Library in Macro mode 'Show Library' button is visible.
*/
await page.getByText('Hide').click();
await takePageScreenshot(page);
await page.getByText('Show Library').click();
await page.getByText('Show Library').isVisible();
});
test('Check that the Mol-structure opened from the file in Macro mode is visible on Micro mode', async () => {
/*
Test case: Macro-Micro-Switcher
Description: Mol-structure opened from the file in Macro mode is visible on Micro mode
*/
await openFileAndAddToCanvasMacro('Molfiles-V2000/glutamine.mol', page);
await turnOnMicromoleculesEditor(page);
await takeEditorScreenshot(page);
});
test('Check that the Ket-structure opened from the file in Macro mode is visible in Micro mode', async () => {
/*
Test case: Macro-Micro-Switcher
Description: Mol-structure opened from the file in Macro mode is visible on Micro mode when
*/
await turnOnMacromoleculesEditor(page);
await openFileAndAddToCanvasMacro('KET/stereo-and-structure.ket', page);
await turnOnMicromoleculesEditor(page);
await takeEditorScreenshot(page);
});
test(
'Create a sequence of monomers in macro mode then switch to micro mode select the entire structure and move it to a new position',
{ tag: ['@IncorrectResultBecauseOfBug'] },
async () => {
/*
Test case: Macro-Micro-Switcher
Description: Sequence of monomers moved to a new position in Micro mode
Now test working not properly because we have bug https://github.com/epam/ketcher/issues/3654
*/
const x = 400;
const y = 400;
await turnOnMacromoleculesEditor(page);
await openFileAndAddToCanvasMacro(
'KET/three-monomers-connected-with-bonds.ket',
page,
);
await turnOnMicromoleculesEditor(page);
await page.keyboard.press('Control+a');
await page.getByText('Edc').hover();
await dragMouseTo(x, y, page);
await takeEditorScreenshot(page);
},
);
test(
'Add monomers in macro mode then switch to micro mode and check that it can not be expanded and abreviation can not be removed',
{ tag: ['@IncorrectResultBecauseOfBug'] },
async () => {
/*
Test case: Macro-Micro-Switcher
Description: Abbreviation of monomer expanded without errors.
Now test working not properly because we have bug https://github.com/epam/ketcher/issues/3659
*/
await openFileAndAddToCanvasMacro(
'KET/three-monomers-connected-with-bonds.ket',
page,
);
await turnOnMicromoleculesEditor(page);
await page.getByText('A6OH').click({ button: 'right' });
await takeEditorScreenshot(page);
},
);
test(
'Add monomers in macro mode then switch to micro mode and check that it can not be moved',
{ tag: ['@IncorrectResultBecauseOfBug'] },
async () => {
/*
Test case: Macro-Micro-Switcher
Description: Sequence of monomers moved to a new position in Micro mode
Now test working not properly because we have bug https://github.com/epam/ketcher/issues/3658
*/
const x1 = 400;
const y1 = 400;
const x2 = 500;
const y2 = 500;
await turnOnMacromoleculesEditor(page);
await openFileAndAddToCanvasMacro(
'KET/three-monomers-not-connected-with-bonds.ket',
page,
);
await turnOnMicromoleculesEditor(page);
await page.getByText('Edc').hover();
await dragMouseTo(x1, y1, page);
await page.getByText('Edc').hover();
await dragMouseTo(x2, y2, page);
await takeEditorScreenshot(page);
},
);
test('Check that Zoom In/Zoom Out/ Reset Zoom Tools work (UI Buttons) after switching to Macro mode', async () => {
/*
Test case: Macro-Micro-Switcher
Description: Zoom In/Zoom Out/ Reset Zoom Tools work after switching to Macro mode
*/
await pageReload(page);
const numberOfPressZoomIn = 5;
const numberOfPressZoomOut = 8;
await openFileAndAddToCanvasMacro(
'KET/three-monomers-connected-with-bonds.ket',
page,
);
await turnOnMicromoleculesEditor(page);
await turnOnMacromoleculesEditor(page);
await page.getByTestId('zoom-selector').click();
for (let i = 0; i < numberOfPressZoomIn; i++) {
await waitForRender(page, async () => {
await page.getByTestId('zoom-in-button').click();
});
}
await clickInTheMiddleOfTheScreen(page);
await takeEditorScreenshot(page);
await page.getByTestId('zoom-selector').click();
for (let i = 0; i < numberOfPressZoomOut; i++) {
await waitForRender(page, async () => {
await page.getByTestId('zoom-out-button').click();
});
}
await clickInTheMiddleOfTheScreen(page);
await takeEditorScreenshot(page);
await page.getByTestId('zoom-selector').click();
await page.getByTestId('reset-zoom-button').click();
await clickInTheMiddleOfTheScreen(page);
await takeEditorScreenshot(page);
});
test('Check that Zoom In/Zoom Out/ Reset Zoom Tools work (Mouse scroll) after switching to Macro mode', async () => {
/*
Test case: Macro-Micro-Switcher
Description: Zoom In/Zoom Out/ Reset Zoom Tools work after switching to Macro mode
*/
await openFileAndAddToCanvasMacro(
'KET/three-monomers-connected-with-bonds.ket',
page,
);
await turnOnMicromoleculesEditor(page);
await turnOnMacromoleculesEditor(page);
await moveMouseToTheMiddleOfTheScreen(page);
await zoomWithMouseWheel(page, -400);
await takeEditorScreenshot(page);
await zoomWithMouseWheel(page, 250);
await takeEditorScreenshot(page);
await page.getByTestId('zoom-selector').click();
await page.getByTestId('reset-zoom-button').click();
await clickInTheMiddleOfTheScreen(page);
await takeEditorScreenshot(page);
});
test('Check that the zoomed in/out structure from Macro mode become standart 100% when switch to Micro mode and again to Macro mode', async () => {
/*
Test case: Macro-Micro-Switcher
Description: Zoomed In/Out structure from Macro mode become standart 100% when switch to Micro mode and again to Macro mode
*/
const numberOfPressZoomIn = 5;
await openFileAndAddToCanvasMacro(
'KET/three-monomers-connected-with-bonds.ket',
page,
);
await page.getByTestId('zoom-selector').click();
for (let i = 0; i < numberOfPressZoomIn; i++) {
await waitForRender(page, async () => {
await page.getByTestId('zoom-in-button').click();
});
}
await clickInTheMiddleOfTheScreen(page);
await turnOnMicromoleculesEditor(page);
await takeEditorScreenshot(page);
await zoomWithMouseWheel(page, 250);
await turnOnMacromoleculesEditor(page);
await takeEditorScreenshot(page);
});
test('Add to Favorites section Peptides, Sugars, Bases, Phosphates and CHEMs then switch to Micro mode and back', async () => {
/*
Test case: Macro-Micro-Switcher
Description: Added to Favorites section Peptides, Sugars, Bases, Phosphates and CHEMs
when switching from Macro mode to Micro mode and back to Macro is saved
*/
await pageReload(page);
await addToFavoritesMonomers(page);
await page.getByTestId('FAVORITES-TAB').click();
await turnOnMicromoleculesEditor(page);
await turnOnMacromoleculesEditor(page);
await takeMonomerLibraryScreenshot(page);
});
test('Check that the Ket-structure pasted from the clipboard in Macro mode is visible in Micro mode.', async () => {
/*
Test case: Macro-Micro-Switcher
Description: Ket-structure pasted from the clipboard in Macro mode is visible in Micro mode
*/
await turnOnMacromoleculesEditor(page);
await pasteFromClipboard(
page,
FILE_TEST_DATA.oneFunctionalGroupExpandedKet,
);
await clickInTheMiddleOfTheScreen(page);
await turnOnMicromoleculesEditor(page);
await takeEditorScreenshot(page);
});
test('Check that the Mol-structure pasted from the clipboard in Macro mode is visible in Micro mode.', async () => {
/*
Test case: Macro-Micro-Switcher
Description: Mol-structure pasted from the clipboard in Macro mode is visible in Micro mode
*/
await pageReload(page);
await pasteFromClipboard(
page,
FILE_TEST_DATA.functionalGroupsExpandedContractedV3000,
'.mol',
);
await clickInTheMiddleOfTheScreen(page);
await turnOnMicromoleculesEditor(page);
await takeEditorScreenshot(page);
});
const tests = [
{ button: TopPanelButton.Layout, description: 'Layout' },
{ button: TopPanelButton.Clean, description: 'Clean Up' },
];
for (const testInfo of tests) {
test(`Check that Pressing ${testInfo.description} button not erase all macromolecules from canvas`, async () => {
/*
Test case: Macro-Micro-Switcher/3712
Description: Pressing Layout or Clean Up button not erase all macromolecules from canvas
*/
await turnOnMacromoleculesEditor(page);
await page.getByTestId('A___Alanine').click();
await clickInTheMiddleOfTheScreen(page);
await turnOnMicromoleculesEditor(page);
await waitForSpinnerFinishedWork(
page,
async () => await selectTopPanelButton(testInfo.button, page),
);
await takeEditorScreenshot(page);
});
}
test('Check that for CHEMs monomer from when switch to micro mode restricted remove abbreviation', async () => {
/*
Test case: Macro-Micro-Switcher
Description: Remove abbreviation restricted for CHEMs in micro mode.
*/
await turnOnMacromoleculesEditor(page);
await page.getByTestId('CHEM-TAB').click();
await page.getByTestId('Test-6-Ch___Test-6-AP-Chem').click();
await clickInTheMiddleOfTheScreen(page);
await turnOnMicromoleculesEditor(page);
await page.getByText('Test-6-Ch').click({ button: 'right' });
await takeEditorScreenshot(page);
});
test(
'The 3D view works for micromolecules when there are macromolecules on the canvas',
{
tag: ['@IncorrectResultBecauseOfBug'],
},
async () => {
/*
Test case: Macro-Micro-Switcher/#4203
Description: The 3D view works for micromolecules when there are macromolecules on the canvas.
Now test working not properly because we have open ticket https://github.com/epam/ketcher/issues/4203
After closing the ticket, should update the screenshots.
*/
await turnOnMacromoleculesEditor(page);
await page.getByTestId('PEPTIDES-TAB').click();
await page.getByTestId(Peptides.BetaAlanine).click();
await clickInTheMiddleOfTheScreen(page);
await turnOnMicromoleculesEditor(page);
await selectRing(RingButton.Benzene, page);
await clickInTheMiddleOfTheScreen(page);
await selectTopPanelButton(TopPanelButton.ThreeD, page);
await takeEditorScreenshot(page, {
maxDiffPixelRatio: 0.05,
});
},
);
test('Check that there are no errors in DevTool console when switching to full screen mode after switching from micro mode', async () => {
/*
Test case: Macro-Micro-Switcher/#4094
Description: There are no errors in DevTool console when switching to full screen mode after switching from micro mode.
*/
page.on('console', (msg) => {
if (msg.type() === 'error') {
test.fail(
msg.type() === 'error',
`There is error in console: ${msg.text}`,
);
}
});
await turnOnMacromoleculesEditor(page);
await page.getByTestId(Peptides.BetaAlanine).click();
await clickInTheMiddleOfTheScreen(page);
await turnOnMicromoleculesEditor(page);
await turnOnMacromoleculesEditor(page);
await page.locator('.css-1kbfai8').click();
});
test('Check the pop-up window appear in fullscreen mode after clicking the “Open/Save” button', async () => {
/*
Test case: Macro-Micro-Switcher/#4173
Description: The pop-up window appear in fullscreen mode after clicking the “Open/Save” button.
*/
page.on('console', (msg) => {
if (msg.type() === 'error') {
test.fail(
msg.type() === 'error',
`There is error in console: ${msg.text}`,
);
}
});
await page.locator('.css-1kbfai8').click();
await selectTopPanelButton(TopPanelButton.Open, page);
await takeEditorScreenshot(page);
await page.getByTitle('Close window').click();
await selectTopPanelButton(TopPanelButton.Save, page);
await takeEditorScreenshot(page);
});
});
test.describe('Macro-Micro-Switcher', () => {
test.beforeEach(async () => {
await turnOnMicromoleculesEditor(page);
});
test('Check that the Mol-structure opened from the file in Micro mode is visible on Macro mode when hover on it', async () => {
/*
Test case: Macro-Micro-Switcher
Description: Mol-structure opened from the file in Micro mode is visible on Macro mode when hover on it
*/
await openFileAndAddToCanvas(
'Molfiles-V2000/glutamine.mol',
page,
topLeftCorner.x,
topLeftCorner.y,
);
await turnOnMacromoleculesEditor(page);
await page.getByText('F1').locator('..').hover();
await takeEditorScreenshot(page);
});
test('Check that the Ket-structure opened from the file in Micro mode is visible in Macro mode when hover on it', async () => {
/*
Test case: Macro-Micro-Switcher
Description: Mol-structure opened from the file in Micro mode is visible on Macro mode when hover on it
*/
await openFileAndAddToCanvas(
'KET/stereo-and-structure.ket',
page,
topLeftCorner.x,
topLeftCorner.y,
);
await turnOnMacromoleculesEditor(page);
await page.getByText('F1').locator('..').hover();
await takeEditorScreenshot(page);
});
test('Create two Benzene rings structure with Charge Plus (+) and Charge Plus (-) Tool added in Micro mode and switch to Macro mode', async () => {
/*
Test case: Macro-Micro-Switcher
Description: Structure exists on the canvas with changes by Charge Plus (+) Tool and Charge Plus (-).
*/
await openFileAndAddToCanvas(
'KET/two-benzene-charged.ket',
page,
topLeftCorner.x,
topLeftCorner.y,
);
await turnOnMacromoleculesEditor(page);
await page.getByText('F2').locator('..').hover();
await takeEditorScreenshot(page);
});
test('Create two Benzene rings structure with some text added in Micro mode and switch to Macro mode.', async () => {
/*
Test case: Macro-Micro-Switcher
Description: Structure exists on the canvas without text.
*/
await openFileAndAddToCanvas(
'KET/benzene-rings-with-text.ket',
page,
topLeftCorner.x,
topLeftCorner.y,
);
await turnOnMacromoleculesEditor(page);
await page.getByText('F1').locator('..').hover();
await takeEditorScreenshot(page);
});
test('Create two Benzene rings structure with Shape Ellipse Tool added in Micro mode and switch to Macro mode.', async () => {
/*
Test case: Macro-Micro-Switcher
Description: Structure exists on the canvas without Shape Ellipse.
*/
await openFileAndAddToCanvas(
'KET/two-benzene-and-ellipse.ket',
page,
topLeftCorner.x,
topLeftCorner.y,
);
await turnOnMacromoleculesEditor(page);
await takeEditorScreenshot(page);
});
test('Create two Benzene rings structure with Arrow Open Angle Tool added in Micro mode and switch to Macro mode.', async () => {
/*
Test case: Macro-Micro-Switcher
Description: Structures exists on the canvas without arrow ( Arrow Open Angle Tool )
*/
await openFileAndAddToCanvas(
'KET/two-benzene-and-arrow.ket',
page,
topLeftCorner.x,
topLeftCorner.y,
);
await turnOnMacromoleculesEditor(page);
await takeEditorScreenshot(page);
});
test('Create ABS, new OR Group, new AND Group. Switch to Macro mode and check that ABS, AND and OR isn not appear.', async () => {
/*
Test case: Macro-Micro-Switcher
Description: In Macro mode ABS, AND and OR is not appear
*/
const xOffsetFromCenter = 200;
const yOffsetFromCenter = 0;
await openFileAndAddToCanvas(
'KET/three-alpha-d-allopyranose.ket',
page,
xOffsetFromCenter,
yOffsetFromCenter,
);
await turnOnMacromoleculesEditor(page);
await waitForRender(page, async () => {
await page.getByText('F1').locator('..').hover();
});
await takeEditorScreenshot(page);
});
test('Create two Benzene rings structure with Reaction Plus Tool in Micro mode and switch to Macro mode.', async () => {
/*
Test case: Macro-Micro-Switcher
Description: In Macro mode plus sign is not appear
*/
await openFileAndAddToCanvas(
'KET/two-benzene-and-plus.ket',
page,
topLeftCorner.x,
topLeftCorner.y,
);
await turnOnMacromoleculesEditor(page);
await takeEditorScreenshot(page);
});
test('Check that the Ket-structure pasted from the clipboard in Micro mode is visible in Macro mode when hover on it.', async () => {
/*
Test case: Macro-Micro-Switcher
Description: Ket-structure pasted from the clipboard in Micro mode is visible in Macro mode when hover on it
*/
const topLeftCornerCoords = {
x: 500,
y: 100,
};
await pasteFromClipboard(
page,
FILE_TEST_DATA.oneFunctionalGroupExpandedKet,
);
await page.mouse.click(topLeftCornerCoords.x, topLeftCornerCoords.y);
await turnOnMacromoleculesEditor(page);
await page.getByText('F1').locator('..').click();
await takeEditorScreenshot(page);
});
test('Check that the Mol-structure pasted from the clipboard in Micro mode is visible in Macro mode when hover on it.', async () => {
/*
Test case: Macro-Micro-Switcher
Description: Mol-structure pasted from the clipboard in Micro mode is visible in Macro mode when hover on it
*/
const coordsToClick = {
x: 400,
y: 100,
};
await pasteFromClipboard(
page,
FILE_TEST_DATA.functionalGroupsExpandedContractedV3000,
'.mol',
);
await waitForRender(page, async () => {
await page.mouse.click(coordsToClick.x, coordsToClick.y);
});
await turnOnMacromoleculesEditor(page);
await page.getByText('F1').locator('..').hover();
await takeEditorScreenshot(page);
});
test(
'Make full screen mode in micro mode and switch to macro mode.',
{ tag: ['@IncorrectResultBecauseOfBug'] },
async () => {
/*
Test case: Macro-Micro-Switcher
Description: Full screen mode is not reset
Test working not properly now because we have bug https://github.com/epam/ketcher/issues/3656
*/
await openFileAndAddToCanvas(
'KET/two-benzene-and-plus.ket',
page,
topLeftCorner.x,
topLeftCorner.y,
);
await page.getByTestId('fullscreen-mode-button').click();
await turnOnMacromoleculesEditor(page);
await takePageScreenshot(page);
},
);
test('Confirm that in macromolecules mode, atoms are displayed as dots without any accompanying text or additional information bonds as one line', async () => {
/*
Test case: Macro-Micro-Switcher
Description: Atoms displayed as dots, without any text or other additional information.
Bonds displayed as one line regardless which type of bond it is.
Now test working not properly because we have open ticket https://github.com/epam/ketcher/issues/3618
After closing the ticket, should update the screenshots.
*/
await openFileAndAddToCanvas('KET/all-type-of-atoms-and-bonds.ket', page);
await turnOnMacromoleculesEditor(page);
await page.getByTestId('zoom-selector').click();
for (let i = 0; i < 3; i++) {
await waitForRender(page, async () => {
await page.getByTestId('zoom-out-button').click();
});
}
await clickInTheMiddleOfTheScreen(page);
await takeEditorScreenshot(page);
});
test('Open a macro file and put in center of canvas in micro mode then switch to macro', async () => {
/*
Test case: Macro-Micro-Switcher/#3902
Description: Structure is in left upper corner of canvas
*/
await pageReload(page);
await turnOnMicromoleculesEditor(page);
await openFileAndAddToCanvas('KET/peptides-connected-with-bonds.ket', page);
await takeEditorScreenshot(page);
await turnOnMacromoleculesEditor(page);
await takeEditorScreenshot(page);
});
test('Settings related to atom and bond display are ignored in macromolecules mode', async () => {
/*
Test case: Macro-Micro-Switcher
Description: Settings related to atom and bond display are ignored in macromolecules mode,
and display is consistently set to dots for atoms and single lines for bonds.
Now test working not properly because we have open ticket https://github.com/epam/ketcher/issues/3618
After closing the ticket, should update the screenshots.
*/
await openFileAndAddToCanvas('KET/all-type-of-atoms-and-bonds.ket', page);
await setAtomAndBondSettings(page);
await takeEditorScreenshot(page);
await turnOnMacromoleculesEditor(page);
await page.getByTestId('zoom-selector').click();
for (let i = 0; i < 3; i++) {
await waitForRender(page, async () => {
await page.getByTestId('zoom-out-button').click();
});
}
await clickInTheMiddleOfTheScreen(page);
await takeEditorScreenshot(page);
});
test('Check that attachment point added in micro mode used as attachment point when switch to macro mode', async () => {
/*
Test case: Macro-Micro-Switcher/#4530
Description: Attachment point added in micro mode used as attachment point when switch to macro mode.
*/
await openFileAndAddToCanvas(
'KET/one-attachment-point-added-in-micro-mode.ket',
page,
);
await takeEditorScreenshot(page);
await turnOnMacromoleculesEditor(page);
await selectSingleBondTool(page);
await page.getByText('F1').locator('..').hover();
await takeEditorScreenshot(page);
});
test('Ensure that system does not allow create s-group if structure have attachment point', async () => {
/*
Test case: Macro-Micro-Switcher/#4530
Description: System does not allow create s-group if structure have attachment point.
*/
await openFileAndAddToCanvas(
'KET/one-attachment-point-added-in-micro-mode.ket',
page,
);
await page.keyboard.press('Control+a');
await selectLeftPanelButton(LeftPanelButton.S_Group, page);
await takeEditorScreenshot(page);
await selectLeftPanelButton(LeftPanelButton.Erase, page);
await page.getByText('R1').locator('..').click();
await takeEditorScreenshot(page);
await page.keyboard.press('Control+a');
await selectLeftPanelButton(LeftPanelButton.S_Group, page);
await takeEditorScreenshot(page);
});
test('Check that multiple attachment points added in micro mode used as attachment point when switch to macro mode', async () => {
/*
Test case: Macro-Micro-Switcher/#4530
Description: Multiple attachment points added in micro mode used as attachment point when switch to macro mode.
*/
await openFileAndAddToCanvas(
'KET/more-than-one-attachment-point.ket',
page,
);
await takeEditorScreenshot(page);
await turnOnMacromoleculesEditor(page);
await selectSingleBondTool(page);
await page.getByText('F1').locator('..').hover();
await takeEditorScreenshot(page);
});
test('Verify attachment points can be added/removed via context menu', async () => {
/*
Test case: Macro-Micro-Switcher/#4530
Description: Attachment points can be added/removed via context menu.
*/
await drawBenzeneRing(page);
await addSuperatomAttachmentPoint(page, 'C', 1);
await addSuperatomAttachmentPoint(page, 'C', 2);
await addSuperatomAttachmentPoint(page, 'C', 3);
await takeEditorScreenshot(page);
await removeSuperatomAttachmentPoint(page, 'C', 2);
await takeEditorScreenshot(page);
await turnOnMacromoleculesEditor(page);
await selectSingleBondTool(page);
await page.getByText('F1').locator('..').hover();
await takeEditorScreenshot(page);
});
test('Ensure that new attachment points are labeled correctly (R1/.../R8) based on the next free attachment point number', async () => {
/*
Test case: Macro-Micro-Switcher/#4530
Description: New attachment points are labeled correctly (R1/.../R8) based on the next free attachment point number.
*/
// await openFileAndAddToCanvas('Molfiles-V2000/long-chain.mol', page);
await openFileAndAddToCanvas('KET/long-chain.ket', page);
await addSuperatomAttachmentPoint(page, 'C', 4);
await addSuperatomAttachmentPoint(page, 'C', 6);
await addSuperatomAttachmentPoint(page, 'C', 8);
await addSuperatomAttachmentPoint(page, 'C', 10);
await addSuperatomAttachmentPoint(page, 'C', 12);
await addSuperatomAttachmentPoint(page, 'C', 14);
await addSuperatomAttachmentPoint(page, 'C', 16);
await addSuperatomAttachmentPoint(page, 'C', 17);
await takeEditorScreenshot(page);
});
test('Verify that system does not create a new attachment point if all 8 attachment points (R1-R8) already exist in the structure', async () => {
/*
Test case: Macro-Micro-Switcher/#4530
Description: System does not create a new attachment point if all 8 attachment points (R1-R8) already exist in the structure.
*/
await openFileAndAddToCanvas(
'KET/chain-with-eight-attachment-points.ket',
page,
);
await clickOnAtom(page, 'C', 9, 'right');
await takeEditorScreenshot(page);
});
test('Check that system start to use missed labels if user want to create AP greater that R8 (if it has R1,R3-R8 - attempt to add causes R2 selection)', async () => {
/*
Test case: Macro-Micro-Switcher/#4530
Description: System does not create a new attachment point if all 8 attachment points (R1-R8) already exist in the structure.
*/
await openFileAndAddToCanvas(
'KET/chain-with-eight-attachment-points.ket',
page,
);
await selectLeftPanelButton(LeftPanelButton.Erase, page);
await page.getByText('R2').locator('..').click();
await addSuperatomAttachmentPoint(page, 'C', 2);
await takeEditorScreenshot(page);
});
test('Check that in context menu for AP - only Delete avaliable', async () => {
/*