-
Notifications
You must be signed in to change notification settings - Fork 169
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#3531 – added tests for ketcher API for macro mode
- Loading branch information
Showing
24 changed files
with
698 additions
and
21 deletions.
There are no files selected for viewing
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
62 changes: 62 additions & 0 deletions
62
ketcher-autotests/tests/Macromolecule-editor/API/add-fragment.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
import { Page, test } from '@playwright/test'; | ||
import { | ||
readFileContents, | ||
waitForPageInit, | ||
turnOnMacromoleculesEditor, | ||
takeEditorScreenshot, | ||
waitForSpinnerFinishedWork, | ||
addFragment, | ||
selectRectangleArea, | ||
openFileAndAddToCanvas, | ||
dragMouseTo, | ||
} from '@utils'; | ||
|
||
const fileName = 'KET/alanine-monomers-bonded.ket'; | ||
|
||
async function shiftStructure(page: Page) { | ||
const startX = 100; | ||
const startY = 100; | ||
const endX = 800; | ||
const endY = 750; | ||
const toShiftToCoordinates = 400; | ||
|
||
await selectRectangleArea(page, startX, startY, endX, endY); | ||
const alanine = await page | ||
.getByText('A', { exact: true }) | ||
.locator('..') | ||
.first(); | ||
await alanine.hover(); | ||
await dragMouseTo(toShiftToCoordinates, toShiftToCoordinates, page); | ||
} | ||
|
||
test.describe('addFragment', () => { | ||
test.beforeEach(async ({ page }) => { | ||
await waitForPageInit(page); | ||
await turnOnMacromoleculesEditor(page); | ||
await openFileAndAddToCanvas(fileName, page); | ||
await shiftStructure(page); | ||
}); | ||
|
||
test.afterEach(async ({ page }) => { | ||
await page.mouse.move(0, 0); | ||
await takeEditorScreenshot(page); | ||
}); | ||
|
||
test('mol with two monomers bonded', async ({ page }) => { | ||
const fileContents = await readFileContents( | ||
'tests/test-data/Molfiles-V3000/alanine-monomers-bonded-expected.mol', | ||
); | ||
await waitForSpinnerFinishedWork( | ||
page, | ||
async () => await addFragment(page, fileContents), | ||
); | ||
}); | ||
|
||
test('ket with two monomers bonded', async ({ page }) => { | ||
const fileContents = await readFileContents(`tests/test-data/${fileName}`); | ||
await waitForSpinnerFinishedWork( | ||
page, | ||
async () => await addFragment(page, fileContents), | ||
); | ||
}); | ||
}); |
Binary file added
BIN
+19.9 KB
...spec.ts-snapshots/addFragment-ket-with-two-monomers-bonded-1-chromium-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+19.9 KB
...spec.ts-snapshots/addFragment-mol-with-two-monomers-bonded-1-chromium-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
26 changes: 26 additions & 0 deletions
26
ketcher-autotests/tests/Macromolecule-editor/API/get-ket.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { test, expect } from '@playwright/test'; | ||
import { | ||
openFileAndAddToCanvas, | ||
readFileContents, | ||
waitForPageInit, | ||
turnOnMacromoleculesEditor, | ||
getKet, | ||
saveToFile, | ||
} from '@utils'; | ||
|
||
test.describe('getKet', () => { | ||
test.beforeEach(async ({ page }) => { | ||
await waitForPageInit(page); | ||
await turnOnMacromoleculesEditor(page); | ||
}); | ||
|
||
test('with two monomers bonded', async ({ page }) => { | ||
await openFileAndAddToCanvas('KET/alanine-monomers-bonded.ket', page); | ||
const ket = await getKet(page); | ||
await saveToFile('KET/alanine-monomers-bonded-expected.ket', ket); | ||
const fileContents = await readFileContents( | ||
'tests/test-data/KET/alanine-monomers-bonded-expected.ket', | ||
); | ||
expect(ket).toBe(fileContents); | ||
}); | ||
}); |
29 changes: 29 additions & 0 deletions
29
ketcher-autotests/tests/Macromolecule-editor/API/get-molFile.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { test, expect } from '@playwright/test'; | ||
import { | ||
openFileAndAddToCanvas, | ||
readFileContents, | ||
waitForPageInit, | ||
turnOnMacromoleculesEditor, | ||
saveToFile, | ||
getMolfile, | ||
} from '@utils'; | ||
|
||
test.describe('getMolfile', () => { | ||
test.beforeEach(async ({ page }) => { | ||
await waitForPageInit(page); | ||
await turnOnMacromoleculesEditor(page); | ||
}); | ||
|
||
test('with two monomers bonded', async ({ page }) => { | ||
await openFileAndAddToCanvas('KET/alanine-monomers-bonded.ket', page); | ||
const mol = await getMolfile(page); | ||
await saveToFile( | ||
'Molfiles-V3000/alanine-monomers-bonded-expected.mol', | ||
mol, | ||
); | ||
const fileContents = await readFileContents( | ||
'tests/test-data/Molfiles-V3000/alanine-monomers-bonded-expected.mol', | ||
); | ||
expect(mol).toBe(fileContents); | ||
}); | ||
}); |
38 changes: 38 additions & 0 deletions
38
ketcher-autotests/tests/Macromolecule-editor/API/set-molecule.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import { test, expect } from '@playwright/test'; | ||
import { | ||
readFileContents, | ||
waitForPageInit, | ||
turnOnMacromoleculesEditor, | ||
setMolecule, | ||
takeEditorScreenshot, | ||
waitForSpinnerFinishedWork, | ||
} from '@utils'; | ||
|
||
test.describe('setMolecule', () => { | ||
test.beforeEach(async ({ page }) => { | ||
await waitForPageInit(page); | ||
await turnOnMacromoleculesEditor(page); | ||
}); | ||
|
||
test('mol with two monomers bonded', async ({ page }) => { | ||
const fileContents = await readFileContents( | ||
'tests/test-data/Molfiles-V3000/alanine-monomers-bonded-expected.mol', | ||
); | ||
await waitForSpinnerFinishedWork( | ||
page, | ||
async () => await setMolecule(page, fileContents), | ||
); | ||
await takeEditorScreenshot(page); | ||
}); | ||
|
||
test('ket with two monomers bonded', async ({ page }) => { | ||
const fileContents = await readFileContents( | ||
'tests/test-data/KET/alanine-monomers-bonded.ket', | ||
); | ||
await waitForSpinnerFinishedWork( | ||
page, | ||
async () => await setMolecule(page, fileContents), | ||
); | ||
await takeEditorScreenshot(page); | ||
}); | ||
}); |
Binary file added
BIN
+8.09 KB
...spec.ts-snapshots/setMolecule-ket-with-two-monomers-bonded-1-chromium-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+8.09 KB
...spec.ts-snapshots/setMolecule-mol-with-two-monomers-bonded-1-chromium-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
183 changes: 183 additions & 0 deletions
183
ketcher-autotests/tests/test-data/KET/alanine-monomers-bonded-expected.ket
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,183 @@ | ||
{ | ||
"root": { | ||
"nodes": [ | ||
{ | ||
"$ref": "monomer0" | ||
}, | ||
{ | ||
"$ref": "monomer1" | ||
} | ||
], | ||
"connections": [ | ||
{ | ||
"connectionType": "single", | ||
"endpoint1": { | ||
"monomerId": "monomer0", | ||
"attachmentPointId": "R2" | ||
}, | ||
"endpoint2": { | ||
"monomerId": "monomer1", | ||
"attachmentPointId": "R1" | ||
} | ||
} | ||
], | ||
"templates": [ | ||
{ | ||
"$ref": "monomerTemplate-A___Alanine" | ||
} | ||
] | ||
}, | ||
"monomer0": { | ||
"type": "monomer", | ||
"id": "0", | ||
"position": { | ||
"x": 10.675, | ||
"y": 6.75 | ||
}, | ||
"alias": "A", | ||
"templateId": "A___Alanine" | ||
}, | ||
"monomerTemplate-A___Alanine": { | ||
"type": "monomerTemplate", | ||
"atoms": [ | ||
{ | ||
"label": "N", | ||
"location": [ | ||
-0.9805331061317909, | ||
-0.30629450761308635, | ||
0 | ||
] | ||
}, | ||
{ | ||
"label": "C", | ||
"location": [ | ||
-0.21253088283357013, | ||
0.20573302003705518, | ||
0 | ||
], | ||
"stereoLabel": "abs" | ||
}, | ||
{ | ||
"label": "C", | ||
"location": [ | ||
-0.24245710640903242, | ||
1.359025604825105, | ||
0 | ||
] | ||
}, | ||
{ | ||
"label": "C", | ||
"location": [ | ||
0.8222288529623745, | ||
-0.30629450761308635, | ||
0 | ||
] | ||
}, | ||
{ | ||
"label": "O", | ||
"location": [ | ||
0.846138577281151, | ||
-1.2284597573196285, | ||
0 | ||
] | ||
}, | ||
{ | ||
"type": "rg-label", | ||
"location": [ | ||
1.5903092126145781, | ||
0.20573302003705518, | ||
0 | ||
], | ||
"$refs": [ | ||
"rg-2" | ||
] | ||
}, | ||
{ | ||
"type": "rg-label", | ||
"location": [ | ||
-1.8232336838376932, | ||
0.07071340035455183, | ||
0 | ||
], | ||
"$refs": [ | ||
"rg-1" | ||
] | ||
} | ||
], | ||
"bonds": [ | ||
{ | ||
"type": 1, | ||
"atoms": [ | ||
1, | ||
0 | ||
] | ||
}, | ||
{ | ||
"type": 1, | ||
"atoms": [ | ||
1, | ||
2 | ||
], | ||
"stereo": 1 | ||
}, | ||
{ | ||
"type": 1, | ||
"atoms": [ | ||
1, | ||
3 | ||
] | ||
}, | ||
{ | ||
"type": 2, | ||
"atoms": [ | ||
3, | ||
4 | ||
] | ||
}, | ||
{ | ||
"type": 1, | ||
"atoms": [ | ||
3, | ||
5 | ||
] | ||
}, | ||
{ | ||
"type": 1, | ||
"atoms": [ | ||
0, | ||
6 | ||
] | ||
} | ||
], | ||
"classHELM": "PEPTIDE", | ||
"naturalAnalogShort": "A", | ||
"id": "A___Alanine", | ||
"alias": "A", | ||
"attachmentPoints": [ | ||
{ | ||
"attachmentAtom": 6, | ||
"leavingGroup": { | ||
"atoms": [] | ||
}, | ||
"type": "left" | ||
}, | ||
{ | ||
"attachmentAtom": 5, | ||
"leavingGroup": { | ||
"atoms": [] | ||
}, | ||
"type": "right" | ||
} | ||
] | ||
}, | ||
"monomer1": { | ||
"type": "monomer", | ||
"id": "1", | ||
"position": { | ||
"x": 15.375, | ||
"y": 10.4 | ||
}, | ||
"alias": "A", | ||
"templateId": "A___Alanine" | ||
} | ||
} |
Oops, something went wrong.