Skip to content

Commit

Permalink
fix: merge conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
SebastianJitaru29 committed Aug 9, 2024
2 parents 7c59b1e + 183c7ff commit 155f512
Show file tree
Hide file tree
Showing 97 changed files with 7,077 additions and 5,120 deletions.
48 changes: 48 additions & 0 deletions .github/workflows/ishikawa-tools.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Generate Reports

on:
schedule:
- cron: '0 0 * * *'
issues:
types: [opened, deleted, closed, reopened, labeled]
workflow_dispatch:

jobs:
generate-reports:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.10.x'

- name: Install dependencies
run: |
pip install matplotlib pandas requests PyGithub
- name: Check environment variables
env:
ACCESS_TOKEN: ${{ secrets.ACCESS_TOKEN }}
USER: ${{ secrets.USER }}
PROJECT: ${{ secrets.PROJECT }}
run: |
echo "User secret length: ${#USER}"
echo "Project secret length: ${#PROJECT}" # Changed the checks for user and project to length checks (these secrets should probably be changed to variables)
echo "Token length: ${#ACCESS_TOKEN}" # This will print the length of the token to ensure it's set, without exposing it.
- name: Run report generation script
env:
TOKEN: ${{ secrets.GITHUB_TOKEN }} #This should work instead of using a personal access token
USER: ${{ secrets.USER }}
PROJECT: ${{ secrets.PROJECT }}
run: python ishikawa_tools/ishikawa_tools_script.py

- uses: actions/upload-artifact@v4
with:
name: ishikawa-screenshots
path: ./ishikawa_tools/output
retention-days: 1
55 changes: 55 additions & 0 deletions .github/workflows/playwright.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: Playwright Tests

on: [push, pull_request]

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1

- name: Cache Docker layers
uses: actions/cache@v2
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: '18.x'

- name: Build and start services
run: docker-compose up -d --build

- name: Wait for container to become available
run: |
npx wait-on http://localhost:8080
sleep 30 # Aumenta el tiempo de espera adicional para asegurarte de que el servidor está listo
- name: Check Docker logs
run: docker-compose logs

- name: Install npm dependencies
run: npm ci

- name: Install Playwright Browsers
run: npx playwright install --with-deps

- name: Run Playwright tests
run: npx playwright test

- uses: actions/upload-artifact@v2
if: always()
with:
name: playwright-report
path: playwright-report/
retention-days: 30

- name: Stop services
run: docker-compose down
23 changes: 23 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,26 @@ jobs:

- name: Test
run: npm test

- name: Comment to PR
if: failure() && github.event_name == 'pull_request'
uses: thollander/actions-comment-pull-request@v2
with:
message: "⚠️ The tests have failed, @${{ github.actor }} Please review the proposed changes."
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Send message to Discord
env:
DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }}
if: failure() && github.event_name == 'pull_request'
uses: Ilshidur/action-discord@master
with:
args: |
⚠️ The GitHub event `${{ github.event_name }}` has failed.
**Repository**: `${{ github.repository }}`
**Workflow**: `${{ github.workflow }}`
**Actor**: `${{ github.actor }}`
**Pull Request**: [Link](${{ github.event.pull_request.html_url }})
**Action URL**: [View Details](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }})
Please review the proposed changes.
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,10 @@ firebase-debug.log
*.njsproj
*.sln
*.sw?
/test-results/
/playwright-report/
/blob-report/
/playwright/.cache/

# Ignore the playwright test screenshots and video
/playwright/output
2 changes: 1 addition & 1 deletion .prettierrc
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
"trailingComma": "all",
"semi": false,
"arrowParens": "always"
}
}
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
"editor.formatOnSave": true,
"[vue]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[javascript]": {
"editor.defaultFormatter": "vscode.typescript-language-features"
}
}

2 changes: 1 addition & 1 deletion dockerfile → Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ RUN npm install
COPY . .

# Run build as per the script defined in package.json
RUN npm run build
RUN npm run build-dev

# Production stage using a minimal Node.js image
FROM node:alpine AS production-stage
Expand Down
38 changes: 38 additions & 0 deletions Dockerfile-playwright
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Etapa 1: Construcción
FROM node:lts AS build-stage

WORKDIR /app

# Copiar y instalar dependencias
COPY package*.json ./
RUN npm install

# Copiar el resto de la aplicación y construir
COPY . .
RUN npm run build-dev

# Etapa 2: Producción y Pruebas
FROM node:18

WORKDIR /app

# Instalar 'serve' y 'wait-on' para servir la aplicación y esperar a que esté lista
RUN npm install -g serve wait-on

# Copiar la aplicación construida desde la etapa de construcción
COPY --from=build-stage /app/dist /app

# Copiar y instalar dependencias necesarias para Playwright
COPY package*.json ./
RUN npx playwright install --with-deps
RUN npm install @playwright/test -D

# Copiar la configuración de Playwright y el resto de la aplicación
COPY playwright.config.js .
COPY . .

# Exponer el puerto en el que se servirá la aplicación
EXPOSE 5000

# Ejecutar la aplicación y esperar a que esté disponible antes de ejecutar las pruebas
CMD ["sh", "-c", "serve -s . -l 5000 & wait-on http://localhost:5000 && npx playwright test"]
11 changes: 9 additions & 2 deletions cypress.config.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
const { defineConfig } = require("cypress");
const { defineConfig } = require('cypress')
require('dotenv').config()

