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

moderatedBugs #490

Closed
wants to merge 53 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
e81f4f8
test
Apr 24, 2024
a0fafe3
revert commit
Apr 24, 2024
4e24110
include cypress testing library in the project
May 2, 2024
f456bd5
firebase auth utils for cypress
May 4, 2024
15552d0
e2e auth tests
May 4, 2024
bf6f07f
data-testid in sign in button
May 4, 2024
a59f344
remove alerts form auth command
May 4, 2024
aeb89a5
heuristic create test
May 4, 2024
882ecf7
heuristic create test
May 4, 2024
f306a60
add data-testid in components
May 4, 2024
b699d01
update package.json
May 4, 2024
0bf0afc
Merge branch 'refs/heads/develop' into create-heuristic-e2e-test
May 4, 2024
92b9fe0
Merge branch 'refs/heads/develop' into create-heuristic-e2e-test
May 9, 2024
707aaa4
include data-testid in button to create heruistic test
May 9, 2024
873d432
send message in pull request when test failed
May 9, 2024
a9c2a3d
send message in pull request when test failed
May 9, 2024
eff7617
brake test
May 9, 2024
28ce3ab
translate to english
May 9, 2024
b10e0de
include autor in the message
May 9, 2024
3e2e99b
include discord message
May 19, 2024
846be26
include more info discord message
May 19, 2024
ea8962e
include more info discord message
May 19, 2024
71ac02c
include secret in discord
May 19, 2024
45e7555
repair test
May 19, 2024
050a660
Added the script for tools and workflow
Apr 19, 2024
71b70ea
Removed the workflow file and will add it using the github ui
Apr 19, 2024
4e8bd78
Create ishikawas.yml
Zlatanius Apr 19, 2024
dc5b74a
Added the workflow file and scripts for generation of ishikawa tools …
May 28, 2024
21bb83e
Removed old workflow file
May 28, 2024
fbe5f18
Changed the trigger for ishikawa action to daily and on issue events
May 28, 2024
cf7072e
Changed the ishikawa action from using a personal access token to usi…
May 28, 2024
f86dcf5
Removed the old ishikawa scripts file
May 28, 2024
782bcf4
Merge pull request #488 from ruxailab/ishikawa-tools
jvJUCA May 29, 2024
c49b2c1
commit test
jvJUCA May 29, 2024
860682f
fix: tokens name on ishikawa functions
jvJUCA May 29, 2024
252dba6
Fix: wrong secret name
jvJUCA May 29, 2024
4f1b46f
feat: check variables
jvJUCA May 29, 2024
61206ba
fix: run job wrong place
jvJUCA May 29, 2024
ba8131c
fix: changed name of env secret
jvJUCA May 29, 2024
58c8e73
fix: ishikawa python and yml
jvJUCA May 29, 2024
3f552eb
fix: added repo owner
jvJUCA May 29, 2024
df5c69b
fix: repo_owner added
jvJUCA May 29, 2024
d698752
Changed back from using access token to the default GITHUB_TOKEN
May 30, 2024
40cbc68
Romved the repo owener variable
May 30, 2024
ed51a33
Changed to echoing the length of the user and project secrets
May 30, 2024
e08ffb9
Added the ability to manualy run the ishikawa tools action
May 30, 2024
5ae5c74
Added the code for creating the output folder. This folder is only ne…
May 30, 2024
220e13c
Added dependencies file for ishikawa tools
Jun 2, 2024
6c3db0a
Merge pull request #489 from ruxailab/ishikawa-tools
jvJUCA Jun 3, 2024
86ec140
Merge pull request #474 from ruxailab/472-generate-message-when-test-…
jvJUCA Jun 3, 2024
2fa93c3
Merge pull request #470 from ruxailab/create-heuristic-e2e-test
jvJUCA Jun 3, 2024
79cc636
intentional error in action for bot testing purposes
jvJUCA Jun 3, 2024
05aa90d
Introduce intentional error in action for bot testing purposes
jvJUCA Jun 3, 2024
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
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
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.

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)
130 changes: 130 additions & 0 deletions cypress/support/commands/auth.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
import { initializeApp } from 'firebase/app'
import {
getAuth,
connectAuthEmulator,
deleteUser as deleteUserAuth,
signInWithEmailAndPassword,
signOut,
createUserWithEmailAndPassword,
} from 'firebase/auth'
import {
getFirestore,
connectFirestoreEmulator,
doc,
setDoc,
deleteDoc,
} from 'firebase/firestore'

const authUser = require('../../fixtures/authUser.json')

const firebaseConfig = {
apiKey: Cypress.env('VUE_APP_FIREBASE_API_KEY'),
authDomain: Cypress.env('VUE_APP_FIREBASE_AUTH_DOMAIN'),
storageBucket: Cypress.env('VUE_APP_FIREBASE_STORAGE_BUCKET'),
projectId: Cypress.env('VUE_APP_FIREBASE_PROJECT_ID'),
appId: Cypress.env('VUE_APP_FIREBASE_APP_ID'),
}

const firebaseApp = initializeApp(firebaseConfig)
const auth = getAuth(firebaseApp)
const db = getFirestore(firebaseApp)
if (window.Cypress) {
connectAuthEmulator(auth, 'http://localhost:9099')
connectFirestoreEmulator(db, 'localhost', 8081)
}

/**
* Delete the currently logged-in user
* @returns {Promise<void>}
*/
export const deleteUser = async (email, password) => {
try {
const { user } = await signInWithEmailAndPassword(auth, email, password)
const { collection } = authUser
await deleteDocById(collection, user.uid)
await deleteUserAuth(user)
console.info(`Deleted user with ID "${user.uid}"`)
} catch (err) {
console.error(err)
}
}

/**
* Log in with email and password
* @param email
* @param password
* @returns {Promise<void>}
*/
export const logInWithEmailAndPassword = async (email, password) => {
try {
await signInWithEmailAndPassword(auth, email, password).then(() => {
console.info(`Logged in as "${email}"`)
})
} catch (err) {
console.error(err)
}
}

/**
* Log out the currently logged-in user
* @returns {Promise<void>}
*/
export const logOut = async () => {
try {
await signOut(auth).then(() => {
console.info('Logged out')
})
} catch (err) {
console.error(err)
}
}

/**
* Sign up with email and password
* @param email
* @param password
* @returns {Promise<void>}
*/
export const signUpWithEmailAndPassword = async (email, password) => {
try {
const { user } = await createUserWithEmailAndPassword(auth, email, password)
console.info(`Signed up as "${email}" with user ID "${user.uid}"`)
const { data, collection } = authUser
await createDoc(collection, user.uid, data)
} catch (err) {
console.error(err)
}
}

/**
* Create a document in a collection
* @param col
* @param docId
* @param data
* @returns {Promise<void>}
*/
export const createDoc = async (col, docId, data) => {
try {
const ref = doc(db, `${col}/${docId}`)
await setDoc(ref, data)
} catch (err) {
console.error(err)
}
}

/**
* Delete a document by ID
* @param col
* @param docId
* @returns {Promise<void>}
*/
export const deleteDocById = async (col, docId) => {
try {
const ref = doc(db, `${col}/${docId}`)
await deleteDoc(ref)
} catch (err) {
console.error(err)
}
}


Loading
Loading