Skip to content
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
24 changes: 24 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: CI workflow

on: pull_request

jobs:
ci-unit:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Install
run: npm ci
- name: test
run: npm test
ci-e2e:
runs-on: ubuntu-latest
needs: [ci-unit]
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Install
run: npm ci
- name: Tests e2e
run: npm run test:e2e:ci
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@ test-report.*
junit.xml
*.log
*.orig
package-lock.json
yarn.lock
.awcache
public
notes
cypress/videos
cypress/snapshots
2 changes: 2 additions & 0 deletions config/test/jest.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,6 @@ module.exports = {
restoreMocks: true,
testEnvironment: 'jsdom',
setupFilesAfterEnv: ['<rootDir>/config/test/setup-after.ts'],
moduleDirectories: ['<rootDir>/src', 'node_modules'],
modulePathIgnorePatterns: ['<rootDir>/cypress'],
};
11 changes: 11 additions & 0 deletions cypress.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { defineConfig } from "cypress";

export default defineConfig({
e2e: {
//setupNodeEvents(on, config) {
// implement node event listeners here
//},
baseUrl: 'http://localhost:8080/#',
specPattern: 'cypress/e2e/**/*.spec.{js,ts,jsx,tsx}',
},
});
66 changes: 66 additions & 0 deletions cypress/e2e/login.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
describe('login scene e2e specs',() => {
it('Visit login scene', () => {
//Arrange

//Act
cy.visit('/');

//Assert

});

it('Input field user has the focus when clicked', () => {
//Arrange

//Act
cy.visit('/');
cy.findByRole('textbox').click();

//Assert
cy.findByRole('textbox').should('have.focus');
});

it('Shows error message for wrong password input', () => {
//Arrange
const user: string = 'admin';
const wrongPassword: string = '1234';

//Act
cy.visit('/');
cy.findByRole('textbox').as('userInput');
cy.get('input[name=password]').as('passwordInput');

cy.get('@userInput').type(user);
cy.get('@passwordInput').type(wrongPassword);
cy.findByRole('button').click();
cy.findByRole('alert').as('errorMessage');

//Assert
cy.get('@userInput').should('have.value', user);
cy.get('@passwordInput').should('have.value', wrongPassword);
cy.get('@errorMessage').should('exist');


});

it('Should navigate when proper password input', () => {
//Arrange
const user: string = 'admin';
const password: string = 'test';

//Act
cy.visit('/');
cy.findByRole('textbox').as('userInput');
cy.get('input[name=password]').as('passwordInput');

cy.get('@userInput').type(user);
cy.get('@passwordInput').type(password);
cy.findByRole('button').click();

//Assert
cy.get('@userInput').should('have.value', user);
cy.get('@passwordInput').should('have.value', password);
cy.url().should('equal', 'http://localhost:8080/#/submodule-list')

});
});
1 change: 1 addition & 0 deletions cypress/support/e2e.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
import '@testing-library/cypress/add-commands';
9 changes: 9 additions & 0 deletions cypress/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@

{
"compilerOptions": {
"target": "es5",
"lib": ["es5", "dom"],
"types": ["cypress", "node", "@testing-library/cypress"]
},
"include": ["**/*.ts"]
}
Loading