Skip to content

Commit

Permalink
some changes
Browse files Browse the repository at this point in the history
- General tests now left one that worked.
- Add TODOs for items.
- fix spaces vs tabs for intending.
- Misc edits.
  • Loading branch information
huss committed Jan 23, 2025
1 parent d46051b commit e345a24
Show file tree
Hide file tree
Showing 4 changed files with 105 additions and 98 deletions.
18 changes: 9 additions & 9 deletions cypress.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */

import { defineConfig } from "cypress";
import { defineConfig } from 'cypress';

export default defineConfig({
e2e: {
setupNodeEvents(on, config) {
// implement node event listeners here
},
specPattern: 'src/cypress/e2e/*.cy.ts',
supportFile: 'src/cypress/support/e2e.ts',
screenshotsFolder: 'src/cypress/screenshots/e2e'
},
e2e: {
setupNodeEvents(on, config) {
// implement node event listeners here
},
specPattern: 'src/cypress/e2e/*.cy.ts',
supportFile: 'src/cypress/support/e2e.ts',
screenshotsFolder: 'src/cypress/screenshots/e2e'
}
});
167 changes: 84 additions & 83 deletions src/cypress/e2e/general_ui.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,96 +2,97 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */

// TODO: Fix UI Functionality Tests
// TODO: The commented out tests were attempts to test the UI that are
// not yet working. They need to be fixed.

// describe('UI Functionality Tests for Open Energy Dashboard', () => {
// beforeEach(() => {
// // Visit the page before each test
// cy.visit('/');
// });
describe('UI Functionality Tests for Open Energy Dashboard', () => {
beforeEach(() => {
// Visit the page before each test
cy.visit('/');
});

// it('Tests all buttons functionality', () => {
// // Ensure buttons are visible and clickable
// cy.get('button').should('have.length.greaterThan', 0); // Ensure buttons exist
// cy.get('button').each((button) => {
// cy.wrap(button).should('be.visible'); // Check visibility
// cy.wrap(button).click({ force: true }); // Test click
// });
// });
// it('Tests all buttons functionality', () => {
// // Ensure buttons are visible and clickable
// cy.get('button').should('have.length.greaterThan', 0); // Ensure buttons exist
// cy.get('button').each((button) => {
// cy.wrap(button).should('be.visible'); // Check visibility
// cy.wrap(button).click({ force: true }); // Test click
// });
// });

// it('Tests all form inputs', () => {
// // Test text and email inputs
// cy.get('input[type="text"], input[type="email"]').each((input) => {
// cy.wrap(input).should('be.visible').type("Sample Text"); // Check visibility and type
// });
// it('Tests all form inputs', () => {
// // Test text and email inputs
// cy.get('input[type="text"], input[type="email"]').each((input) => {
// cy.wrap(input).should('be.visible').type("Sample Text"); // Check visibility and type
// });

// // Test password inputs
// cy.get('input[type="password"]').each((input) => {
// cy.wrap(input).should('be.visible').type('password');
// });
// // Test password inputs
// cy.get('input[type="password"]').each((input) => {
// cy.wrap(input).should('be.visible').type('password');
// });

// // Test textareas
// cy.get('textarea').each((textarea) => {
// cy.wrap(textarea).should('be.visible').type('Sample description text');
// });
// // Test textareas
// cy.get('textarea').each((textarea) => {
// cy.wrap(textarea).should('be.visible').type('Sample description text');
// });

// // Submit forms
// cy.get('form').each((form) => {
// cy.wrap(form).within(() => {
// cy.get('button[type="submit"], input[type="submit"]').click({ force: true });
// });
// });
// });
// // Submit forms
// cy.get('form').each((form) => {
// cy.wrap(form).within(() => {
// cy.get('button[type="submit"], input[type="submit"]').click({ force: true });
// });
// });
// });

// it('Tests dropdown menus', () => {
// // Ensure dropdowns are visible and options are selectable
// cy.get('select').should('have.length.greaterThan', 0); // Ensure dropdowns exist
// cy.get('select').each((dropdown) => {
// cy.wrap(dropdown)
// .should('be.visible') // Check visibility
// .find('option')
// .should('have.length.greaterThan', 1); // Ensure options exist
// it('Tests dropdown menus', () => {
// // Ensure dropdowns are visible and options are selectable
// cy.get('select').should('have.length.greaterThan', 0); // Ensure dropdowns exist
// cy.get('select').each((dropdown) => {
// cy.wrap(dropdown)
// .should('be.visible') // Check visibility
// .find('option')
// .should('have.length.greaterThan', 1); // Ensure options exist

// // Select the first option (change index as needed)
// cy.wrap(dropdown).select(0);
// });
// });
// // Select the first option (change index as needed)
// cy.wrap(dropdown).select(0);
// });
// });

// it('Tests links for navigation', () => {
// // Ensure links have valid href attributes
// cy.get('a[href]').each((link) => {
// cy.wrap(link).should('have.attr', 'href').and('not.be.empty'); // Check href exists
// });
// });
it('Tests links for navigation', () => {
// Ensure links have valid href attributes
cy.get('a[href]').each((link) => {
cy.wrap(link).should('have.attr', 'href').and('not.be.empty'); // Check href exists
});
});

// it('Tests modals for correct behavior', () => {
// // Ensure modals can be triggered and closed
// cy.get('[data-bs-toggle="modal"]').each((modalTrigger) => {
// cy.wrap(modalTrigger).should('be.visible').click(); // Trigger modal
// cy.get('.modal').should('be.visible'); // Check modal is visible
// cy.get('.modal .close').click(); // Close modal
// cy.get('.modal').should('not.be.visible'); // Check modal is closed
// });
// });
// it('Tests tables for data population', () => {
// // Ensure tables are populated with rows
// cy.get('table').should('have.length.greaterThan', 0); // Ensure tables exist
// cy.get('table').each((table) => {
// cy.wrap(table).find('tr').should('have.length.greaterThan', 1); // At least one row
// });
// });
// it('Tests interactive inputs (checkboxes and radio)', () => {
// // Check and uncheck checkboxes
// cy.get('input[type="checkbox"]').each((checkbox) => {
// cy.wrap(checkbox).check({ force: true }).should('be.checked'); // Check it
// cy.wrap(checkbox).uncheck({ force: true }).should('not.be.checked'); // Uncheck it
// });
// cy.get('input[type="radio"]').each((radio) => {
// cy.wrap(radio).check({ force: true }).should('be.checked'); // Check radio
// });
// });
// it('Tests for dynamic elements', () => {
// // Ensure dynamically loaded elements exist and are visible
// cy.get('[data-dynamic]').should('exist').and('be.visible');
// });
// });
// it('Tests modals for correct behavior', () => {
// // Ensure modals can be triggered and closed
// cy.get('[data-bs-toggle="modal"]').each((modalTrigger) => {
// cy.wrap(modalTrigger).should('be.visible').click(); // Trigger modal
// cy.get('.modal').should('be.visible'); // Check modal is visible
// cy.get('.modal .close').click(); // Close modal
// cy.get('.modal').should('not.be.visible'); // Check modal is closed
// });
// });
// it('Tests tables for data population', () => {
// // Ensure tables are populated with rows
// cy.get('table').should('have.length.greaterThan', 0); // Ensure tables exist
// cy.get('table').each((table) => {
// cy.wrap(table).find('tr').should('have.length.greaterThan', 1); // At least one row
// });
// });
// it('Tests interactive inputs (checkboxes and radio)', () => {
// // Check and uncheck checkboxes
// cy.get('input[type="checkbox"]').each((checkbox) => {
// cy.wrap(checkbox).check({ force: true }).should('be.checked'); // Check it
// cy.wrap(checkbox).uncheck({ force: true }).should('not.be.checked'); // Uncheck it
// });
// cy.get('input[type="radio"]').each((radio) => {
// cy.wrap(radio).check({ force: true }).should('be.checked'); // Check radio
// });
// });
// it('Tests for dynamic elements', () => {
// // Ensure dynamically loaded elements exist and are visible
// cy.get('[data-dynamic]').should('exist').and('be.visible');
// });
});
16 changes: 10 additions & 6 deletions src/cypress/e2e/line.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,12 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */

