Skip to content

Commit

Permalink
add test case for max_facet_depth
Browse files Browse the repository at this point in the history
  • Loading branch information
RFSH committed Sep 19, 2024
1 parent 87a4ea6 commit e33f45a
Show file tree
Hide file tree
Showing 2 changed files with 91 additions and 2 deletions.
34 changes: 34 additions & 0 deletions test/specs/annotation/conf/table_display/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -671,6 +671,37 @@
}
}
}
},
"table_w_max_facet_depth": {
"table_name": "table_w_max_facet_depth",
"schema_name": "schema_table_display",
"kind": "table",
"keys": [
{"unique_columns": ["id"]}
],
"foreign_keys": [],
"column_definitions": [
{
"name": "id",
"nullok": false,
"type": {
"typename": "integer"
}
},
{
"name": "text_col",
"type": {
"typename": "text"
}
}
],
"annotations": {
"tag:misd.isi.edu,2015:display": {
"max_facet_depth": {
"compact/select/association/link": 0
}
}
}
}
},
"schema_name": "schema_table_display",
Expand All @@ -679,6 +710,9 @@
"hide_row_count": {
"compact": true,
"compact/select": false
},
"max_facet_depth": {
"compact/select/association/unlink": 1
}
}
}
Expand Down
59 changes: 57 additions & 2 deletions test/specs/annotation/tests/03.table_display.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ exports.execute = function (options) {
tableName11 = "table_w_table_display_annotation_w_title",
tableNameWoAnnot = "table_wo_annotation",
tableNameCatalogAnnot = "table_w_rowname_catalog_snapshot",
tableNameCompactOptions = "table_w_compact_options";
tableNameCompactOptions = "table_w_compact_options",
tableNameWMaxFacetDepth = "table_w_max_facet_depth";

var table1EntityUri = options.url + "/catalog/" + catalog_id + "/entity/" +
schemaName + ":" + tableName1 + "/@sort(id)";
Expand Down Expand Up @@ -68,14 +69,17 @@ exports.execute = function (options) {
var tableCompactOptionsEntityUri = options.url + "/catalog/" + catalog_id + "/entity/" + schemaName + ":" +
tableNameCompactOptions;

var tableWMaxFacetDepthUri = options.url + "/catalog/" + catalog_id + "/entity/" + schemaName + ":" +
tableNameWMaxFacetDepth;

var chaiseURL = "https://example.org/chaise";
var recordURL = chaiseURL + "/record";
var record2URL = chaiseURL + "/record-two";
var viewerURL = chaiseURL + "/viewer";
var searchURL = chaiseURL + "/search";
var recordsetURL = chaiseURL + "/recordset";

var appLinkFn = function (tag, location) {
const appLinkFn = function (tag, location) {
var url;
switch (tag) {
case "tag:isrd.isi.edu,2016:chaise:record":
Expand Down Expand Up @@ -845,6 +849,57 @@ exports.execute = function (options) {
});
});

describe('display.showFaceting and display.maxFacetDepth', () => {
let refTableWMaxFacetDepth;

beforeAll((done) => {
utils.setCatalogAnnotations(options, {
"max_facet_depth": {
"compact/select/foreign_key": 2
}
}).then(() => {
options.ermRest.setClientConfig({
facetPanelDisplay: { maxFacetDepth: 3 }
});
return options.ermRest.resolve(tableWMaxFacetDepthUri, {cid: 'test'});
}).then((ref) => {
refTableWMaxFacetDepth = ref;
done();
}).catch((err) => done.fail(err));
});

it ('should get it from the display annotation on the table', () => {
let ref = refTableWMaxFacetDepth.contextualize.compactSelectAssociationLink;
expect(ref.display.showFaceting).toBe(false);
expect(ref.display.maxFacetDepth).toBe(0);
});

it ('otherwise should get it from display annotation on schema', () => {
let ref = refTableWMaxFacetDepth.contextualize.compactSelectAssociationUnlink;
expect(ref.display.showFaceting).toBe(true);
expect(ref.display.maxFacetDepth).toBe(1);
});

it ('otherwise should get it from the display annotation on catalog', () => {
let ref = refTableWMaxFacetDepth.contextualize.compactSelectForeignKey;
expect(ref.display.showFaceting).toBe(true);
expect(ref.display.maxFacetDepth).toBe(2);
});

it ('otherwise should get it from the client config.', () => {
let ref = refTableWMaxFacetDepth.contextualize.compactSelectSavedQueries;
expect(ref.display.showFaceting).toBe(true);
expect(ref.display.maxFacetDepth).toBe(2); // max that we allow is 2
});

afterAll((done) => {
// removed the catalog annotation
utils.setCatalogAnnotations(options, {}).then(() => {
done();
}).catch((err) => done.fail(err));
});
});

});

};

0 comments on commit e33f45a

Please sign in to comment.