-
Notifications
You must be signed in to change notification settings - Fork 99
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
Dataview search e2e Tests #1468
base: development
Are you sure you want to change the base?
Changes from 6 commits
c311c41
5b2a980
54ea635
82fb746
3425eea
d92f886
f398b90
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 |
---|---|---|
|
@@ -13,4 +13,4 @@ | |
"sentry_dsn": "", | ||
"sentry_environment": "", | ||
"sentry_debug_mode": false | ||
} | ||
} |
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. Could you undo the changes in the Cypress env |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,4 +6,4 @@ | |
"ush_user_email": "[email protected]", | ||
"ush_user_pwd": "1234567", | ||
"ush_user_name": "Automation User Member Role" | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import DataViewFunctions from '../../functions/DataViewFunctions/DataViewFunctions'; | ||
const dataViewFunctions = new DataViewFunctions(); | ||
|
||
describe('Search and Verify Posts', () => { | ||
beforeEach(() => { | ||
cy.visit(Cypress.env('baseUrl')); | ||
}); | ||
|
||
it('should display posts with the keyword in title or description', () => { | ||
const searchKeyword = 'election'; | ||
dataViewFunctions.search_and_verify_results(searchKeyword); | ||
}); | ||
|
||
it('should display an empty state when searching with special characters', () => { | ||
const generateSpecialCharacterKeyword = () => { | ||
const specialChars = '!@#$%^&*()_+-=[]{};\':"\\|,.<>/?`~'; | ||
let keyword = ''; | ||
const length = Math.floor(Math.random() * 10) + 1; | ||
for (let i = 0; i < length; i++) { | ||
keyword += specialChars[Math.floor(Math.random() * specialChars.length)]; | ||
} | ||
return keyword; | ||
}; | ||
const specialCharKeyword = generateSpecialCharacterKeyword(); | ||
dataViewFunctions.search_and_verify_results_with_special_characters(specialCharKeyword); | ||
}); | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,7 @@ const loginFunctions = new LoginFunctions(); | |
|
||
class DataViewFunctions { | ||
click_data_view_btn() { | ||
cy.get(DataViewLocators.dataViewBtn).click(); | ||
cy.get(DataViewLocators.dataViewBtn).should('be.visible').click({ force: true }); | ||
cy.url().should('include', '/feed'); | ||
} | ||
|
||
|
@@ -25,6 +25,32 @@ class DataViewFunctions { | |
.children(DataViewLocators.postItem) | ||
.contains('Automated Title Response'); | ||
} | ||
search_and_verify_results(keyword) { | ||
this.click_data_view_btn(); | ||
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. Before searching for the keyword, could you add a post with the keyword so that the post exists that you are searching for. 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. do you mean to create a new post in the test block? because there are posts with the election keyword before now... 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. An update has been made for this, kindly review @shakirandagire |
||
cy.get(DataViewLocators.searchInput).clear({ force: true }).type(keyword, { force: true }); | ||
|
||
// Wait for the API request to fetch results | ||
cy.intercept('GET', '**/api/v5/posts/stats*').as('searchResults'); | ||
cy.wait('@searchResults'); | ||
|
||
// Verify that results contain the keyword in the title or description | ||
cy.get(DataViewLocators.postPreview).within(() => { | ||
cy.get(DataViewLocators.postItem).each(($post) => { | ||
cy.wrap($post) | ||
.invoke('text') | ||
.then((text) => { | ||
expect(text.toLowerCase()).to.include(keyword.toLowerCase()); | ||
}); | ||
}); | ||
}); | ||
} | ||
search_and_verify_results_with_special_characters(keyword) { | ||
this.click_data_view_btn(); | ||
cy.get(DataViewLocators.searchInput).clear({ force: true }).type(keyword, { force: true }); | ||
cy.get(DataViewLocators.postsEmptyMessage) | ||
.should('be.visible') | ||
.and('contain.text', 'No posts match your keyword search'); | ||
} | ||
} | ||
|
||
export default DataViewFunctions; |
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.
Could you not make any changes to the env file that is outside the e2e-testing folder
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.
reverted the changes