module.exports = defineConfig({
projectId: 'xmf2jf',
e2e: {
setupNodeEvents(on, config) {
// implement node event listeners here
},
},
});
env: {
// add environment variables here
...process.env,
url: 'http://localhost:8080',
},
})
67 changes: 67 additions & 0 deletions cypress/e2e/auth.spec.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
const authUser = require('../fixtures/authUser.json')
const url = Cypress.env('url')

describe('Authentication Suite', () => {
describe('Registration', () => {
it('should allow a new user to register', () => {
cy.visit(url + '/signup')
const { email, password } = authUser
cy.get('form').findByLabelText(/e-mail/i).type(email)
cy.get('form').findByLabelText("Password").type(password)
cy.get('form').findByLabelText("Confirm your password").type(password)
cy.findByRole('button', {name: 'Sign-up'}).click()
cy.wait(500)
cy.contains(email)
cy.deleteUser(email, password)
})
it('should reject registration with invalid password', () => {
cy.visit(url + '/signup')
const { email, invalidPassword } = authUser
cy.get('form').findByLabelText(/e-mail/i).type(email)
cy.get('form').findByLabelText("Password").type(invalidPassword)
cy.get('form').findByLabelText("Confirm your password").type(invalidPassword)
cy.findByRole('button', {name: 'Sign-up'}).click()
cy.contains('Password must be at least 6 characters')
})
it('should reject registration when passwords do not match', () => {
cy.visit(url + '/signup')
const { email, password, invalidPassword } = authUser
cy.get('form').findByLabelText(/e-mail/i).type(email)
cy.get('form').findByLabelText("Password").type(password)
cy.get('form').findByLabelText("Confirm your password").type(invalidPassword)
cy.findByRole('button', {name: 'Sign-up'}).click()
cy.contains('Different passwords')
})
})
describe('Login', () => {
const { email, password } = authUser
beforeEach(() => {
cy.signup(email, password)
cy.logout()
cy.visit(url + '/signin')
})
afterEach(() => {
cy.deleteUser(email, password)
})
it('should allow a registered user to login', () => {
cy.get('form').findByLabelText(/e-mail/i).type(email)
cy.get('form').findByLabelText('Password').type(password)
cy.findByTestId('sign-in-button').click()
cy.wait(500)
cy.contains(email)
})
it('should reject login with incorrect password', () => {
const { email, password, invalidPassword } = authUser
cy.get('form').findByLabelText(/e-mail/i).type(email)
cy.get('form').findByLabelText('Password').type(invalidPassword)
cy.findByTestId('sign-in-button').click()
cy.contains('Incorrect password')
})
it('should reject login with unregistered email', () => {
cy.get('form').findByLabelText(/e-mail/i).type('[email protected]')
cy.get('form').findByLabelText('Password').type('noexist')
cy.findByTestId('sign-in-button').click()
cy.contains('Incorrect username or password')
})
})
})
31 changes: 31 additions & 0 deletions cypress/e2e/heuristic.spec.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
const heuristic = require('../fixtures/heuristic.json')
const authUser = require('../fixtures/authUser.json')

const url = Cypress.env('url')
const { email, password } = authUser

describe('Heuristic test Suite', () => {
before('Signup into the app', () => {
cy.deleteUser(email, password)
cy.signup(email, password)
cy.login(email, password)
})
after('Remove user', () => {
cy.deleteUser(email, password)
})
describe('Create Heuristic Test', () => {
it('should allow a new test to create', () => {
cy.visit(url + '/testslist')
cy.findByTestId('create-test-btn').click()
cy.findByText('Create a blank test').click()
cy.findByText('Usability Heuristic').click()

const { name, description } = heuristic
cy.findByLabelText(/Test name/i).type(name)
cy.findByLabelText(/Test Description/i).type(description)
cy.findByTestId('add-name-test-creation-btn').click()

cy.contains(/Manager/i)
})
})
})
13 changes: 13 additions & 0 deletions cypress/fixtures/authUser.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"email": "[email protected]",
"password": "ruxailab1234",
"invalidPassword": "123",
"data": {
"accessLevel": 1,
"email" : "[email protected]",
"myAnswers": {},
"myTests": {},
"notifications": []
},
"collection": "users"
}
5 changes: 0 additions & 5 deletions cypress/fixtures/example.json

This file was deleted.

4 changes: 4 additions & 0 deletions cypress/fixtures/heuristic.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"name": "Heuristic Test",
"description": "This is a test of the heuristic test"
}
15 changes: 14 additions & 1 deletion cypress/support/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,17 @@
//
//
// -- This will overwrite an existing command --
// Cypress.Commands.overwrite('visit', (originalFn, url, options) => { ... })
// Cypress.Commands.overwrite('visit', (originalFn, url, options) => { ... })

import '@testing-library/cypress/add-commands'
import { deleteUser,
logInWithEmailAndPassword,
logOut,
signUpWithEmailAndPassword }
from './commands/auth'


Cypress.Commands.add('deleteUser', deleteUser)
Cypress.Commands.add('login', logInWithEmailAndPassword)
Cypress.Commands.add('logout', logOut)
Cypress.Commands.add('signup', signUpWithEmailAndPassword)
Loading

0 comments on commit 155f512

Please sign in to comment.