gene crud

This commit is contained in:
Colin Megill
2021-06-08 17:03:40 -07:00
parent 022ffc22e6
commit c78c367c34
6 changed files with 133 additions and 25 deletions
+3
View File
@@ -16,3 +16,6 @@ summary test,,F5,
summary test,,PIGU, summary test,,PIGU,
geneset_to_delete,,, geneset_to_delete,,,
geneset_to_edit,,, geneset_to_edit,,,
fill_this_geneset,,RER1,
empty_this_geneset,,SIK1,
brush_this_gene,,SIK1,
1 # Test fixture
16 summary test,,PIGU,
17 geneset_to_delete,,,
18 geneset_to_edit,,,
19 fill_this_geneset,,RER1,
20 empty_this_geneset,,SIK1,
21 brush_this_gene,,SIK1,
+62 -8
View File
@@ -160,14 +160,6 @@ export async function expandCategory(category) {
if (notExpanded) await clickOn(`${category}:category-expand`); if (notExpanded) await clickOn(`${category}:category-expand`);
} }
export async function expandGeneset(genesetName) {
const expand = await waitByID(`${genesetName}:geneset-expand`);
const notExpanded = await expand.$(
"[data-testclass='geneset-expand-is-not-expanded']"
);
if (notExpanded) await clickOn(`${genesetName}:geneset-expand`);
}
export async function clip(min = 0, max = 100) { export async function clip(min = 0, max = 100) {
await clickOn("visualization-settings"); await clickOn("visualization-settings");
await clearInputAndTypeInto("clip-min-input", min); await clearInputAndTypeInto("clip-min-input", min);
@@ -184,6 +176,20 @@ export async function createCategory(categoryName) {
await clickOn("submit-category"); await clickOn("submit-category");
} }
/*
GENESET
*/
export async function expandGeneset(genesetName) {
const expand = await waitByID(`${genesetName}:geneset-expand`);
const notExpanded = await expand.$(
"[data-testclass='geneset-expand-is-not-expanded']"
);
if (notExpanded) await clickOn(`${genesetName}:geneset-expand`);
}
export async function createGeneset(genesetName) { export async function createGeneset(genesetName) {
await clickOnUntil("open-create-geneset-dialog", async () => { await clickOnUntil("open-create-geneset-dialog", async () => {
await expect(page).toMatchElement(getTestId("create-geneset-input")); await expect(page).toMatchElement(getTestId("create-geneset-input"));
@@ -235,6 +241,54 @@ export async function assertGenesetExists(genesetName) {
return expect(result).toBe(genesetName); return expect(result).toBe(genesetName);
} }
/*
GENE
*/
export async function addGeneToSet(genesetName, geneToAddToSet) {
const submitButton = `${genesetName}:submit-gene`;
await clickOn(`${genesetName}:add-new-gene-to-geneset`);
await typeInto("add-genes", geneToAddToSet);
await clickOn(submitButton);
}
export async function removeGene(geneSymbol) {
const targetId = `delete-from-geneset:${geneSymbol}`;
await clickOn(targetId);
await waitByClass("autosave-complete");
}
export async function assertGeneExistsInGeneset(geneSymbol) {
const handle = await waitByID(`${geneSymbol}:gene-label`);
const result = await handle.evaluate((node) => {
return node.getAttribute("aria-label");
});
return expect(result).toBe(geneSymbol);
}
export async function assertGeneDoesNotExist(geneSymbol) {
const result = await isElementPresent(getTestId(`${geneSymbol}:gene-label`));
await expect(result).toBe(false);
}
export async function expandGene(geneSymbol) {
await clickOn(`maximize-${geneSymbol}`);
}
/*
CATEGORY
*/
export async function duplicateCategory(categoryName) { export async function duplicateCategory(categoryName) {
await clickOn("open-annotation-dialog"); await clickOn("open-annotation-dialog");
+63 -12
View File
@@ -34,21 +34,42 @@ import {
getCellSetCount, getCellSetCount,
expandGeneset, expandGeneset,
editGenesetName, editGenesetName,
addGeneToSet,
assertGeneExistsInGeneset,
removeGene,
assertGeneDoesNotExist,
expandGene,
} from "./cellxgeneActions"; } from "./cellxgeneActions";
const data = datasets[DATASET]; const data = datasets[DATASET];
const perTestCategoryName = "TEST-CATEGORY"; const perTestCategoryName = "TEST-CATEGORY";
const perTestLabelName = "TEST-LABEL"; const perTestLabelName = "TEST-LABEL";
// geneset CRUD
const genesetToDeleteName = "geneset_to_delete"; const genesetToDeleteName = "geneset_to_delete";
const preExistingGenesetName = "fifth_dataset"; const preExistingGenesetName = "fifth_dataset";
const meanExpressionBrushGenesetName = "second_gene_set"; const meanExpressionBrushGenesetName = "second_gene_set";
const meanExpressionBrushCellsSelected = "557"; const meanExpressionBrushCellsSelected = "557";
// initial text, the text we type in, the result // initial text, the text we type in, the result
const editableGenesetName = "geneset_to_edit"; const editableGenesetName = "geneset_to_edit";
const editText = "_111"; const editText = "_111";
const newGenesetName = "geneset_to_edit_111"; const newGenesetName = "geneset_to_edit_111";
// add gene to set
const geneToAddToSet = "RER1";
const setToAddGeneTo = "fill_this_geneset";
// remove gene from set
const geneToRemove = "SIK1";
const setToRemoveFrom = "empty_this_geneset";
// brush a gene
const geneToBrush = "SIK1";
const brushThisGeneGeneset = "brush_this_gene";
const geneBrushedCellCount = "109";
async function setup(config) { async function setup(config) {
await goToPage(appUrlBase); await goToPage(appUrlBase);
@@ -63,13 +84,15 @@ async function setup(config) {
await waitByClass("autosave-complete"); await waitByClass("autosave-complete");
} }
describe("geneSET crud operations and interactions", (config = {}) => { describe("geneSET crud operations and interactions", () => {
test("static pre existing genesets load from csv, expand", async () => { test("static pre existing genesets load from csv, expand", async () => {
await setup(config); await goToPage(appUrlBase);
await assertGenesetExists(preExistingGenesetName); await assertGenesetExists(preExistingGenesetName);
}); });
test("brush on geneset mean", async () => { test("brush on geneset mean", async () => {
await setup(config); await goToPage(appUrlBase);
await expandGeneset(meanExpressionBrushGenesetName); await expandGeneset(meanExpressionBrushGenesetName);
const histBrushableAreaId = `histogram-${meanExpressionBrushGenesetName}-plot-brushable-area`; const histBrushableAreaId = `histogram-${meanExpressionBrushGenesetName}-plot-brushable-area`;
@@ -88,7 +111,7 @@ describe("geneSET crud operations and interactions", (config = {}) => {
expect(cellCount).toBe(meanExpressionBrushCellsSelected); expect(cellCount).toBe(meanExpressionBrushCellsSelected);
}); });
test("create a new geneset", async () => { test("create a new geneset", async () => {
await setup(config); await goToPage(appUrlBase);
const genesetName = `test-geneset-foo-123`; const genesetName = `test-geneset-foo-123`;
await assertGenesetDoesNotExist(genesetName); await assertGenesetDoesNotExist(genesetName);
@@ -97,22 +120,50 @@ describe("geneSET crud operations and interactions", (config = {}) => {
await assertGenesetExists(genesetName); await assertGenesetExists(genesetName);
}); });
test("edit geneset name", async () => { test("edit geneset name", async () => {
await setup(config); await goToPage(appUrlBase);
await editGenesetName(editableGenesetName, editText); await editGenesetName(editableGenesetName, editText);
await assertGenesetExists(newGenesetName); await assertGenesetExists(newGenesetName);
}); });
test("delete a geneset", async () => { test("delete a geneset", async () => {
await setup(config); await goToPage(appUrlBase);
await deleteGeneset(genesetToDeleteName); await deleteGeneset(genesetToDeleteName);
}); });
}); });
// describe("GENE crud operations and interactions", () => { describe("GENE crud operations and interactions", () => {
// test("add a gene to geneset", async () => {}); test("add a gene to geneset", async () => {
// test("color by gene", async () => {}); await goToPage(appUrlBase);
// test("expand gene and brush", async () => {});
// test("delete gene from geneset", async () => {}); await addGeneToSet(setToAddGeneTo, geneToAddToSet);
// }); await expandGeneset(setToAddGeneTo);
await assertGeneExistsInGeneset(geneToAddToSet);
});
test("expand gene and brush", async () => {
await goToPage(appUrlBase);
await expandGeneset(brushThisGeneGeneset);
await expandGene(geneToBrush);
const histBrushableAreaId = `histogram-${geneToBrush}-plot-brushable-area`;
const coords = await calcDragCoordinates(histBrushableAreaId, {
x1: 0.25,
y1: 0.5,
x2: 0.55,
y2: 0.5,
});
await drag(histBrushableAreaId, coords.start, coords.end);
const cellCount = await getCellSetCount(1);
expect(cellCount).toBe(geneBrushedCellCount);
});
test("delete gene from geneset", async () => {
await goToPage(appUrlBase);
await expandGeneset(setToRemoveFrom);
await removeGene(geneToRemove);
await assertGeneDoesNotExist(geneToRemove);
});
});
describe.each([ describe.each([
{ withSubset: true, tag: "subset" }, { withSubset: true, tag: "subset" },
+1 -1
View File
@@ -124,7 +124,7 @@ class Gene extends React.Component {
<AnchorButton <AnchorButton
minimal minimal
small small
data-testid={`delete-from-geneset-${gene}`} data-testid={`delete-from-geneset:${gene}`}
onClick={this.handleDeleteGeneFromSet} onClick={this.handleDeleteGeneFromSet}
intent="none" intent="none"
style={{ fontWeight: 700, marginRight: 2 }} style={{ fontWeight: 700, marginRight: 2 }}
@@ -58,7 +58,7 @@ class AddGeneToGenesetDialogue extends React.PureComponent {
isActive={genesetsUI.isAddingGenesToGeneset === geneset} isActive={genesetsUI.isAddingGenesToGeneset === geneset}
inputProps={{ "data-testid": `${geneset}:create-label-dialog` }} inputProps={{ "data-testid": `${geneset}:create-label-dialog` }}
primaryButtonProps={{ primaryButtonProps={{
"data-testid": `${geneset}:submit-label`, "data-testid": `${geneset}:submit-gene`,
}} }}
title="Add genes to gene set" title="Add genes to gene set"
instruction={`Add gene to ${geneset}`} instruction={`Add gene to ${geneset}`}
@@ -76,8 +76,8 @@ class GenesetMenus extends React.PureComponent {
> >
<Button <Button
style={{ marginLeft: 0, marginRight: 2 }} style={{ marginLeft: 0, marginRight: 2 }}
data-testclass="handleAddNewLabelToCategory" data-testclass="handleAddNewGeneToGeneset"
data-testid={`${geneset}:add-new-label-to-category`} data-testid={`${geneset}:add-new-gene-to-geneset`}
icon={<Icon icon="plus" iconSize={10} />} icon={<Icon icon="plus" iconSize={10} />}
onClick={this.activateAddGeneToGenesetMode} onClick={this.activateAddGeneToGenesetMode}
small small