Skip to content

Commit

Permalink
Refresh count with refresh button
Browse files Browse the repository at this point in the history
  • Loading branch information
WHTaylor committed Apr 30, 2024
1 parent cfc9b79 commit 778e051
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
9 changes: 9 additions & 0 deletions cypress/e2e/refresh.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
describe('Clicking the refresh button fetches the count', () => {
it('passes', () => {
cy.login('prod')
cy.openEntityByTyping('Facility');
cy.intercept("*count*").as("count");
cy.get('button[title^=Refresh]').click();
cy.wait("@count").then(assert.isOk);
})
})
2 changes: 1 addition & 1 deletion src/components/entity-table/container/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ type CounterProps = {
}
const EntityCounter = ({filter, icatClient}: CounterProps) => {
const {isSuccess, data} = useQuery({
queryKey: [icatClient.buildCountUrl(filter)],
queryKey: [icatClient.buildUrl(filter), 'count'],
queryFn: async () => await icatClient.getCount(filter)
});

Expand Down
2 changes: 1 addition & 1 deletion src/icat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ class IcatClient {
return this.entityUrl({query}).toString();
}

public buildCountUrl(filter: TableFilter): string {
buildCountUrl(filter: TableFilter): string {
const where = queryWhereFromInput(filter.where);
const query = `select count(e) from ${filter.table} e ${where}`;
return this.entityUrl({query}).toString();
Expand Down

0 comments on commit 778e051

Please sign in to comment.