Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: ove test #114

Merged
merged 5 commits into from
Dec 16, 2024
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
4 changes: 2 additions & 2 deletions packages/ove/cypress/e2e/editing.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ describe("editing", function () {
cy.contains("Caret Between Bases 5293 and 1");
cy.contains(".ve-row-item-sequence", "5'gtcttatga");
});
it(`should be able to insert data around the origin correctly
it(`should be able to insert data around the origin correctly
- new sequence should be inserted after the origin`, () => {
cy.selectRange(5297, 3);
cy.replaceSelection("aaaaaa");
Expand All @@ -68,7 +68,7 @@ describe("editing", function () {
cy.replaceSelection("tt");
cy.contains("Selecting 2 bps from 3 to 4");
});
it(`should be able to revComp, comp selections that wrap the origin correctly
it(`should be able to revComp, comp selections that wrap the origin correctly
- new sequence should be inserted after the origin`, () => {
cy.selectRange(5297, 3);
cy.contains("Jump to start").click();
Expand Down
4 changes: 2 additions & 2 deletions packages/ove/cypress/e2e/editor.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ describe("editor", function () {
cy.tgToggle("shouldAutosave");
cy.contains(".veRowViewPart", "Part 0").first().click();
cy.get(".veRowViewSelectionLayer").first().trigger("contextmenu");
cy.get(".bp3-menu-item").contains("Cut").click();
cy.get(".bp3-menu-item").contains("Cut").realClick();
cy.contains("onCopy callback triggered");
cy.contains("onSave callback triggered");
cy.contains("Selection Cut");
Expand All @@ -167,7 +167,7 @@ describe("editor", function () {
cy.get(".veRowViewSelectionLayer").first().trigger("contextmenu");
//tnrnote: cut in cypress only works on electron, not firefox or chrome

cy.get(".bp3-menu-item").contains("Cut").click();
cy.get(".bp3-menu-item").contains("Cut").realClick();
cy.contains("Selection Cut");
cy.get(".tg-menu-bar").contains("File").click();
cy.get(".bp3-menu-item").contains("Save As").click();
Expand Down
13 changes: 6 additions & 7 deletions packages/ove/cypress/e2e/menuBar.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,6 @@ describe("menuBar", function () {
// eslint-disable-next-line cypress/no-unnecessary-waiting
cy.wait(0);
cy.focused().type("remove duplicate feature{enter}", { delay: 1 });
cy.contains(".rt-td", "dbl term").should("exist");
cy.contains(".bp3-dialog button", "Remove 2 Duplicates");
cy.get(".bp3-dialog .bp3-icon-settings").click();
cy.get(".tg-test-ignore-name .tg-no-fill-field").click();
Expand All @@ -204,7 +203,7 @@ describe("menuBar", function () {
cy.get(".tg-menu-bar-popover").contains("Select All").click();

cy.get(".tg-menu-bar").contains("Edit").click();
cy.get(".tg-menu-bar-popover").contains("Cut").click();
cy.get(".tg-menu-bar-popover").contains("Cut").realClick();
cy.get(".tg-menu-bar").contains("Edit").click({ force: true });

[
Expand Down Expand Up @@ -273,7 +272,7 @@ describe("menuBar", function () {

cy.selectRange(2, 5);
cy.get(".tg-menu-bar").contains("Edit").trigger("mouseover");
cy.get(".tg-menu-bar-popover").contains("Cut").click();
cy.get(".tg-menu-bar-popover").contains("Cut").realClick();

cy.get(".tg-menu-bar").contains("File").click();
cy.get(`[cmd="saveSequence"]`).should("not.have.class", "bp3-disabled");
Expand All @@ -290,7 +289,7 @@ describe("menuBar", function () {
});
it(` goTo, rotateTo work
-can't go to a position outside of the sequence
-can go to a position inside the sequence
-can go to a position inside the sequence
-can rotate the sequence to that position
`, () => {
cy.get(".tg-menu-bar").contains("Edit").click();
Expand Down Expand Up @@ -329,7 +328,7 @@ describe("menuBar", function () {
it(`
select range, copy, cut works
-cannot select range outside of sequence //TODO
-can select a valid range
-can select a valid range
-can copy the select bps
-can cut the selected bps
`, function () {
Expand All @@ -348,10 +347,10 @@ describe("menuBar", function () {

cy.get(".veStatusBar").contains(`5299`);
cy.get(".tg-menu-bar").contains("Edit").click();
cy.get(".tg-menu-bar-popover").contains("Copy").click();
cy.get(".tg-menu-bar-popover").contains("Copy").realClick();
cy.contains("Selection Copied");
cy.get(".tg-menu-bar").contains("Edit").click();
cy.get(".tg-menu-bar-popover").contains("Cut").click();
cy.get(".tg-menu-bar-popover").contains("Cut").realClick();
cy.contains("Selection Cut");
cy.get(".veStatusBar").contains(`5288`);
});
Expand Down
2 changes: 1 addition & 1 deletion packages/ove/cypress/e2e/oligoMode.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ describe("oligo mode editing in OVE", function () {
// eslint-disable-next-line cypress/no-unnecessary-waiting
cy.wait(0);
cy.focused().type("gatccaauu{enter}");
cy.contains("Selecting 9 bps from 10 to 18"); //the t's should be filtered out
cy.contains("Selecting 10 bps from 10 to 19"); //the t's should be filtered out
cy.contains("gatccaauu");
cy.get(".veTabProperties").click();
cy.contains("Circular/Linear:").should("not.exist");
Expand Down
6 changes: 3 additions & 3 deletions packages/ove/cypress/e2e/properties.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ describe("properties", function () {
cy.contains("textarea", `primer_bind complement(10..20)`);
cy.contains("textarea", `/label="fakeprimer"`);
});
it(`should be able to delete a feature from the properties tab and not have the delete button still enabled;
it(`should be able to delete a feature from the properties tab and not have the delete button still enabled;
- have the number of features correctly displayed
-not be able to create a new feature if sequenceLength === 0`, () => {
cy.get(".veTabProperties").click();
Expand All @@ -38,7 +38,7 @@ describe("properties", function () {
cy.get(".tg-menu-bar").contains("Edit").click();
cy.get(".tg-menu-bar-popover").contains("Select All").click();
cy.get(".veSelectionLayer").first().trigger("contextmenu", { force: true });
cy.get(".bp3-menu-item").contains("Cut").click();
cy.get(".bp3-menu-item").contains("Cut").realClick();
cy.get(".tgNewAnnBtn").should("have.class", "bp3-disabled");
});
it(`a custom properties tab should be able to be added`, () => {
Expand All @@ -53,7 +53,7 @@ describe("properties", function () {
cy.get(".circularLinearSelect select").select("Linear");
cy.contains(".bp3-dialog", "Truncate Annotations").should("be.visible");
});
it(`we should be able to view and edit a description in general properties
it(`we should be able to view and edit a description in general properties
and have that visible within the genbank view as well we should be able to edit a description in general properties, not make any changes, hit ok, and have the description not clear (bug! https://github.com/TeselaGen/lims/issues/5492)
// and have that visible within the genbank view as well`, () => {
cy.get(".veTabProperties").click();
Expand Down
2 changes: 1 addition & 1 deletion packages/ove/src/CreateAnnotationsPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export default compose(
}))}
withCheckboxes
schema={annotationType === "feature" ? schemaFeatures : schemaOther}
></DataTable>
/>
</div>
<DialogFooter
hideModal={hideDialog}
Expand Down
153 changes: 78 additions & 75 deletions packages/ove/src/DigestTool/DigestTool.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@
// import uniqid from "shortid";
// import Ladder from "./Ladder";
import { compose, withProps } from "recompose";
// import selectionLayer from "../redux/selectionLayer";
import React, { useState } from "react";
import { DataTable } from "@teselagen/ui";
import React, { useMemo, useState } from "react";
import { DataTable, useStableReference } from "@teselagen/ui";
import { getCutsiteType, getVirtualDigest } from "@teselagen/sequence-utils";
import CutsiteFilter from "../CutsiteFilter";
import Ladder from "./Ladder";
// import getCutsiteType from "./getCutsiteType";
import {
Tabs,
Tab,
Expand All @@ -22,23 +17,91 @@ import { pick } from "lodash-es";

const MAX_DIGEST_CUTSITES = 50;
const MAX_PARTIAL_DIGEST_CUTSITES = 10;
const onSingleSelectRow = ({ onFragmentSelect }) => {
onFragmentSelect();
};

export const DigestTool = props => {
const [selectedTab, setSelectedTab] = useState("virtualDigest");
const {
editorName,
// height = 100,
dimensions = {},
lanes,
digestTool: { selectedFragment, computePartialDigest },
onDigestSave,
computePartialDigestDisabled,
computeDigestDisabled,
updateComputePartialDigest,
boxHeight,
digestLaneRightClicked,
ladders
ladders,
sequenceData,
sequenceLength,
selectionLayerUpdate: _selectionLayerUpdate,
updateSelectedFragment
} = props;

const isCircular = sequenceData.circular;
const cutsites = sequenceData.cutsites;
const computePartialDigestDisabled =
cutsites.length > MAX_PARTIAL_DIGEST_CUTSITES;
const computeDigestDisabled = cutsites.length > MAX_DIGEST_CUTSITES;
// The selection layer update function is memoized to prevent re-renders
// It changes triggered by the DataTables below
const selectionLayerUpdate = useStableReference(_selectionLayerUpdate);

// This useMemo might not be necessary once if we figure out
// why the DataTables below triggers a re-render outside of them.
const lanes = useMemo(() => {
const { fragments } = getVirtualDigest({
cutsites,
sequenceLength,
isCircular,
computePartialDigest,
computePartialDigestDisabled,
computeDigestDisabled
});
const _lanes = [
fragments.map(f => ({
...f,
onFragmentSelect: () => {
selectionLayerUpdate.current({
start: f.start,
end: f.end,
name: f.name
});
updateSelectedFragment(f.Intentid);
}
}))
];
return _lanes;
}, [
computeDigestDisabled,
computePartialDigest,
computePartialDigestDisabled,
cutsites,
isCircular,
selectionLayerUpdate,
sequenceLength,
updateSelectedFragment
]);

// Same comment as above
const digestInfoLanes = useMemo(
() =>
lanes[0].map(({ id, cut1, cut2, start, end, size, ...rest }) => {
return {
...rest,
id,
start,
end,
length: size,
leftCutter: cut1.restrictionEnzyme.name,
rightCutter: cut2.restrictionEnzyme.name,
leftOverhang: getCutsiteType(cut1.restrictionEnzyme),
rightOverhang: getCutsiteType(cut2.restrictionEnzyme)
};
}),
[lanes]
);

return (
<div
style={{
Expand Down Expand Up @@ -137,25 +200,9 @@ export const DigestTool = props => {
maxHeight={400}
// noFooter
withSearch={false}
onSingleRowSelect={({ onFragmentSelect }) => {
onFragmentSelect();
}}
onSingleRowSelect={onSingleSelectRow}
formName="digestInfoTable"
entities={lanes[0].map(
({ id, cut1, cut2, start, end, size, ...rest }) => {
return {
...rest,
id,
start,
end,
length: size,
leftCutter: cut1.restrictionEnzyme.name,
rightCutter: cut2.restrictionEnzyme.name,
leftOverhang: getCutsiteType(cut1.restrictionEnzyme),
rightOverhang: getCutsiteType(cut2.restrictionEnzyme)
};
}
)}
entities={digestInfoLanes}
schema={schema}
/>
}
Expand All @@ -178,48 +225,4 @@ const schema = {
]
};

export default compose(
withEditorInteractions,
withProps(
({
sequenceData,
sequenceLength,
selectionLayerUpdate,
updateSelectedFragment,
digestTool: { computePartialDigest }
}) => {
const isCircular = sequenceData.circular;
const cutsites = sequenceData.cutsites;
const computePartialDigestDisabled =
cutsites.length > MAX_PARTIAL_DIGEST_CUTSITES;
const computeDigestDisabled = cutsites.length > MAX_DIGEST_CUTSITES;

const { fragments, overlappingEnzymes } = getVirtualDigest({
cutsites,
sequenceLength,
isCircular,
computePartialDigest,
computePartialDigestDisabled,
computeDigestDisabled
});
return {
computePartialDigestDisabled,
computeDigestDisabled,
lanes: [
fragments.map(f => ({
...f,
onFragmentSelect: () => {
selectionLayerUpdate({
start: f.start,
end: f.end,
name: f.name
});
updateSelectedFragment(f.Intentid);
}
}))
],
overlappingEnzymes
};
}
)
)(DigestTool);
export default withEditorInteractions(DigestTool);
Loading
Loading