// This test is a greate template to start with for understanding testing using cypress.
describe('testing line graph selecing groups and meters and test for plotly line graph ', () => {
// TODO These tests assume a clean setup/test data. In the future we should wipe the database
// and load the needed data (maybe without the actual meter data until needed) in a similar way
// to how the Chai/Mocha tests work.

// This test is a great template to start with for understanding testing using cypress.
describe('testing line graph selecting groups and meters and test for plotly line graph ', () => {
beforeEach(() => {
// Visit the OED application
cy.visit('/');
Expand All @@ -19,19 +23,20 @@ describe('testing line graph selecing groups and meters and test for plotly line

});
// Checking all group options
it('groups should be clickable and display 10 options and 1 incompatiable option', () => {
it('groups should be clickable and display 10 options and 1 incompatible option', () => {
// Find and click the group
cy.get('#root > div:nth-child(2) > div.container-fluid.flexGrowOne > div > div.col-2.d-none.d-lg-block > div > div:nth-child(4) > div:nth-child(2) > div > div.css-1fdsijx-ValueContainer').click().should('be.visible');
// Check if the 10 options are there
cy.get('#react-select-2-listbox > div:nth-child(1) > div:nth-child(2)').children().should('have.length', 10);
cy.get('#react-select-2-group-0-heading > div > span.badge.bg-primary.rounded-pill').should('have.text', '10');
// check if the incompatiable option is visible and not clickable
// check if the incompatible option is visible and not clickable
cy.get('#react-select-2-option-1-0').should('exist')
.should('have.attr', 'aria-disabled', 'true') // Check the aria-disabled attribute
.should('have.attr', 'tabindex', '-1') // Validate tabindex to confirm it’s not focusable
});
// Checking all meter options
it('selecting menu option should display 25 options and plotly graph', () => {
//open menu option
// open menu option
cy.get("#root > div:nth-child(2) > div.container-fluid.flexGrowOne > div > div.col-2.d-none.d-lg-block > div > div:nth-child(4) > div:nth-child(4) > div > div.css-1fdsijx-ValueContainer").click().should('be.visible');
// Verify all options
cy.get("#react-select-3-listbox > div > div:nth-child(2)").children().should('have.length', 25);
Expand Down Expand Up @@ -84,5 +89,4 @@ describe('testing line graph selecing groups and meters and test for plotly line
And checking the time interval in which the data is displayed. (From seconds to day...)
*/
});

});
2 changes: 2 additions & 0 deletions src/cypress/support/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */

// TODO This might be removed once all basic tests are ready.

/// <reference types="cypress" />
// ***********************************************
// This example commands.ts shows you how to
Expand Down

0 comments on commit e345a24

Please sign in to comment.