Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -831,7 +831,7 @@ test(`14. Component tab is highlighted red when its property is invalid after su
* 1. Open Molecules canvas
* 2. Load molecule on canvas
* 3. Press "Create Monomer" button
* 4. Define Sugar, Base, and Phosphate molecules leaving all fields empty
* 4. Define Sugar, Base, and Phosphate molecules with invalid symbols (e.g. <invalid name>)
* 5. Press Submit and verify error states
*
* Version 3.11
Expand All @@ -850,14 +850,18 @@ test(`14. Component tab is highlighted red when its property is invalid after su
await presetSection.setupSugar({
atomIds: [2, 3],
bondIds: [2],
symbol: '<invalid name>',
});
await presetSection.setupBase({
atomIds: [0, 1],
bondIds: [0],
symbol: '<invalid name>',
naturalAnalogue: NucleotideNaturalAnalogue.A,
});
await presetSection.setupPhosphate({
atomIds: [4, 5],
bondIds: [4],
symbol: '<invalid name>',
});

await dialog.submit();
Expand All @@ -869,6 +873,15 @@ test(`14. Component tab is highlighted red when its property is invalid after su
).getNotificationMessage(),
).toEqual('Mandatory fields must be filled.');

expect(
await NotificationMessageBanner(
page,
ErrorMessage.invalidSymbol,
).getNotificationMessage(),
).toEqual(
'The monomer code must consist only of uppercase and lowercase letters, numbers, hyphens (-), underscores (_), and asterisks (*).',
);

await presetSection.openTab(NucleotidePresetTab.Preset);
await expect(presetSection.presetTab.nameEditbox).toHaveClass(/inputError/);
await expect(page.getByTestId(NucleotidePresetTab.Preset)).toHaveClass(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -727,67 +727,61 @@ test(`15. Verify that by default the functionality of saving new monomers from c
expect(await Library(page).isMonomerExist(Peptide.Peptide)).toBeFalsy();
});

test.fail(
`16. Check preset Sugar/Base/Phosphate tabs allow editing monomer properties`,
async () => {
/*
* !!! Failed until feature https://github.com/epam/ketcher/issues/8775 is done !!!
* Test task: https://github.com/epam/ketcher/issues/8248
* Description: Verify that if for a monomer component all mandatory properties are filled, that monomer will
* also be saved to the library (in addition to the preset).
* Case:
* 1. Open Molecules canvas
* 2. Load molecule on canvas
* 3. Press "Create Monomer" button
* 4. Fill in Sugar, Base, and Phosphate tabs with test data (all fields)
* 5. Press "Submit" button
*
* Version 3.11
*/
await pasteFromClipboardAndOpenAsNewProject(page, 'CCCCCC');

const dialog = CreateMonomerDialog(page);
const presetSection = NucleotidePresetSection(page);

await LeftToolbar(page).createMonomer();
// shifting canvas to make tooltip appear fully
await shiftCanvas(page, -150, 50);

await dialog.selectType(MonomerType.NucleotidePreset);

await presetSection.setName(Preset.Preset.alias);

await presetSection.setupSugar({
atomIds: [2, 3],
bondIds: [2],
symbol: Sugar.Sugar.alias,
name: 'Sugar Test monomer',
HELMAlias: 'SugAlias',
});
await presetSection.setupBase({
atomIds: [0, 1],
bondIds: [0],
symbol: Base.Base.alias,
name: 'Base Test monomer',
naturalAnalogue: NucleotideNaturalAnalogue.A,
HELMAlias: 'BaseAlias',
});
await presetSection.setupPhosphate({
atomIds: [4, 5],
bondIds: [4],
symbol: Phosphate.Phosphate.alias,
name: 'Phosphate Test monomer',
HELMAlias: 'PhosAlias',
});

await dialog.submit();

await CommonTopRightToolbar(page).turnOnMacromoleculesEditor();
expect(await Library(page).isMonomerExist(Preset.Preset)).toBeTruthy();
expect(await Library(page).isMonomerExist(Sugar.Sugar)).toBeTruthy();
expect(await Library(page).isMonomerExist(Base.Base)).toBeTruthy();
expect(
await Library(page).isMonomerExist(Phosphate.Phosphate),
).toBeTruthy();
},
);
test(`16. Check preset Sugar/Base/Phosphate tabs allow editing monomer properties`, async () => {
/*
* Test task: https://github.com/epam/ketcher/issues/8248
* Description: Verify that if for a monomer component all mandatory properties are filled, that monomer will
* also be saved to the library (in addition to the preset).
* Case:
* 1. Open Molecules canvas
* 2. Load molecule on canvas
* 3. Press "Create Monomer" button
* 4. Fill in Sugar, Base, and Phosphate tabs with test data (all fields)
* 5. Press "Submit" button
*
* Version 3.11
*/
await pasteFromClipboardAndOpenAsNewProject(page, 'CCCCCC');

const dialog = CreateMonomerDialog(page);
const presetSection = NucleotidePresetSection(page);

await LeftToolbar(page).createMonomer();
// shifting canvas to make tooltip appear fully
await shiftCanvas(page, -150, 50);

await dialog.selectType(MonomerType.NucleotidePreset);

await presetSection.setName(Preset.Preset.alias);

await presetSection.setupSugar({
atomIds: [2, 3],
bondIds: [2],
symbol: Sugar.Sugar.alias,
name: 'Sugar Test monomer',
HELMAlias: 'SugAlias',
});
await presetSection.setupBase({
atomIds: [0, 1],
bondIds: [0],
symbol: Base.Base.alias,
name: 'Base Test monomer',
naturalAnalogue: NucleotideNaturalAnalogue.A,
HELMAlias: 'BaseAlias',
});
await presetSection.setupPhosphate({
atomIds: [4, 5],
bondIds: [4],
symbol: Phosphate.Phosphate.alias,
name: 'Phosphate Test monomer',
HELMAlias: 'PhosAlias',
});

await dialog.submit();

await CommonTopRightToolbar(page).turnOnMacromoleculesEditor();
expect(await Library(page).isMonomerExist(Preset.Preset)).toBeTruthy();
expect(await Library(page).isMonomerExist(Sugar.Sugar)).toBeTruthy();
expect(await Library(page).isMonomerExist(Base.Base)).toBeTruthy();
expect(await Library(page).isMonomerExist(Phosphate.Phosphate)).toBeTruthy();
});
3 changes: 2 additions & 1 deletion packages/ketcher-react/src/script/editor/Editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1153,6 +1153,7 @@ class Editor implements KetcherEditor {
>,
monomerStructure?: Selection,
forceAddNewLeavingGroupAtom = false,
leavingAtomLabel: AtomLabel = AtomLabel.H,
) {
assert(this.monomerCreationState);

Expand Down Expand Up @@ -1188,7 +1189,7 @@ class Editor implements KetcherEditor {
this.render.ctab,
{ type: Bond.PATTERN.TYPE.SINGLE, stereo: Bond.PATTERN.STEREO.NONE },
atomId,
{ label: AtomLabel.H },
{ label: leavingAtomLabel },
);

additionalAction = bondAdditionAction;
Expand Down
Loading
Loading