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

Data view filter posts by category #1156

Draft
wants to merge 30 commits into
base: development
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
d48e6aa
Add e2e tests for data view filters by categories
Jun 14, 2024
c7258d9
Add steps to check for dropdown elements and children elements
Jun 17, 2024
a8e2b89
Add steps to check for specific elements
Jun 17, 2024
cb5c318
Stecify the child component
Jun 17, 2024
7b37315
Add data-qa attributes
Jun 17, 2024
ab2d9cd
Remove unnecessary locators
Jun 17, 2024
52814ad
Add step to click on checkbox
Jun 18, 2024
60bef5f
Check for child dropdown lements exist and selected
Jun 18, 2024
851cc12
Specify the dropdown child items
Jun 18, 2024
9fd0b5e
Add force true to click event
Jun 18, 2024
c37dc25
Update the checkbox selected command
Jun 18, 2024
0d04a18
Update the checkbox selected command
Jun 18, 2024
e60bbfd
Merge branch 'development' of https://github.com/ushahidi/platform-cl…
Jun 21, 2024
d9be587
Merge branch 'development' of https://github.com/ushahidi/platform-cl…
Jun 24, 2024
55cf0d5
Merge branch 'development' of https://github.com/ushahidi/platform-cl…
Jul 8, 2024
a2607f2
Add additional steps for filter by categories
Jul 8, 2024
238fa52
Remove it block from the data-view file
Jul 8, 2024
66b9f35
Fix the failing tests
Jul 8, 2024
e3c08be
Remove unnecessary custom attributes
Jul 8, 2024
4eef9cb
Change click to check
Jul 8, 2024
adce02e
Add force true to check command
Jul 8, 2024
43271a9
Fix failing tests
Jul 8, 2024
dd7dee4
Fix failing tests
Jul 8, 2024
25fc790
Add wait time
Jul 8, 2024
96fb3bf
Merge branch 'development' into data-view-filter-posts-by-category
AmTryingMyBest Jul 22, 2024
3f53039
update filter by categories test
AmTryingMyBest Jul 23, 2024
5903fd4
update filter by categories test
AmTryingMyBest Jul 23, 2024
4ce62ba
add check for API responses
AmTryingMyBest Jul 24, 2024
6d72972
silence test that filter by status
AmTryingMyBest Jul 25, 2024
3eb8c66
update API test endpoints
AmTryingMyBest Jul 25, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,9 @@

<ng-template #buttonContent>
<span>{{ title }}</span>
<span class="filter-control__button__count" *ngIf="badge">{{ badge }}</span>
<span class="filter-control__button__count" *ngIf="badge" [attr.data-qa]="'selected-count'">{{
badge
}}</span>
<mat-icon
class="filter-control__button__arrow"
[svgIcon]="(isDesktop$ | async)! ? 'arrow-down-thin' : 'arrow-down'"
Expand Down
7 changes: 6 additions & 1 deletion e2e-testing/cypress/e2e/12-data-view/data-view-filters.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,13 @@ describe('Automated Tests for Post Filters in Data View', () => {
dataViewFilterFunctions.verify_count_on_results();
});

it('Filter posts by status', () => {
it.skip('Filter posts by status', () => {
dataViewFilterFunctions.click_data_view_btn();
dataViewFilterFunctions.check_post_filter_by_status();
});

it('Filter posts by categories', () => {
dataViewFilterFunctions.click_data_view_btn();
dataViewFilterFunctions.check_post_filter_by_categories();
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,11 @@ const loginFunctions = new LoginFunctions();

class DataViewFilterFunctions {
click_data_view_btn() {
cy.intercept('/api/v5/posts?page=19').as('dataViewPage19');
cy.get(DataViewLocators.dataViewBtn).click();

cy.url().should('include', '/feed');
cy.wait('@dataViewPage19').its('response.statusCode').should('eq', 200);
}

check_post_filter_by_survey() {
Expand Down Expand Up @@ -138,6 +141,47 @@ class DataViewFilterFunctions {
.should('contain', 'mat-pseudo-checkbox-checked');
cy.get(DataViewLocators.feedPageResults).contains('Current results: 20 / 512');
}

check_post_filter_by_categories() {
//click search form filter button
cy.get(DataViewLocators.revealFiltersBtn).click();
//click categories filter button
cy.get('button:contains("Categories")').click();
//verify a child is not visible before revealing it
cy.contains('Needs Escalation').should('not.exist');
//drop down to reveal children categories
cy.get(':nth-child(2) > .multilevelselect-filter__option__arrow > .mzima-button').click();
//verify child now visible
cy.contains('Needs Escalation').should('be.visible');

//add alias to check response from API
cy.intercept('/api/v5/posts?page=1').as('posts');
//click parent check mark
cy.contains('Escalation').click();

//verify count shows how many categories are selected
cy.get(DataViewLocators.selectedFilterCount).contains('4');

cy.contains('Categories').click({ force: true });

//wait for response from API before next step
cy.wait('@posts').its('response.statusCode').should('eq', 200);
//verify count of posts is updated correctly
cy.get(DataViewLocators.feedPageResults).contains('Current results: 2/2');

//select another category
cy.get('button:contains("Categories")').click();
cy.contains('Geolocation').click();
//verify count shows how many categories are selected
cy.get(DataViewLocators.selectedFilterCount).contains('11');
cy.contains('Categories').click({ force: true });
//verify count of posts is updated correctly
cy.get(DataViewLocators.feedPageResults).contains('Current results: 20/55');

//clear all filters
cy.get(DataViewLocators.clearFiltersBtn).click();
cy.get(DataViewLocators.feedPageResults).contains('Current results: 20/512');
}
}

export default DataViewFilterFunctions;
2 changes: 1 addition & 1 deletion e2e-testing/cypress/locators/DataViewLocators.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ const DataViewLocators = {
statusBtn: '[data-qa="status"]',
filterSelectionList: '[data-qa="filter-selection-list"]',
filterListOption: '[data-qa="filter-list-option"]',
selectedFilterCount: '[data-qa="selected-count"]',

postMenuDots: '[data-qa="post-menu"]',
publishPostBtn: '[data-qa="btn-publish-post"]',

postDetails: '[data-qa="post-details"]',

};

export default DataViewLocators;
Loading