-
Notifications
You must be signed in to change notification settings - Fork 187
/
Copy pathrna-library.spec.ts
877 lines (819 loc) · 30 KB
/
rna-library.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
import {
turnOnMacromoleculesEditor,
turnOnMicromoleculesEditor,
} from '@utils/macromolecules';
import { Page, test, expect } from '@playwright/test';
import {
Bases,
Phosphates,
Sugars,
addMonomerToCenterOfCanvas,
clickInTheMiddleOfTheScreen,
dragMouseTo,
moveMouseToTheMiddleOfTheScreen,
openFileAndAddToCanvasMacro,
pressButton,
receiveFileComparisonData,
saveToFile,
selectEraseTool,
selectMonomer,
selectRectangleSelectionTool,
selectSingleBondTool,
takeEditorScreenshot,
takeLeftToolbarMacromoleculeScreenshot,
takeMonomerLibraryScreenshot,
takePageScreenshot,
takePresetsScreenshot,
takeRNABuilderScreenshot,
waitForPageInit,
waitForRender,
moveMouseAway,
} from '@utils';
import { getKet } from '@utils/formats';
async function expandCollapseRnaBuilder(page: Page) {
await page
.locator('div')
.filter({ hasText: /^RNA Builder$/ })
.getByRole('button')
.click();
}
async function drawThreeMonomers(page: Page) {
const x = 800;
const y = 350;
const x1 = 650;
const y1 = 150;
await selectMonomer(page, Sugars.ThreeA6);
await clickInTheMiddleOfTheScreen(page);
await selectMonomer(page, Bases.NBebnzylAdenine);
await page.mouse.click(x, y);
await selectMonomer(page, Phosphates.Phosphate);
await page.mouse.click(x1, y1);
}
async function drawThreeMonomersConnectedWithBonds(page: Page) {
const sugars = await page.getByText('3A6').locator('..');
const sugar1 = sugars.nth(0);
const bases = await page.getByText('baA').locator('..');
const base1 = bases.nth(0);
const phosphates = await page.getByText('P').locator('..');
const phosphate1 = phosphates.nth(0);
await drawThreeMonomers(page);
await selectSingleBondTool(page);
await sugar1.hover();
await page.mouse.down();
await base1.hover();
await page.mouse.up();
await sugar1.hover();
await page.mouse.down();
await phosphate1.hover();
await page.mouse.up();
}
async function drawBasePhosphate(page: Page) {
const x = 800;
const y = 350;
const bases = await page.getByText('baA').locator('..');
const base1 = bases.nth(0);
const phosphates = await page.getByText('P').locator('..');
const phosphate1 = phosphates.nth(0);
await selectMonomer(page, Bases.NBebnzylAdenine);
await clickInTheMiddleOfTheScreen(page);
await selectMonomer(page, Phosphates.Phosphate);
await page.mouse.click(x, y);
await selectSingleBondTool(page);
await base1.hover();
await page.mouse.down();
await phosphate1.hover();
await page.mouse.up();
await pressButton(page, 'R2');
await pressButton(page, 'Connect');
}
async function drawSugarPhosphate(page: Page) {
const x = 800;
const y = 350;
const sugars = await page.getByText('3A6').locator('..');
const sugar1 = sugars.nth(0);
const phosphates = await page.getByText('P').locator('..');
const phosphate1 = phosphates.nth(0);
await selectMonomer(page, Sugars.ThreeA6);
await clickInTheMiddleOfTheScreen(page);
await selectMonomer(page, Phosphates.Phosphate);
await page.mouse.click(x, y);
await selectSingleBondTool(page);
await sugar1.hover();
await page.mouse.down();
await phosphate1.hover();
await page.mouse.up();
}
async function drawSugarBase(page: Page) {
const x = 800;
const y = 350;
const sugars = await page.getByText('3A6').locator('..');
const sugar1 = sugars.nth(0);
const bases = await page.getByText('baA').locator('..');
const base1 = bases.nth(0);
await selectMonomer(page, Sugars.ThreeA6);
await clickInTheMiddleOfTheScreen(page);
await selectMonomer(page, Bases.NBebnzylAdenine);
await page.mouse.click(x, y);
await selectSingleBondTool(page);
await sugar1.hover();
await page.mouse.down();
await base1.hover();
await page.mouse.up();
}
async function pressEscapeWhenPullBond(page: Page) {
const anyPointX = 300;
const anyPointY = 500;
await page.mouse.down();
await page.mouse.move(anyPointX, anyPointY);
await page.keyboard.press('Escape');
await waitForRender(page, async () => {
await page.mouse.up();
});
}
test.describe('RNA Library', () => {
test.beforeEach(async ({ page }) => {
await waitForPageInit(page);
await turnOnMacromoleculesEditor(page);
await page.getByTestId('RNA-TAB').click();
});
test('Check that switch between Macro and Micro mode does not crash application', async ({
page,
}) => {
/*
Test case: #3498
Description: Application does not crash.
Test working incorrect because we have bug: https://github.com/epam/ketcher/issues/3498
*/
await turnOnMicromoleculesEditor(page);
await turnOnMacromoleculesEditor(page);
await takePageScreenshot(page);
});
test('Check the RNA components panel', async ({ page }) => {
/*
Test case: #2748, #2751 - RNA Builder. Accordion component
Description: Check the RNA components panel.
RNA panel consist of:
RNA Builder(collapsed), Presets(5)(expanded), Sugars(199)(collapsed),
Bases(160)(collapsed), Phosphates(32)(collapsed)
*/
await takeMonomerLibraryScreenshot(page);
});
test('Expand RNA Builder', async ({ page }) => {
/*
Test case: #2748, #2751 - RNA Builder. Accordion component
Description: After click on arrow RNA Builder expanded.
*/
await expandCollapseRnaBuilder(page);
await takeMonomerLibraryScreenshot(page);
});
const testData = [
{
component: 'Presets',
description:
'After clicking on the arrow, the Presets component collapsed.',
},
{
component: 'Sugars',
description:
'After clicking on the arrow, the Sugars component expanded.',
},
{
component: 'Bases',
description: 'After clicking on the arrow, the Bases component expanded.',
},
{
component: 'Phosphates',
description:
'After clicking on the arrow, the Phosphates component expanded.',
},
];
for (const data of testData) {
test(`Check ${data.component} component`, async ({ page }) => {
/*
Test case: #2748, #2751 - RNA Builder. Accordion component
*/
await page.getByTestId(`summary-${data.component}`).click();
await takeMonomerLibraryScreenshot(page);
});
}
test('Add Sugar monomer to canvas', async ({ page }) => {
/*
Test case: #2507 - Add RNA monomers to canvas
Description: The selected sugar monomer should be added to the canvas
in the form of a square with rounded edges and in the corresponding color.
*/
await addMonomerToCenterOfCanvas(page, Sugars.TwelveddR);
await takeEditorScreenshot(page);
});
test('Add Base monomer to canvas', async ({ page }) => {
/*
Test case: #2507 - Add RNA monomers to canvas
Description: The selected base monomer should be added to the canvas
in the form of a rhombus and in the corresponding color.
*/
await addMonomerToCenterOfCanvas(page, Bases.Adenine);
await takeEditorScreenshot(page);
});
test('Add Phosphate monomer to canvas', async ({ page }) => {
/*
Test case: #2507 - Add RNA monomers to canvas
Description: The selected phosphate monomer should be added to the canvas
in the form of a circle and in the corresponding color.
*/
await addMonomerToCenterOfCanvas(page, Phosphates.Test6Ph);
await takeEditorScreenshot(page);
});
test('Sugar preview window when hovered on canvas', async ({ page }) => {
/*
Test case: #2507 - Add RNA monomers to canvas
Description: The selected sugar monomer should be added to the canvas
in the form of a square with rounded edges and in the corresponding color.
When hover over monomer window with preview appears.
*/
await addMonomerToCenterOfCanvas(page, Sugars.TwelveddR);
await page.getByText('12ddR').locator('..').first().hover();
await takeEditorScreenshot(page);
});
test('Base preview window when hovered on canvas', async ({ page }) => {
/*
Test case: #2507 - Add RNA monomers to canvas
Description: The selected base monomer should be added to the canvas
in the form of a rhombus and in the corresponding color.
When hover over monomer window with preview appears.
*/
await addMonomerToCenterOfCanvas(page, Bases.TClampOMe);
await page.getByText('clA').locator('..').first().hover();
await takeEditorScreenshot(page);
});
test('Phosphate preview window when hovered on canvas', async ({ page }) => {
/*
Test case: #2507 - Add RNA monomers to canvas
Description: The selected phosphate monomer should be added to the canvas
in the form of a circle and in the corresponding color.
When hover over monomer window with preview appears.
*/
await addMonomerToCenterOfCanvas(page, Phosphates.Test6Ph);
await page.getByText('Test-6-Ph').locator('..').first().hover();
await takeEditorScreenshot(page);
});
test('Add Custom preset to Presets section', async ({ page }) => {
/*
Test case: #2759 - Edit RNA mode
Description: Custom presets added to Presets section.
*/
await expandCollapseRnaBuilder(page);
await selectMonomer(page, Sugars.TwelveddR);
await selectMonomer(page, Bases.Adenine);
await selectMonomer(page, Phosphates.Test6Ph);
await page.getByTestId('add-to-presets-btn').click();
await page.getByTestId('12ddR(A)Test-6-Ph_A_12ddR_Test-6-Ph').click();
await expandCollapseRnaBuilder(page);
await takePresetsScreenshot(page);
});
test('Add Custom preset to Presets section and display after page reload', async ({
page,
}) => {
await expandCollapseRnaBuilder(page);
await selectMonomer(page, Sugars.TwelveddR);
await selectMonomer(page, Bases.Adenine);
await selectMonomer(page, Phosphates.Test6Ph);
await page.getByTestId('add-to-presets-btn').click();
await page.getByTestId('12ddR(A)Test-6-Ph_A_12ddR_Test-6-Ph').click();
await expandCollapseRnaBuilder(page);
await takePresetsScreenshot(page);
await page.reload();
await waitForPageInit(page);
await turnOnMacromoleculesEditor(page);
await page.getByTestId('RNA-TAB').click();
await page.getByTestId('12ddR(A)Test-6-Ph_A_12ddR_Test-6-Ph').click();
await expandCollapseRnaBuilder(page);
await takePresetsScreenshot(page);
});
test('Add Custom preset to Canvas', async ({ page }) => {
/*
Test case: #2507 - Add RNA monomers to canvas
Description: Custom presets added to Canvas.
*/
await expandCollapseRnaBuilder(page);
await selectMonomer(page, Sugars.ThreeA6);
await selectMonomer(page, Bases.NBebnzylAdenine);
await selectMonomer(page, Phosphates.Boranophosphate);
await page.getByTestId('add-to-presets-btn').click();
await page.getByTestId('3A6(baA)bP_baA_3A6_bP').click();
await clickInTheMiddleOfTheScreen(page);
await selectRectangleSelectionTool(page);
await takeEditorScreenshot(page);
});
test('Add RNA to canvas when Sugar does not contain R3 attachment point(for example 3SS6(nC65C)oxy/ am6(daA)Rsp )', async ({
page,
}) => {
/*
Test case: #2507 - Add RNA monomers to canvas https://github.com/epam/ketcher/issues/3615
Description: RNA added to canvas when Sugar does not contain R3 attachment point.
The test is currently not functioning correctly as the bug has not been fixed
*/
await expandCollapseRnaBuilder(page);
await selectMonomer(page, Sugars.ThreeSS6);
await selectMonomer(page, Bases.NBebnzylAdenine);
await selectMonomer(page, Phosphates.Boranophosphate);
await page.getByTestId('add-to-presets-btn').click();
await page.getByTestId('3SS6(baA)bP_baA_3SS6_bP').click();
await clickInTheMiddleOfTheScreen(page);
await selectRectangleSelectionTool(page);
await takeEditorScreenshot(page);
});
test('Add to presets (different combinations: Sugar+Base', async ({
page,
}) => {
/*
Test case: #2759 - Edit RNA mode
Description: Custom presets added to Presets section.
*/
await expandCollapseRnaBuilder(page);
await selectMonomer(page, Sugars.TwelveddR);
await selectMonomer(page, Bases.Adenine);
await page.getByTestId('add-to-presets-btn').click();
await page.getByTestId('12ddR(A)_A_12ddR_.').click();
await expandCollapseRnaBuilder(page);
await takePresetsScreenshot(page);
});
test('Add to presets (different combinations: Sugar+Phosphate', async ({
page,
}) => {
/*
Test case: #2759 - Edit RNA mode
Description: Custom presets added to Presets section.
*/
await expandCollapseRnaBuilder(page);
await selectMonomer(page, Sugars.TwelveddR);
await selectMonomer(page, Phosphates.Boranophosphate);
await page.getByTestId('add-to-presets-btn').click();
await page.getByTestId('12ddR()bP_._12ddR_bP').click();
await expandCollapseRnaBuilder(page);
await takePresetsScreenshot(page);
});
test('Add to presets (different combinations: Base+Phosphate', async ({
page,
}) => {
/*
Test case: #2759 - Edit RNA mode
Description: Custom presets added to Presets section.
*/
await expandCollapseRnaBuilder(page);
await selectMonomer(page, Bases.Adenine);
await selectMonomer(page, Phosphates.Boranophosphate);
await page.getByTestId('add-to-presets-btn').click();
await page.getByTestId('(A)bP_A_._bP').click();
await takePresetsScreenshot(page);
});
test('Add Custom preset to Presets section and Edit', async ({ page }) => {
/*
Test case: #2759 - Edit RNA mode
Description: Custom presets added to Presets section and can be edited.
*/
await expandCollapseRnaBuilder(page);
await selectMonomer(page, Sugars.TwelveddR);
await selectMonomer(page, Bases.Adenine);
await selectMonomer(page, Phosphates.Test6Ph);
await page.getByTestId('add-to-presets-btn').click();
await page.getByTestId('12ddR(A)Test-6-Ph_A_12ddR_Test-6-Ph').click({
button: 'right',
});
await page.getByTestId('edit').locator('div').click();
await page.getByTestId('rna-builder-slot--base').click();
await page.getByTestId('baA___N-benzyl-adenine').click();
await page.getByTestId('save-btn').click();
await page.getByTestId('12ddR(baA)Test-6-Ph_baA_12ddR_Test-6-Ph').click();
// To avoid unstable test execution
// Allows see a right preset in a viewport
await expandCollapseRnaBuilder(page);
await takePresetsScreenshot(page);
});
test('Add Custom preset to Presets section then Duplicate and Edit', async ({
page,
}) => {
/*
Test case: #2759 - Edit RNA mode
Description: Custom presets added to Presets section then can be duplicated and edited.
*/
await expandCollapseRnaBuilder(page);
await selectMonomer(page, Sugars.TwelveddR);
await selectMonomer(page, Bases.Adenine);
await selectMonomer(page, Phosphates.Test6Ph);
await page.getByTestId('add-to-presets-btn').click();
await page.getByTestId('12ddR(A)Test-6-Ph_A_12ddR_Test-6-Ph').click({
button: 'right',
});
await page.getByTestId('duplicateandedit').locator('div').click();
await page.getByTestId('save-btn').click();
// To avoid unstable test execution
// Allows see a right preset in a veiwport
await expandCollapseRnaBuilder(page);
await page.getByTestId('12ddR(A)Test-6-Ph_Copy_A_12ddR_Test-6-Ph').click({
button: 'right',
});
await page.getByTestId('edit').click();
await page.getByTestId('rna-builder-slot--phosphate').click();
await page.getByTestId('P___Phosphate').click();
await page.getByTestId('save-btn').click();
await page.getByTestId('12ddR(A)P_A_12ddR_P').click();
await takePresetsScreenshot(page);
});
test('Add Custom preset to Presets section and Delete', async ({ page }) => {
/*
Test case: #2759 - Edit RNA mode
Description: Custom presets added to Presets section and can be deleted.
Test working incorrect because we have bug: https://github.com/epam/ketcher/issues/3561
*/
await expandCollapseRnaBuilder(page);
await selectMonomer(page, Sugars.TwelveddR);
await selectMonomer(page, Bases.Adenine);
await selectMonomer(page, Phosphates.Test6Ph);
await page.getByTestId('add-to-presets-btn').click();
await page.getByTestId('12ddR(A)Test-6-Ph_A_12ddR_Test-6-Ph').click({
button: 'right',
});
await page.getByTestId('deletepreset').click();
await page.getByRole('button', { name: 'Delete' }).click();
await takePresetsScreenshot(page);
});
test('Add Custom preset to Presets section and Rename', async ({ page }) => {
/*
Test case: #2759 - Edit RNA mode
Description: Custom presets added to Presets section and can be renamed.
*/
await expandCollapseRnaBuilder(page);
await selectMonomer(page, Sugars.TwentyFiveR);
await selectMonomer(page, Bases.NBebnzylAdenine);
await selectMonomer(page, Phosphates.Boranophosphate);
await page.getByTestId('add-to-presets-btn').click();
await page.getByTestId('25R(baA)bP_baA_25R_bP').click({
button: 'right',
});
await page.getByTestId('edit').locator('div').click();
await page.getByPlaceholder('Name your structure').click();
await page.getByPlaceholder('Name your structure').fill('TestMonomers');
await page.getByTestId('save-btn').click();
await takePresetsScreenshot(page);
});
test('Autofilling RNA name when selects RNA parts', async ({ page }) => {
/*
Test case: #2759 - Edit RNA mode
Description: RNA name autofilling when selects RNA parts.
*/
await expandCollapseRnaBuilder(page);
await page.getByTestId('rna-builder-slot--sugar').click();
await page.getByTestId("3A6___6-amino-hexanol (3' end)").click();
await moveMouseAway(page);
await page.getByTestId('rna-builder-slot--base').click();
await page.getByTestId('baA___N-benzyl-adenine').click();
await moveMouseAway(page);
await page.getByTestId('rna-builder-slot--phosphate').click();
await page.getByTestId('bP___Boranophosphate').click();
await moveMouseAway(page);
await takeRNABuilderScreenshot(page);
});
test('Add names to RNA manually', async ({ page }) => {
/*
Test case: #2759 - Edit RNA mode
Description: RNA name added.
*/
await expandCollapseRnaBuilder(page);
await page.getByTestId('rna-builder-slot--sugar').click();
await page.getByTestId('25R___2,5-Ribose').click();
// To avoid unstable test execution
// Hide tooltip which overlays 'rna-builder-slot--base' element
await moveMouseAway(page);
await page.getByTestId('rna-builder-slot--base').click();
await page.getByTestId('A___Adenine').click();
await page.getByTestId('rna-builder-slot--phosphate').click();
await page.getByTestId('Test-6-Ph___Test-6-AP-Phosphate').click();
await page.getByPlaceholder('Name your structure').click();
await page.getByPlaceholder('Name your structure').fill('cTest');
await page.getByTestId('add-to-presets-btn').click();
await clickInTheMiddleOfTheScreen(page);
await takeRNABuilderScreenshot(page);
});
test('Highlight Sugar, Phosphate and Base in Library, once it chosen in RNA Builder', async ({
page,
}) => {
/*
Test case: #2759 - Edit RNA mode
Description: Sugar, Phosphate and Base highlighted in Library.
*/
const monomers = [
{
type: 'sugar',
groupName: 'Sugars',
name: "3A6___6-amino-hexanol (3' end)",
},
{ type: 'base', groupName: 'Bases', name: 'baA___N-benzyl-adenine' },
{
type: 'phosphate',
groupName: 'Phosphates',
name: 'bP___Boranophosphate',
},
];
await expandCollapseRnaBuilder(page);
for (const monomer of monomers) {
await page.getByTestId(`rna-builder-slot--${monomer.type}`).click();
await page.getByTestId(monomer.name).click();
await page
.getByTestId(`rna-accordion-details-${monomer.groupName}`)
.hover();
await page.mouse.wheel(0, 0);
await clickInTheMiddleOfTheScreen(page);
await takeMonomerLibraryScreenshot(page, { maxDiffPixelRatio: 0.03 });
}
});
test('Add Sugar-Base Combination to Canvas', async ({ page }) => {
/*
Test case: #2507 - Add RNA monomers to canvas
Description: Sugar-Base Combination added to Canvas.
*/
await expandCollapseRnaBuilder(page);
await selectMonomer(page, Sugars.ThreeA6);
await selectMonomer(page, Bases.NBebnzylAdenine);
await page.getByTestId('add-to-presets-btn').click();
await page.getByTestId('3A6(baA)_baA_3A6_.').click();
await clickInTheMiddleOfTheScreen(page);
await selectRectangleSelectionTool(page);
await takeEditorScreenshot(page);
});
test('Add Sugar-Phosphate Combination to Canvas', async ({ page }) => {
/*
Test case: #2507 - Add RNA monomers to canvas
Description: Sugar-Phosphate Combination added to Canvas.
*/
await expandCollapseRnaBuilder(page);
await selectMonomer(page, Sugars.ThreeA6);
await selectMonomer(page, Phosphates.Boranophosphate);
// To avoid unstable test execution
// Hide tooltip which overlays 'add-to-presets-btn' element
await moveMouseAway(page);
await page.getByTestId('add-to-presets-btn').click();
await page.getByTestId('3A6()bP_._3A6_bP').click();
await clickInTheMiddleOfTheScreen(page);
await selectRectangleSelectionTool(page);
await takeEditorScreenshot(page);
});
test('Can not Add Base-Phosphate Combination to Canvas', async ({ page }) => {
/*
Test case: #2507 - Add RNA monomers to canvas
Description: Base-Phosphate Combination not added to Canvas.
*/
await expandCollapseRnaBuilder(page);
await selectMonomer(page, Bases.NBebnzylAdenine);
await selectMonomer(page, Phosphates.Boranophosphate);
await page.getByTestId('add-to-presets-btn').click();
await page.getByTestId('(baA)bP_baA_._bP').click();
await moveMouseToTheMiddleOfTheScreen(page);
await takeEditorScreenshot(page);
});
test('Add Sugar and Base Combination to Canvas and connect with bond', async ({
page,
}) => {
/*
Test case: #2507 - Add RNA monomers to canvas
Description: Sugar and Base Combination added to Canvas and connect with bond.
*/
const bondLine = await page.locator('g[pointer-events="stroke"]');
await drawSugarBase(page);
await bondLine.hover();
await takeEditorScreenshot(page);
});
test('Add Sugar and Phosphate Combination to Canvas and connect with bond', async ({
page,
}) => {
/*
Test case: #2507 - Add RNA monomers to canvas
Description: Sugar and Phosphate Combination added to Canvas and connect with bond.
*/
const bondLine = await page.locator('g[pointer-events="stroke"]');
await drawSugarPhosphate(page);
await bondLine.hover();
await takeEditorScreenshot(page);
});
test('Add Base and Phosphate Combination to Canvas and connect with bond', async ({
page,
}) => {
/*
Test case: #2507 - Add RNA monomers to canvas
Description: Base and Phosphate Combination added to Canvas and connect with bond.
*/
const bondLine = await page.locator('g[pointer-events="stroke"]');
await drawBasePhosphate(page);
await bondLine.hover();
await takeEditorScreenshot(page);
});
test('Add Sugar-Base-Phosphate Combination to Canvas and connect with bond', async ({
page,
}) => {
/*
Test case: #2507 - Add RNA monomers to canvas
Description: Sugar-Base-Phosphate Combination added to Canvas and connect with bond.
*/
const bondLine = await page.locator('g[pointer-events="stroke"]').first();
await drawThreeMonomersConnectedWithBonds(page);
await bondLine.hover();
await takeEditorScreenshot(page);
});
const monomersToDelete = [
{ text: '12ddR', description: 'Sugar monomer deleted.' },
{ text: 'baA', description: 'Base monomer deleted.' },
{ text: 'P', description: 'Phosphate monomer deleted.' },
];
for (const monomer of monomersToDelete) {
test(`Open file from .ket and Delete ${monomer.text} monomer`, async ({
page,
}) => {
await openFileAndAddToCanvasMacro(
'KET/monomers-connected-with-bonds.ket',
page,
);
await selectEraseTool(page);
await page.getByText(monomer.text).locator('..').first().click();
await takeEditorScreenshot(page);
});
}
const monomerToDelete = [
{ text: '3A6', description: 'Sugar monomer deleted.' },
{ text: 'baA', description: 'Base monomer deleted.' },
{ text: 'P', description: 'Phosphate monomer deleted.' },
];
for (const monomer of monomerToDelete) {
test(`Draw Sugar-Base-Phosphate and Delete ${monomer.text} monomer`, async ({
page,
}) => {
await drawThreeMonomersConnectedWithBonds(page);
await selectEraseTool(page);
await page.getByText(monomer.text).locator('..').first().click();
await takeEditorScreenshot(page);
});
}
test('Draw Sugar-Base-Phosphate and Delete connecting bond', async ({
page,
}) => {
/*
Test case: Bond tool
Description: Bond deleted.
*/
const bondLine = await page.locator('g[pointer-events="stroke"]').first();
await drawThreeMonomersConnectedWithBonds(page);
await selectEraseTool(page);
await bondLine.click();
await takeEditorScreenshot(page);
});
test('Draw Sugar-Base-Phosphate and try to attach bond to occupied attachment point', async ({
page,
}) => {
/*
Test case: Bond tool
Description: A message appears at the bottom of the canvas:
Monomers don't have any connection point available.
*/
const sugars = await page.getByText('3A6').locator('..');
const sugar1 = sugars.nth(0);
const bases = await page.getByText('baA').locator('..');
const base1 = bases.nth(0);
const phosphates = await page.getByText('P').locator('..');
const phosphate1 = phosphates.nth(0);
await drawThreeMonomers(page);
await selectSingleBondTool(page);
await sugar1.hover();
await page.mouse.down();
await base1.hover();
await page.mouse.up();
await phosphate1.hover();
await page.mouse.down();
await base1.hover();
await page.mouse.up();
await takeEditorScreenshot(page);
});
const molecules = [
{ type: 'Sugars', description: '25R___2,5-Ribose' },
{ type: 'Bases', description: 'baA___N-benzyl-adenine' },
{ type: 'Phosphates', description: 'bP___Boranophosphate' },
];
for (const molecule of molecules) {
test(`Move ${molecule.type} on canvas to new position`, async ({
page,
}) => {
/*
Test case: #2507 - Add RNA monomers to canvas
Description: Sugar/Base/Phosphate moved to new position.
*/
const anyPointX = 300;
const anyPointY = 500;
await page.getByTestId(`summary-${molecule.type}`).click();
await page.getByTestId(molecule.description).click();
await clickInTheMiddleOfTheScreen(page);
await selectRectangleSelectionTool(page);
await clickInTheMiddleOfTheScreen(page);
await dragMouseTo(anyPointX, anyPointY, page);
await takeEditorScreenshot(page);
});
}
const monomersToMove = ['3A6', 'baA', 'P'];
for (const monomer of monomersToMove) {
test(`Draw Sugar-Base-Phosphate and Move ${monomer} monomer`, async ({
page,
}) => {
/*
Test case: #2507 - Add RNA monomers to canvas
Description: Sugar/Base/Phosphate monomer moved to new position.
Bonds are connected to monomers.
*/
const anyPointX = 300;
const anyPointY = 500;
await drawThreeMonomersConnectedWithBonds(page);
await selectRectangleSelectionTool(page);
await page.getByText(monomer).locator('..').first().click();
await dragMouseTo(anyPointX, anyPointY, page);
await takeEditorScreenshot(page);
});
}
test('Press "Escape" button while pull the bond from monomer', async ({
page,
}) => {
/*
Test case: #2507 - Add RNA monomers to canvas
Description: Bond does not remain on the canvas and returns to original position.
Test working incorrect now because we have bug https://github.com/epam/ketcher/issues/3539
*/
await addMonomerToCenterOfCanvas(page, Sugars.TwentyFiveR);
await selectSingleBondTool(page);
await page.getByText('25R').locator('..').first().click();
await pressEscapeWhenPullBond(page);
await takeEditorScreenshot(page);
});
test('Check presence of Clear canvas button in left menu', async ({
page,
}) => {
/*
Test case: Clear Canvas tool
Description: Clear canvas button presence in left menu
*/
await takeLeftToolbarMacromoleculeScreenshot(page);
});
test('Draw Sugar-Base-Phosphate and press Clear canvas', async ({ page }) => {
/*
Test case: Clear Canvas tool
Description: Canvas is cleared
*/
await drawThreeMonomersConnectedWithBonds(page);
await page.getByTestId('clear-canvas').click();
await takeEditorScreenshot(page);
});
test('Open Sugar-Base-Phosphate from .ket file and press Clear canvas', async ({
page,
}) => {
/*
Test case: Clear Canvas tool
Description: Canvas is cleared
*/
await openFileAndAddToCanvasMacro(
'KET/monomers-connected-with-bonds.ket',
page,
);
await page.getByTestId('clear-canvas').click();
await takeEditorScreenshot(page);
});
test('Save file with three Monomers as .ket file', async ({ page }) => {
/*
Test case: Open&save files
Description: File saved with three Monomers as .ket file
*/
await openFileAndAddToCanvasMacro(
'KET/monomers-connected-with-bonds.ket',
page,
);
const expectedFile = await getKet(page);
await saveToFile(
'KET/monomers-connected-with-bonds-expected.ket',
expectedFile,
);
const { fileExpected: ketFileExpected, file: ketFile } =
await receiveFileComparisonData({
page,
expectedFileName:
'tests/test-data/KET/monomers-connected-with-bonds-expected.ket',
});
expect(ketFile).toEqual(ketFileExpected);
});
test('Open Sugar-Base-Phosphate from .ket file and switch to Micromolecule mode', async ({
page,
}) => {
/*
Test case: https://github.com/epam/ketcher/issues/3498
Description: Ketcher switch to Micromolecule mode
Test is not working properly because we have bug.
*/
await openFileAndAddToCanvasMacro(
'KET/monomers-connected-with-bonds.ket',
page,
);
await turnOnMicromoleculesEditor(page);
await takePageScreenshot(page);
});
});