Skip to content

Commit

Permalink
exposing addEditableTableEntities on editable cell table, adding cypr…
Browse files Browse the repository at this point in the history
…ess ci test retries
  • Loading branch information
tnrich committed Nov 8, 2023
1 parent 2365c23 commit d3244ef
Show file tree
Hide file tree
Showing 6 changed files with 58 additions and 14 deletions.
4 changes: 4 additions & 0 deletions cypress.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ export default ({
video: false,
pageLoadTimeout: 40000,
e2e: {
retries: {
runMode: 3,
openMode: 0
},
// setupNodeEvents(on, config) {
// on(
// "file:preprocessor",
Expand Down
1 change: 0 additions & 1 deletion packages/ove/cypress/e2e/editing.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ describe("editing", function () {
cy.contains(`.bp3-menu-item`, "Edit Part").click();
cy.contains(".bp3-dialog button", "Save").click();

cy.contains(`button`, "Help").click();
cy.triggerFileCmd("New Part");
cy.contains(`.bp3-dialog`, "New Part");
cy.get(`[placeholder="Untitled Annotation"]`);
Expand Down
8 changes: 4 additions & 4 deletions packages/ove/cypress/e2e/proteinEditor.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,11 @@ describe("proteinEditor", function () {
// eslint-disable-next-line cypress/no-unnecessary-waiting
cy.wait(0);
cy.get(".sequenceInputBubble input").type("{enter}");
cy.contains("Selecting 9 AAs from 1 to 9");
cy.contains("Length: 1394 AAs");
cy.get(`[data-test="ve-find-tool-toggle"]`).click().focused().type(".*-ma");
cy.contains("Selecting 6 AAs from 1 to 6");
cy.contains("Length: 1391 AAs");
cy.get(`[data-test="ve-find-tool-toggle"]`).click().focused().type("ma");

cy.get(`[title="Selecting 5 AAs from 1 to 5"]`).should("exist");
cy.get(`[title="Selecting 2 AAs from 1 to 2"]`).should("exist");
});
it(`should be able to delete correctly when backspace/del pressed`, () => {
cy.contains(".veRowViewPrimaryProteinSequenceContainer svg g", "M").click({
Expand Down
1 change: 1 addition & 0 deletions packages/ui/cypress/support/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
//
// -- This is will overwrite an existing command --
// Cypress.Commands.overwrite("visit", (originalFn, url, options) => { ... })
// cypress/support/index.js
const { isString } = require("lodash");

Cypress.Commands.add("tgToggle", (type, onOrOff = true) => {
Expand Down
2 changes: 1 addition & 1 deletion packages/ui/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@teselagen/ui",
"version": "0.3.43",
"version": "0.3.44",
"main": "./src/index.js",
"exports": {
".": {
Expand Down
56 changes: 48 additions & 8 deletions packages/ui/src/DataTable/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,10 @@ const IS_LINUX = window.navigator.platform.toLowerCase().search("linux") > -1;
class DataTable extends React.Component {
constructor(props) {
super(props);
if (this.props.helperProp) {
this.props.helperProp.addEditableTableEntities =
this.addEditableTableEntities;
}
this.hotkeyEnabler = withHotkeys({
moveUpARow: {
global: false,
Expand Down Expand Up @@ -1704,16 +1708,23 @@ class DataTable extends React.Component {
additionalBodyEl={
isCellEditable &&
!onlyShowRowsWErrors && (
<Button
icon="add"
style={{ marginTop: "auto" }}
onClick={() => {
this.insertRows({ numRows: 10, appendToBottom: true });
<div
style={{
width: "100%",
display: "flex",
justifyContent: "center"
}}
minimal
>
Add 10 Rows
</Button>
<Button
icon="add"
onClick={() => {
this.insertRows({ numRows: 10, appendToBottom: true });
}}
minimal
>
Add 10 Rows
</Button>
</div>
)
}
className={classNames({
Expand Down Expand Up @@ -2961,6 +2972,35 @@ class DataTable extends React.Component {
return stringText;
};

addEditableTableEntities = incomingEnts => {
const { entities = [], reduxFormCellValidation } = computePresets(
this.props
);

this.updateEntitiesHelper(entities, entities => {
const newEntities = incomingEnts.map(e => ({
...e,
id: e.id || nanoid(),
_isClean: false
}));

const { newEnts, validationErrors } = this.formatAndValidateEntities(
newEntities,
{
useDefaultValues: true,
indexToStartAt: entities.length
}
);

entities.splice(entities.length, 0, ...newEnts);

this.updateValidation(entities, {
...reduxFormCellValidation,
...validationErrors
});
});
};

insertRows = ({ above, numRows = 1, appendToBottom } = {}) => {
const { entities = [], reduxFormCellValidation } = computePresets(
this.props
Expand Down

0 comments on commit d3244ef

Please sign in to comment.