Skip to content

[test] filters e2e #182

Open
Faria-Ejaz wants to merge 7 commits intomasterfrom
filters-test
Open

[test] filters e2e #182
Faria-Ejaz wants to merge 7 commits intomasterfrom
filters-test

Conversation

@Faria-Ejaz
Copy link
Copy Markdown

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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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

<div>
<App />
<DevTools />
{/* <DevTools /> */}
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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