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

Added UI tests #7

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions cypress.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { defineConfig } from "cypress";

export default defineConfig({
env: {
BASEURL: 'http://localhost:3001/',
HOST: 'localhost',
PORT: '16992',
USERNAME: 'admin',
AMTPASSWORD: 'P@ssword'
},
e2e: {
experimentalRunAllSpecs: true,
specPattern: 'cypress/e2e/integration/**/*.ts',
}
});
29 changes: 29 additions & 0 deletions cypress/e2e/integration/connect.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
const baseUrl: string = Cypress.env('BASEURL')
const AMTPassword: string = Cypress.env('AMTPASSWORD')
// ---------------------------- Test section ----------------------------

describe('Load Site', () => {
it('loads initial page properly', () => {
// Make sure the test always starts at the initial page
cy.window().then((win) => {
win.sessionStorage.clear()
})

// Go to base site
cy.visit(baseUrl)

// Make sure the login page was hit
cy.url().should('eq', baseUrl)
})
})

describe('Connect to host', () => {
it('Fills in password and connects', () => {
// Go to base site
cy.visit(baseUrl)
// Enter the password
cy.get('[data-cy="password"]').type(AMTPassword)
// Click on the connect button
cy.get('[data-cy="connectbtn"]').click()
})
})
37 changes: 37 additions & 0 deletions cypress/support/commands.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/// <reference types="cypress" />
// ***********************************************
// This example commands.ts shows you how to
// create various custom commands and overwrite
// existing commands.
//
// For more comprehensive examples of custom
// commands please read more here:
// https://on.cypress.io/custom-commands
// ***********************************************
//
//
// -- This is a parent command --
// Cypress.Commands.add('login', (email, password) => { ... })
//
//
// -- This is a child command --
// Cypress.Commands.add('drag', { prevSubject: 'element'}, (subject, options) => { ... })
//
//
// -- This is a dual command --
// Cypress.Commands.add('dismiss', { prevSubject: 'optional'}, (subject, options) => { ... })
//
//
// -- This will overwrite an existing command --
// Cypress.Commands.overwrite('visit', (originalFn, url, options) => { ... })
//
// declare global {
// namespace Cypress {
// interface Chainable {
// login(email: string, password: string): Chainable<void>
// drag(subject: string, options?: Partial<TypeOptions>): Chainable<Element>
// dismiss(subject: string, options?: Partial<TypeOptions>): Chainable<Element>
// visit(originalFn: CommandOriginalFn, url: string, options: Partial<VisitOptions>): Chainable<Element>
// }
// }
// }
20 changes: 20 additions & 0 deletions cypress/support/e2e.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// ***********************************************************
// This example support/e2e.ts is processed and
// loaded automatically before your test files.
//
// This is a great place to put global configuration and
// behavior that modifies Cypress.
//
// You can change the location of this file or turn off
// automatically serving support files with the
// 'supportFile' configuration option.
//
// You can read more here:
// https://on.cypress.io/configuration
// ***********************************************************

// Import commands.js using ES2015 syntax:
import './commands'

// Alternatively you can use CommonJS syntax:
// require('./commands')
Loading