-
Notifications
You must be signed in to change notification settings - Fork 187
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#4495 - Macro: UI support for IDT import/export
- Loading branch information
1 parent
65a15fa
commit 091564b
Showing
23 changed files
with
168 additions
and
3 deletions.
There are no files selected for viewing
123 changes: 123 additions & 0 deletions
123
ketcher-autotests/tests/Macromolecule-editor/Import-Saving-Files/import-saving-idt.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,123 @@ | ||
import { test, expect } from '@playwright/test'; | ||
import { | ||
TopPanelButton, | ||
openFileAndAddToCanvasMacro, | ||
selectTopPanelButton, | ||
takeEditorScreenshot, | ||
waitForPageInit, | ||
saveToFile, | ||
openFile, | ||
receiveFileComparisonData, | ||
selectOptionInDropdown, | ||
pressButton, | ||
chooseFileFormat, | ||
readFileContents, | ||
moveMouseAway, | ||
getIdt, | ||
} from '@utils'; | ||
import { turnOnMacromoleculesEditor } from '@utils/macromolecules'; | ||
|
||
function removeNotComparableData(file: string) { | ||
return file.replaceAll('\r', ''); | ||
} | ||
test.describe('Import-Saving .idt Files', () => { | ||
test.beforeEach(async ({ page }) => { | ||
await waitForPageInit(page); | ||
await turnOnMacromoleculesEditor(page); | ||
}); | ||
|
||
test(`Import .idt file`, async ({ page }) => { | ||
await openFileAndAddToCanvasMacro('IDT/idt-a.idt', page); | ||
await moveMouseAway(page); | ||
await takeEditorScreenshot(page); | ||
}); | ||
|
||
test('Import incorrect data', async ({ page }) => { | ||
const randomText = '!+%45#asjfnsalkfl'; | ||
await selectTopPanelButton(TopPanelButton.Open, page); | ||
await page.getByTestId('paste-from-clipboard-button').click(); | ||
await page.getByTestId('open-structure-textarea').fill(randomText); | ||
await chooseFileFormat(page, 'IDT'); | ||
await page.getByTestId('add-to-canvas-button').click(); | ||
await takeEditorScreenshot(page); | ||
}); | ||
|
||
test('Check import of .ket file and save in .idt format', async ({ | ||
page, | ||
}) => { | ||
await openFileAndAddToCanvasMacro('KET/rna-a.ket', page); | ||
const expectedFile = await getIdt(page); | ||
await saveToFile('IDT/idt-rna-a.idt', expectedFile); | ||
|
||
const METADATA_STRING_INDEX = [1]; | ||
|
||
const { fileExpected: idtFileExpected, file: idtFile } = | ||
await receiveFileComparisonData({ | ||
page, | ||
expectedFileName: 'tests/test-data/IDT/idt-rna-a.idt', | ||
metaDataIndexes: METADATA_STRING_INDEX, | ||
}); | ||
|
||
expect(idtFile).toEqual(idtFileExpected); | ||
|
||
await takeEditorScreenshot(page); | ||
}); | ||
|
||
test('Check that empty file can be saved in .idt format', async ({ | ||
page, | ||
}) => { | ||
const expectedFile = await getIdt(page); | ||
await saveToFile('IDT/idt-empty.idt', expectedFile); | ||
|
||
const METADATA_STRING_INDEX = [1]; | ||
|
||
const { fileExpected: idtFileExpected, file: idtFile } = | ||
await receiveFileComparisonData({ | ||
page, | ||
expectedFileName: 'tests/test-data/IDT/idt-empty.idt', | ||
metaDataIndexes: METADATA_STRING_INDEX, | ||
}); | ||
|
||
expect(idtFile).toEqual(idtFileExpected); | ||
}); | ||
|
||
test('Check that system does not let importing empty .idt file', async ({ | ||
page, | ||
}) => { | ||
await selectTopPanelButton(TopPanelButton.Open, page); | ||
await openFile('IDT/idt-empty.idt', page); | ||
await page.getByText('Add to Canvas').isDisabled(); | ||
}); | ||
|
||
test('Check that system does not let uploading corrupted .idt file', async ({ | ||
page, | ||
}) => { | ||
await selectTopPanelButton(TopPanelButton.Open, page); | ||
|
||
const filename = 'IDT/idt-corrupted.idt'; | ||
await openFile(filename, page); | ||
await selectOptionInDropdown(filename, page); | ||
await pressButton(page, 'Add to Canvas'); | ||
await takeEditorScreenshot(page); | ||
}); | ||
|
||
test('Should open .ket file and modify to .idt format in save modal textarea', async ({ | ||
page, | ||
}) => { | ||
await openFileAndAddToCanvasMacro('KET/rna-a.ket', page); | ||
await selectTopPanelButton(TopPanelButton.Save, page); | ||
await chooseFileFormat(page, 'IDT'); | ||
await page | ||
.getByTestId('dropdown-select') | ||
.getByRole('combobox') | ||
.allInnerTexts(); | ||
|
||
const textArea = page.getByTestId('preview-area-text'); | ||
const file = await readFileContents('tests/test-data/IDT/idt-rna-a.idt'); | ||
const expectedData = removeNotComparableData(file); | ||
const valueInTextarea = removeNotComparableData( | ||
await textArea.inputValue(), | ||
); | ||
expect(valueInTextarea).toBe(expectedData); | ||
}); | ||
}); |
Binary file added
BIN
+5.62 KB
...-idt-Files-Check-import-of-ket-file-and-save-in-idt-format-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
+40.5 KB
...heck-that-system-does-not-let-uploading-corrupted-idt-file-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
+4.94 KB
....spec.ts-snapshots/Import-Saving-idt-Files-Import-idt-file-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
+40 KB
...ts-snapshots/Import-Saving-idt-Files-Import-incorrect-data-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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
A |
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 @@ | ||
!+-$#12w12r23e32e33 |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
rA/3Phos/ |
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
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
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
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
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
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
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
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
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
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
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
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
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
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