Skip to content
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

Updates in e2e tests #1066

Merged
merged 6 commits into from
Oct 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion client/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,13 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/).

## [v0.6.0 Unreleased]
## [Unreleased]

### Fixed

- Update password in profile form was not working as expected [LANDGRIF-1479](https://vizzuality.atlassian.net/browse/LANDGRIF-1479)

## [v1.0.0]

### Added

Expand Down
1 change: 0 additions & 1 deletion client/cypress.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ export default defineConfig({
baseUrl: 'http://localhost:3000',
screenshotOnRunFailure: true,
video: false,
videoUploadOnPasses: false,
viewportWidth: 1280,
viewportHeight: 920,
},
Expand Down
2 changes: 1 addition & 1 deletion client/cypress/e2e/analysis/charts.cy.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
describe('Analysis charts', () => {
beforeEach(() => {
cy.interceptAllRequests();
cy.login();
cy.loginWithFixtures();
cy.visit('/analysis/chart');
});

Expand Down
2 changes: 1 addition & 1 deletion client/cypress/e2e/analysis/comparison.cy.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
describe('Analysis comparison', () => {
beforeEach(() => {
cy.interceptAllRequests();
cy.login();
cy.loginWithFixtures();
});

afterEach(() => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
describe('Analysis contextual layers', () => {
beforeEach(() => {
cy.interceptAllRequests();
cy.login();
cy.loginWithFixtures();
cy.visit('/analysis/map');
cy.wait(['@fetchIndicators', '@fetchContextualLayerCategories']);
cy.get('[data-testid="contextual-layer-modal-toggle"]').click();
Expand Down
145 changes: 145 additions & 0 deletions client/cypress/e2e/analysis/filters-map.cy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
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/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');
cy.intercept('GET', '/api/v1/suppliers/types?type=producer').as('fetchProducers');
cy.intercept('GET', '/api/v1/sourcing-locations/location-types?sort=DESC').as(
'fetchLocationTypes',
);

cy.login();
cy.visit('/analysis/map');
});

afterEach(() => {
cy.logout();
});

// Indicators
it('not to filter by a disabled indicator', () => {
cy.wait('@fetchIndicators').then((interception) => {
const firstDisabledIndicator = interception.response.body?.data.find(
({ attributes }) => attributes.status === 'inactive',
);
// opens the select
cy.get('[data-testid="select-indicators-filter"]').find('button').click();
cy.get('[data-testid="select-indicators-filter"]')
.find('li[data-headlessui-state="disabled"]')
.first()
.should('contain', firstDisabledIndicator?.attributes.name)
.should('have.attr', 'aria-disabled', 'true');
// url should not include the disabled indicator
cy.url().should('not.include', `indicator=${firstDisabledIndicator?.id}`); // Land use
});
});

it('filter by an active indicator', () => {
cy.wait('@fetchIndicators').then((interception) => {
const activeIndicators = interception.response.body?.data.filter(
({ attributes }) => attributes.status === 'active',
);
// opens the select
cy.get('[data-testid="select-indicators-filter"]').find('button').click();
cy.get('[data-testid="select-indicators-filter"]')
.find('li:not([data-headlessui-state="disabled"])')
.eq(1)
.should('contain', activeIndicators[1]?.attributes.name)
.click();
// url should include the active indicator
cy.url().should('include', `indicator=${activeIndicators[1]?.id}`);
});
});

// Years
it('filter by a year', () => {
cy.wait('@fetchYears').then((interception) => {
const secondYear = interception.response.body?.data[1];
cy.get('[data-testid="select-year-filter"]').find('button').click();
cy.get('[data-testid="select-year-filter"]')
.find('li')
.eq(1)
.should('have.text', secondYear)
.click();
});
});

// Other filters: Materials
it('filter by a material and/or some of them', () => {
cy.get('[data-testid="more-filters-button"]').click();
cy.wait('@fetchMaterialsTrees').then((interception) => {
const firstItem = interception.response.body?.data[0];
cy.get('[data-testid="tree-select-materials-filter"]').find('div[role="combobox"]').click();
cy.get('[data-testid="tree-select-materials-filter"]')
.find('div[role="listbox"]')
.find('.rc-tree-treenode')
.eq(1)
.should('have.text', firstItem.attributes.name)
.click();
});
});

// Other filters: Regions
it('filter by an origin and/or some of them', () => {
cy.get('[data-testid="more-filters-button"]').click();
cy.wait('@fetchOriginsTrees').then((interception) => {
const firstItem = interception.response.body?.data[0];
cy.get('[data-testid="tree-select-origins-filter"]').find('div[role="combobox"]').click();
cy.get('[data-testid="tree-select-origins-filter"]')
.find('div[role="listbox"]')
.find('.rc-tree-treenode')
.eq(1)
.should('have.text', firstItem.attributes.name)
.click();
});
});

// Other filters: T1 suppliers
it('filter by a T1 supplier', () => {
cy.get('[data-testid="more-filters-button"]').click();
cy.wait('@fetchT1Suppliers').then((interception) => {
const firstItem = interception.response.body?.data[0];
cy.get('[data-testid="tree-select-t1-suppliers-filter"]')
.find('div[role="combobox"]')
.click();
cy.get('[data-testid="tree-select-t1-suppliers-filter"]')
.find('div[role="listbox"]')
.find('.rc-tree-treenode')
.eq(1)
.should('have.text', firstItem.attributes.name)
.click();
});
});

// Other filters: Producers
it('filter by a producer', () => {
cy.get('[data-testid="more-filters-button"]').click();
cy.wait('@fetchProducers').then((interception) => {
const firstItem = interception.response.body?.data[0];
cy.get('[data-testid="tree-select-producers-filter"]').find('div[role="combobox"]').click();
cy.get('[data-testid="tree-select-producers-filter"]')
.find('div[role="listbox"]')
.find('.rc-tree-treenode')
.eq(1)
.should('have.text', firstItem.attributes.name)
.click();
});
});

// Other filters: Location types
it('filter by a location type', () => {
cy.get('[data-testid="more-filters-button"]').click();
cy.wait('@fetchLocationTypes').then((interception) => {
const firstItem = interception.response.body?.data[0];
cy.get('[data-testid="select-location-type-filter"]').find('button').click();
cy.get('[data-testid="select-location-type-filter"]')
.find('li')
.first()
.should('have.text', firstItem.label)
.click();
});
});
});
86 changes: 86 additions & 0 deletions client/cypress/e2e/analysis/filters-table.cy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
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/materials/trees*').as('fetchMaterialsTrees');

cy.login();
cy.visit('/analysis/table');
});

afterEach(() => {
cy.logout();
});

// Indicators
it('filter by All indicator', () => {
// select indicator
cy.get('[data-testid="select-indicators-filter"]').find('button').click();
cy.get('[data-testid="select-indicators-filter"] ul li:first').click();

cy.url().should('include', 'indicator=all');
});

it('not to filter by a disabled indicator', () => {
cy.wait('@fetchIndicators').then((interception) => {
const firstDisabledIndicator = interception.response.body?.data.find(
({ attributes }) => attributes.status === 'inactive',
);
// opens the select
cy.get('[data-testid="select-indicators-filter"]').find('button').click();
cy.get('[data-testid="select-indicators-filter"]')
.find('li[data-headlessui-state="disabled"]')
.first()
.should('contain', firstDisabledIndicator?.attributes.name)
.should('have.attr', 'aria-disabled', 'true');
// url should not include the disabled indicator
cy.url().should('not.include', `indicator=${firstDisabledIndicator?.id}`); // Land use
});
});

it('filter by an active indicator', () => {
cy.wait('@fetchIndicators').then((interception) => {
const firstActiveIndicator = interception.response.body?.data.find(
({ attributes }) => attributes.status === 'active',
);
// opens the select
cy.get('[data-testid="select-indicators-filter"]').find('button').click();
cy.get('[data-testid="select-indicators-filter"]')
.find('li:not([data-headlessui-state="disabled"])')
.eq(1)
.should('contain', firstActiveIndicator?.attributes.name)
.click();
// url should include the active indicator
cy.url().should('include', `indicator=${firstActiveIndicator?.id}`);
});
});

// Group by filters
it('filter by a group', () => {
cy.get('[data-testid="select-group-filters"]').find('button').click();
cy.get('[data-testid="select-group-filters"]')
.find('li')
.eq(2)
.should('have.text', 'Region')
.click();
cy.url().should('include', 'by=region');
});

// Years
it('filter by a range of years', () => {
cy.wait('@fetchYears').then((interception) => {
const firstYear = interception.response.body?.data[0];
const lastYear =
interception.response.body?.data[interception.response.body?.data.length - 1];
cy.get('[data-testid="years-range-btn"]')
.should('have.text', `from${firstYear} - ${lastYear + 5}`)
.click();
// cy.get('[data-testid="select-year-filter"]')
// .find('li')
// .eq(1)
// .should('have.text', lastYear)
// .click();
});
});
});
98 changes: 0 additions & 98 deletions client/cypress/e2e/analysis/filters.cy.ts

This file was deleted.

Loading