-
Notifications
You must be signed in to change notification settings - Fork 4
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
[DT-777] Filter by participant count #2733
Changes from all commits
2cbedca
45612b9
9b2edc9
e2d3e06
37606ba
9f89de8
0f08b2c
8dd3cc4
d03c0bf
e1383f1
d0556f8
c033344
4cc1ac8
44e9f1c
2417d78
af1a501
24ca3b1
c4ed6ee
2d3b3ab
851879e
455abe3
ff293e5
79eaba9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,7 +9,9 @@ const datasets = [ | |
datasetId: 123456, | ||
datasetIdentifier: `DUOS-123456`, | ||
datasetName: 'Some Dataset 1', | ||
participantCount: 100, | ||
study: { | ||
studyName: 'Some Study 1', | ||
studyId: 1, | ||
dataCustodianEmail: ['Some Data Custodian Email 1'], | ||
} | ||
|
@@ -23,9 +25,11 @@ const props = { | |
|
||
describe('Dataset Search Table tests', () => { | ||
|
||
describe('Data library with three datasets', () => { | ||
describe('Data library with one dataset footer tests', () => { | ||
beforeEach(() => { | ||
cy.initApplicationConfig(); | ||
cy.stub(TerraDataRepo, 'listSnapshotsByDatasetIds').returns({}); | ||
cy.clock(); | ||
mount(<DatasetSearchTable {...props} />); | ||
}); | ||
|
||
|
@@ -38,6 +42,66 @@ describe('Dataset Search Table tests', () => { | |
cy.get('#header-checkbox').click(); | ||
cy.contains('1 dataset selected from 1 study'); | ||
}); | ||
}); | ||
|
||
|
||
describe('Data library filter by participant count tests', () => { | ||
|
||
beforeEach(() => { | ||
cy.initApplicationConfig(); | ||
cy.stub(TerraDataRepo, 'listSnapshotsByDatasetIds').returns({}); | ||
cy.clock(); | ||
}); | ||
|
||
function handler(request, searchText) { | ||
if (JSON.stringify(request.body).includes(searchText)) { | ||
request.reply(['filtered']); | ||
} else { | ||
request.reply([]); | ||
} | ||
} | ||
|
||
|
||
it('When a participant count filter is applied the query is updated', () => { | ||
cy.intercept( | ||
{method: 'POST', url: '**/search/index'}, (req) => { | ||
return handler(req, '{"range":{"participantCount":{"gte":null,"lte":50}}}'); | ||
}).as('searchIndex'); | ||
mount(<DatasetSearchTable {...props} />); | ||
// first clear the default value (100), without clearing first, type('50') would result in input of 10050 | ||
const range = cy.get('#participantCountMax-range-input'); | ||
range.clear(); | ||
range.type('50'); | ||
cy.tick(150); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Cypress recommends that there be a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I use the clock command in the before each method, but I could move it into each individual test There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thank you, I did miss that. No need if it's there, that should cover it. |
||
// this api call should have had a request that contained the searchText | ||
let count = 0; | ||
cy.wait('@searchIndex').then((response) => { | ||
expect(response.response.body[0]).to.equal('filtered'); | ||
count++; | ||
}); | ||
cy.get('@searchIndex').then(() => { | ||
expect(count).to.equal(1); | ||
}); | ||
|
||
}); | ||
|
||
it('When an invalid participant count filter is applied the query represents the default value', () => { | ||
cy.intercept({method: 'POST', url: '**/search/index'}, (req) => { | ||
// when non-numeric input is entered, the default value (in this case, 100) is used | ||
return handler(req, '{"range":{"participantCount":{"gte":100,"lte":null}}}'); | ||
}).as('searchIndex'); | ||
mount(<DatasetSearchTable {...props} />); | ||
cy.get('#participantCountMin-range-input').type('test'); | ||
cy.tick(150); | ||
let count = 0; | ||
cy.wait('@searchIndex').then((response) => { | ||
expect(response.response.body[0]).to.equal('filtered'); | ||
count++; | ||
}); | ||
cy.get('@searchIndex').then(() => { | ||
expect(count).to.equal(1); | ||
}); | ||
}); | ||
|
||
}); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unused