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

[test] filters e2e #182

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open

[test] filters e2e #182

wants to merge 7 commits into from

Conversation

Faria-Ejaz
Copy link

No description provided.

it('should have an arrow button', () => {
cy.get(
':nth-child(1) .Select .Select-control .Select-arrow-zone .Select-arrow',
{ timeout: 30000 }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

timeouts should be defined as constants


it('should select one option', () => {
cy.get(
':nth-child(1) .Select .Select-control .Select-arrow-zone .Select-arrow',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

selectors should be defined as constants

});
});
context('Test for Organization Filters', () => {
it('should have an arrow button', () => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

im not sure what this test is actually testing. We are looking to test functionality not design.

)
.eq(0)
.click();
cy.contains('Recurship').click(); //Selects the dropdown menu option
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since you are testing against our live environment, it would be better to make generic asserts like (list contains atleast one item).

':nth-child(7) .Select .Select-control .Select-arrow-zone .Select-arrow';
const kw=
':nth-child(8) > .form-control';

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it could be more generic if you make a function that take index and return selector with that index

cy.get(org, { timeout: delay })
.eq(0)
.click();
cy.contains('NES').click();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

select a random first element instead of giving names because we won't have this name always in list. It would have different names for different events

cy.get(org, { timeout: delay })
.eq(0)
.click();
cy.contains('Recurship').click();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here, select random elements,

context('Test for Date Filter', () => {
it('should only accept a correct date format', () => {
cy.get("input[name='filterDateTo']")
.type('2018-01-09')
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can give a random value of date by moment.add or moment.subtract methods

@@ -5,7 +5,7 @@ import App from '../App/App';
const Root = () => (
<div>
<App />
<DevTools />
{/* <DevTools /> */}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't commit this line.

context('Test for Filters Route', () => {
it('Should be on Filters page', () => {
cy.visit('/events');
cy.get('h3').should('contain', 'Welcome to Event Management');
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This heading will be removed in future, can you please assert something else

});
context('Test for Key Words filter', () => {
it('should display 1 result', () => {
cy.get(kw).type('const');
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

make a data set for these values

cy.get(kw).should('have.value', 'sasta');
cy.get('.btn').click();
cy.get('.card div')
.should('have.length', '2')
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add some generic tests. We are testing components which could have more than 2 results

/* eslint no-undef: "error" */

import { constants } from '../dataSet';
const EVEND = Cypress.moment()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please use proper variable names, they can be as long as you want.

cy.visit(constants.URL);
});
it('should display 2 result', () => {
cy.get(constants.kw).type('sasta');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

constants.kw is not a good name.

.eq(0)
.click();
cy.get('div.Select-menu-outer').should('be.visible');
cy.get(constants.VAL5).click();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

VAL5 is not a good name, each name needs to define what is it for

);
});

it('should cancel all the items at once', () => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Each "it" statement needs to have an assertion. Otherwise its not very useful. In this case you need to assert that the state got reset

@Faria-Ejaz Faria-Ejaz changed the title [WIP][test] filtersOrganisation [test] filtersOrganisation Nov 24, 2018
@Faria-Ejaz Faria-Ejaz changed the title [test] filtersOrganisation [test] filters e2e Nov 24, 2018
@mashhoodr
Copy link
Member

@Faria-Ejaz can you please fix the codacy issues in this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants