Skip to content

Commit

Permalink
fixtures for years selector
Browse files Browse the repository at this point in the history
  • Loading branch information
davidsingal committed Jan 9, 2024
1 parent c7020aa commit 6a6449b
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 4 deletions.
19 changes: 16 additions & 3 deletions client/cypress/e2e/analysis/filters-map.cy.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
describe('Analysis filters', () => {
beforeEach(() => {
cy.intercept('GET', '/api/v1/indicators?sort=name').as('fetchIndicators');
cy.intercept('GET', '/api/v1/indicators?filter[status]=active').as('fetchActiveIndicators');
cy.intercept('GET', '/api/v1/h3/years*').as('fetchYears');
cy.intercept('GET', '/api/v1/indicators?sort=name', {
fixture: 'indicators/index',
}).as('fetchIndicators');
cy.intercept('GET', '/api/v1/indicators?filter[status]=active', {
fixture: 'indicators/index',
}).as('fetchActiveIndicators');
cy.intercept('GET', '/api/v1/h3/years*', {
statusCode: 200,
fixture: 'years/index',
}).as('fetchYears');
cy.intercept('GET', '/api/v1/materials/trees*').as('fetchMaterialsTrees');
cy.intercept('GET', '/api/v1/admin-regions/trees*').as('fetchOriginsTrees');
cy.intercept('GET', '/api/v1/suppliers/types?type=t1supplier').as('fetchT1Suppliers');
Expand All @@ -22,6 +29,7 @@ describe('Analysis filters', () => {
// Indicators
it('not to filter by a disabled indicator', () => {
cy.intercept('GET', '/api/v1/indicators*', {
statusCode: 200,
fixture: 'indicators/index',
}).as('fetchIndicators');

Expand All @@ -42,6 +50,11 @@ describe('Analysis filters', () => {
});

it('filter by an active indicator', () => {
cy.intercept('GET', '/api/v1/indicators*', {
statusCode: 200,
fixture: 'indicators/index',
}).as('fetchIndicators');

cy.wait('@fetchIndicators').then((interception) => {
const activeIndicators = interception.response.body?.data.filter(
({ attributes }) => attributes.status === 'active',
Expand Down
9 changes: 8 additions & 1 deletion client/cypress/e2e/analysis/filters-table.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@ describe('Analysis filters', () => {
beforeEach(() => {
cy.intercept('GET', '/api/v1/indicators?sort=name').as('fetchIndicators');
cy.intercept('GET', '/api/v1/indicators?filter[status]=active').as('fetchActiveIndicators');
cy.intercept('GET', '/api/v1/h3/years*').as('fetchYears');
cy.intercept('GET', '/api/v1/h3/years*', {
statusCode: 200,
fixture: 'years/index',
}).as('fetchYears');
cy.intercept('GET', '/api/v1/materials/trees*').as('fetchMaterialsTrees');

cy.login();
Expand Down Expand Up @@ -44,6 +47,10 @@ describe('Analysis filters', () => {
});

it('filter by an active indicator', () => {
cy.intercept('GET', '/api/v1/indicators*', {
fixture: 'indicators/index',
}).as('fetchIndicators');

cy.wait('@fetchIndicators').then((interception) => {
const firstActiveIndicator = interception.response.body?.data.find(
({ attributes }) => attributes.status === 'active',
Expand Down

0 comments on commit 6a6449b

Please sign in to comment.