[tests][m]: Setup Integration Tests with Cypress (#26).

* [cypress][s]-setup-integration=with-cypress
* [fix][s]- fix typescript bug 'All files must be modules when the '--isolatedModules' flag is provided' by adding an 'export {}' to all test files
* Fixes of cypress tests
* Use yarn everywhere not npm

Co-authored-by: Abhishek Gahlot <me@abhishek.it>
This commit is contained in:
Gift Egwuenu
2020-07-17 16:16:26 +01:00
committed by GitHub
parent 3cc1c1dca8
commit d9b5c4ddbd
13 changed files with 1435 additions and 728 deletions

View File

@@ -0,0 +1,32 @@
describe('Test Home Page', () => {
beforeEach(() => {
cy.visit('/');
});
it('renders the hero title', () => {
cy.contains('Find, Share and Publish Quality Data with Datahub');
});
it('checks that a search form exists', () => {
cy.get('form').contains('Search');
});
it('submits the search form', () => {
cy.get('form').find('[type="text"]').type('my-dataset');
cy.get('form').submit();
cy.url().should('include', '/search?q=my-dataset&sort=');
cy.get('.text-3xl').and('contain.text', 'results found');
});
it('shows the recent datasets', () => {
cy.contains('Recent Datasets');
});
it('returns the expected number of recent datasets', () => {
cy.get('.recent')
.find('div')
.should(($div) => {
expect($div).to.have.length.of.at.least(2);
});
});
});

View File

@@ -0,0 +1,18 @@
describe('Test Search Page', () => {
beforeEach(() => {
cy.visit('/search');
});
it('has a search form', () => {
cy.contains('form');
cy.contains('Search');
});
it('should return a search result', () => {
cy.get('form').find('[type="text"]').type('world population');
cy.get('form').submit();
cy.url().should('include', 'search?q=world%20population&sort=');
cy.get('.text-3xl').should('have.text', '1 results found');
cy.get('.text-xl > .text-primary').should('have.text', 'World Population');
});
});