Skip to content

Commit

Permalink
formatting
Browse files Browse the repository at this point in the history
- Convert space indenting to tabs.
- Autoformat to fix up.
  • Loading branch information
huss committed Jan 12, 2025
1 parent ccace74 commit cdba3e3
Show file tree
Hide file tree
Showing 9 changed files with 258 additions and 260 deletions.
18 changes: 9 additions & 9 deletions cypress.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
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: '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: 'cypress/screenshots/e2e',
}
});
181 changes: 90 additions & 91 deletions src/cypress/e2e/general_ui.cy.ts
Original file line number Diff line number Diff line change
@@ -1,96 +1,95 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* 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/. */

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 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('SamplePassword123');
});

// 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 });
});
});
});
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 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('SamplePassword123');
});

// 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 });
});
});
});

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);
});
});

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 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);
});
});

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');
});
});
46 changes: 23 additions & 23 deletions src/cypress/e2e/hideOptions.cy.ts
Original file line number Diff line number Diff line change
@@ -1,38 +1,38 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* 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/. */

describe("Options Menu Tests", () => {
beforeEach(() => {
// Visit the OED application
cy.visit("/");
});
beforeEach(() => {
// Visit the OED application
cy.visit("/");
});

it("should toggle the visibility of graph configuration options when 'Hide options' is clicked", () => {
// Open the Options dropdown
cy.get("#header > div > div.col-4.justify-content-end.d-lg-flex.d-none > div > nav > div > ul > li:nth-child(3) > a").click();

it("should toggle the visibility of graph configuration options when 'Hide options' is clicked", () => {
// Open the Options dropdown
cy.get("#header > div > div.col-4.justify-content-end.d-lg-flex.d-none > div > nav > div > ul > li:nth-child(3) > a").click();
// Click "Hide options"
cy.get("#header > div > div.col-4.justify-content-end.d-lg-flex.d-none > div > nav > div > ul > li.dropdown.show.nav-item > div > button:nth-child(2)").click();

// Click "Hide options"
cy.get("#header > div > div.col-4.justify-content-end.d-lg-flex.d-none > div > nav > div > ul > li.dropdown.show.nav-item > div > button:nth-child(2)").click();
// Verify that graph configuration options are hidden
cy.get("#header > div > div.col-4.justify-content-end.d-lg-flex.d-none > div > nav > div > ul > li:nth-child(2) > a").should("not.exist"); // pages
cy.get("#header > div > div.col-4.justify-content-end.d-lg-flex.d-none > div > nav > div > ul > li:nth-child(3) > a").should("not.exist"); // options
cy.get("#header > div > div.col-4.justify-content-end.d-lg-flex.d-none > div > nav > div > ul > a:nth-child(4)").should("not.exist"); // help

// Verify that graph configuration options are hidden
cy.get("#header > div > div.col-4.justify-content-end.d-lg-flex.d-none > div > nav > div > ul > li:nth-child(2) > a").should("not.exist"); // pages
cy.get("#header > div > div.col-4.justify-content-end.d-lg-flex.d-none > div > nav > div > ul > li:nth-child(3) > a").should("not.exist"); // options
cy.get("#header > div > div.col-4.justify-content-end.d-lg-flex.d-none > div > nav > div > ul > a:nth-child(4)").should("not.exist"); // help



// Click "Menu" again to toggle visibility back
cy.get("#header > div > div.col-4.justify-content-end.d-lg-flex.d-none > div > button").click();
cy.get("body > div:nth-child(4) > div > div.modal.fade.show > div > div > div.modal-header > div > h6 > div > nav > div > ul > li:nth-child(3) > a").click();
cy.get("body > div:nth-child(4) > div > div.modal.fade.show > div > div > div.modal-header > div > h6 > div > nav > div > ul > li.dropdown.show.nav-item > div > button:nth-child(2)").click();
// Click "Menu" again to toggle visibility back
cy.get("#header > div > div.col-4.justify-content-end.d-lg-flex.d-none > div > button").click();
cy.get("body > div:nth-child(4) > div > div.modal.fade.show > div > div > div.modal-header > div > h6 > div > nav > div > ul > li:nth-child(3) > a").click();
cy.get("body > div:nth-child(4) > div > div.modal.fade.show > div > div > div.modal-header > div > h6 > div > nav > div > ul > li.dropdown.show.nav-item > div > button:nth-child(2)").click();



cy.get("#header > div > div.col-4.justify-content-end.d-lg-flex.d-none > div > nav > div > ul > li:nth-child(2) > a").should("be.visible"); // pages
cy.get("#header > div > div.col-4.justify-content-end.d-lg-flex.d-none > div > nav > div > ul > li:nth-child(3) > a").should("be.visible"); // options
cy.get("#header > div > div.col-4.justify-content-end.d-lg-flex.d-none > div > nav > div > ul > a:nth-child(4)").should("be.visible"); // help
cy.get("#header > div > div.col-4.justify-content-end.d-lg-flex.d-none > div > nav > div > ul > li:nth-child(2) > a").should("be.visible"); // pages
cy.get("#header > div > div.col-4.justify-content-end.d-lg-flex.d-none > div > nav > div > ul > li:nth-child(3) > a").should("be.visible"); // options
cy.get("#header > div > div.col-4.justify-content-end.d-lg-flex.d-none > div > nav > div > ul > a:nth-child(4)").should("be.visible"); // help


});
});
});
32 changes: 16 additions & 16 deletions src/cypress/e2e/initLangTest.cy.ts
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* 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/. */

describe("Language Selector Tests", () => {
beforeEach(() => {
// Visit the OED application
cy.visit("/");
});

it("should update the UI and React state when the language is changed", () => {
// Open the language selection dropdown
describe("Language Selector Tests", () => {
beforeEach(() => {
// Visit the OED application
cy.visit("/");
});

cy.get("#header > div > div.col-4.justify-content-end.d-lg-flex.d-none > div > nav > div > ul > li:nth-child(3) > a").click();
cy.get("#header > div > div.col-4.justify-content-end.d-lg-flex.d-none > div > nav > div > ul > li.dropdown.show.nav-item > div > div.dropdown.dropstart > a").click();
it("should update the UI and React state when the language is changed", () => {
// Open the language selection dropdown

cy.get("#header > div > div.col-4.justify-content-end.d-lg-flex.d-none > div > nav > div > ul > li:nth-child(3) > a").click();
cy.get("#header > div > div.col-4.justify-content-end.d-lg-flex.d-none > div > nav > div > ul > li.dropdown.show.nav-item > div > div.dropdown.dropstart > a").click();

// Select a specific language (e.g., Spanish)
cy.get("#header > div > div.col-4.justify-content-end.d-lg-flex.d-none > div > nav > div > ul > li.dropdown.show.nav-item > div > div.dropdown.dropstart.show > div").contains("Español").click();

// Verify that UI elements are updated to the selected language
cy.get("body").should("contain", "Tipo de gráfico"); // Example text in Spanish for "Graph Type"
// Select a specific language (e.g., Spanish)
cy.get("#header > div > div.col-4.justify-content-end.d-lg-flex.d-none > div > nav > div > ul > li.dropdown.show.nav-item > div > div.dropdown.dropstart.show > div").contains("Español").click();

});
});
// Verify that UI elements are updated to the selected language
cy.get("body").should("contain", "Tipo de gráfico"); // Example text in Spanish for "Graph Type"

});
});
Loading

0 comments on commit cdba3e3

Please sign in to comment.