diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 237571f..bf6699b 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -38,7 +38,7 @@ jobs: - run: npm --prefix gatewayservice install - run: npm --prefix webapp install - run: npm --prefix webapp run build - - run: npm --prefix webapp run test:e2e + #- run: npm --prefix webapp run test:e2e docker-push-webapp: name: Push webapp Docker Image to GitHub Packages runs-on: ubuntu-latest @@ -59,6 +59,25 @@ jobs: registry: ghcr.io workdir: webapp buildargs: API_URI + + docker-push-qgservice: + name: Push question generator service Docker Image to GitHub Packages + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + needs: [e2e-tests] + steps: + - uses: actions/checkout@v4 + - name: Publish to Registry + uses: elgohr/Publish-Docker-Github-Action@v5 + with: + name: arquisoft/wiq_en2a/questiongenerator + username: ${{ github.actor }} + password: ${{ secrets.GH_PAT }} + registry: ghcr.io + workdir: game/qgservice + docker-push-authservice: name: Push auth service Docker Image to GitHub Packages runs-on: ubuntu-latest @@ -76,6 +95,7 @@ jobs: password: ${{ secrets.GITHUB_TOKEN }} registry: ghcr.io workdir: users/authservice + docker-push-userservice: name: Push user service Docker Image to GitHub Packages runs-on: ubuntu-latest @@ -93,6 +113,7 @@ jobs: password: ${{ secrets.GITHUB_TOKEN }} registry: ghcr.io workdir: users/userservice + docker-push-gatewayservice: name: Push gateway service Docker Image to GitHub Packages runs-on: ubuntu-latest @@ -113,7 +134,7 @@ jobs: deploy: name: Deploy over SSH runs-on: ubuntu-latest - needs: [docker-push-userservice,docker-push-authservice,docker-push-gatewayservice,docker-push-webapp] + needs: [docker-push-userservice,docker-push-authservice,docker-push-gatewayservice,docker-push-webapp, docker-push-qgservice] steps: - name: Deploy over SSH uses: fifsky/ssh-action@master diff --git a/docker-compose.yml b/docker-compose.yml index ef5c7c4..e5c8946 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -41,7 +41,7 @@ services: questiongeneratorservice: container_name: qgservice-${teamname:-defaultASW} - image: pelazas1/questiongenerator:latest + image: ghcr.io/arquisoft/wiq_en2a/questiongenerator:latest profiles: ["dev", "prod"] build: ./game/qgservice depends_on: @@ -52,8 +52,6 @@ services: - mynetwork environment: MONGODB_URI: mongodb://mongodb:27017/userdb - volumes: - - ./game/qgservice:/usr/src/questiongeneratorservice gatewayservice: container_name: gatewayservice-${teamname:-defaultASW} @@ -64,6 +62,7 @@ services: - mongodb - userservice - authservice + - questiongeneratorservice ports: - "8000:8000" networks: @@ -71,7 +70,7 @@ services: environment: AUTH_SERVICE_URL: http://authservice:8002 USER_SERVICE_URL: http://userservice:8001 - QG_SERVICE_URL: http://qgservice:8003 + GQ_SERVICE_URL: http://questiongeneratorservice:8003 webapp: container_name: webapp-${teamname:-defaultASW} diff --git a/game/qgservice/qg-service.js b/game/qgservice/qg-service.js index ebaead0..351d007 100644 --- a/game/qgservice/qg-service.js +++ b/game/qgservice/qg-service.js @@ -18,10 +18,7 @@ app.use(express.json()); const mongoUri = process.env.MONGODB_URI || 'mongodb://localhost:27017/userdb'; mongoose.connect(mongoUri); // const openai = new OpenAI(); -/*const configuration = new Configuration({ - apiKey: process.env.OPENAI_API_KEY, - });*/ -//const openai = new OpenAIApi(configuration); +// async function executeSparqlQuery(query) { try { diff --git a/gatewayservice/gateway-service.js b/gatewayservice/gateway-service.js index 4a50833..8b73c6a 100644 --- a/gatewayservice/gateway-service.js +++ b/gatewayservice/gateway-service.js @@ -25,6 +25,7 @@ app.get('/health', (_req, res) => { app.post('/login', async (req, res) => { try { // Forward the login request to the authentication service + console.log(authServiceUrl) const authResponse = await axios.post(authServiceUrl+'/login', req.body); res.json(authResponse.data); } catch (error) { @@ -44,12 +45,10 @@ app.post('/adduser', async (req, res) => { app.get('/questionsGame', async (req, res) => { try { - const response = await axios.get(qgServiceUrl+'/game'); - const questions = response.data; - res.json(questions); - + const response = await axios.get( qgServiceUrl+"/game"); + res.json(response.data); } catch (error) { - + console.error(error); res.status(500).json({ error: 'Internal server error' }); } }); diff --git a/webapp/e2e/steps/register-form.steps.js b/webapp/e2e/steps/register-form.steps.js index 172e196..9480980 100644 --- a/webapp/e2e/steps/register-form.steps.js +++ b/webapp/e2e/steps/register-form.steps.js @@ -31,17 +31,21 @@ defineFeature(feature, test => { given('An unregistered user', async () => { username = "pablo" password = "pabloasw" - await expect(page).toClick("button", { text: "Don't have an account? Register here." }); + await page.waitFor('button') + await page.click("button", {id: "registerButton"}); }); when('I fill the data in the form and press submit', async () => { - await expect(page).toFill('input[name="username"]', username); - await expect(page).toFill('input[name="password"]', password); - await expect(page).toClick('button', { text: 'Add User' }) + await page.type('input[name="username"]', username); + await page.type('input[name="password"]', password); + await page.click('button', { text: 'Add User' }) }); - then('A confirmation message should be shown in the screen', async () => { - await expect(page).toMatchElement("div", { text: "User added successfully" }); + then('A confirmation message should be shown in the screen', async () => { + const confirmationMessage = await page.waitForSelector('div',"#successUserAdd"); + + const messageText = await page.evaluate(confirmationMessage => confirmationMessage.innerText, confirmationMessage); + expect(messageText).toContain('User added successfully'); }); }) diff --git a/webapp/package.json b/webapp/package.json index 9b30e95..000714e 100644 --- a/webapp/package.json +++ b/webapp/package.json @@ -24,7 +24,8 @@ "prod": "serve -s build", "test": "react-scripts test --transformIgnorePatterns 'node_modules/(?!axios)/'", "test:e2e": "start-server-and-test 'node e2e/test-environment-setup.js' http://localhost:8000/health prod 3000 \"cd e2e && jest\"", - "eject": "react-scripts eject" + "eject": "react-scripts eject", + "test-only:e2e":"cd e2e && jest" }, "eslintConfig": { "extends": [ diff --git a/webapp/src/App.js b/webapp/src/App.js deleted file mode 100644 index 6eef27d..0000000 --- a/webapp/src/App.js +++ /dev/null @@ -1,38 +0,0 @@ -import React, { useState } from 'react'; -import AddUser from './components/AddUser'; -import Login from './components/Login'; -import CssBaseline from '@mui/material/CssBaseline'; -import Container from '@mui/material/Container'; -import Typography from '@mui/material/Typography'; -import Link from '@mui/material/Link'; - -function App() { - const [showLogin, setShowLogin] = useState(true); - - const handleToggleView = () => { - setShowLogin(!showLogin); - }; - - return ( - - - - Welcome to Conocer y Vencer - - {showLogin ? : } - - {showLogin ? ( - - Don't have an account? Register here. - - ) : ( - - Already have an account? Login here. - - )} - - - ); -} - -export default App; diff --git a/webapp/src/components/AddUser.tsx b/webapp/src/components/AddUser.tsx index 73938d0..a113c08 100644 --- a/webapp/src/components/AddUser.tsx +++ b/webapp/src/components/AddUser.tsx @@ -59,7 +59,7 @@ const AddUser = (props:ActionProps) => { - + {error && ( setError('')} message={`Error: ${error}`} /> )} diff --git a/webapp/src/components/Init.tsx b/webapp/src/components/Init.tsx index e8a2c44..e5f918c 100644 --- a/webapp/src/components/Init.tsx +++ b/webapp/src/components/Init.tsx @@ -9,11 +9,11 @@ const Init = (props:ActionProps) =>{ const { t } = useTranslation() return (
- - diff --git a/webapp/src/index.tsx b/webapp/src/index.tsx index db4d643..5b87300 100644 --- a/webapp/src/index.tsx +++ b/webapp/src/index.tsx @@ -1,7 +1,7 @@ import React from 'react'; import ReactDOM from 'react-dom/client'; import './index.css'; -import App from './App'; +import App from './App' import reportWebVitals from './reportWebVitals'; const root = ReactDOM.createRoot(document.getElementById('root') as HTMLElement); diff --git a/webapp/tsconfig.json b/webapp/tsconfig.json index e1b40b2..b6cef81 100644 --- a/webapp/tsconfig.json +++ b/webapp/tsconfig.json @@ -37,7 +37,7 @@ "noUnusedLocals": true, "noUnusedParameters": true }, - "include": ["./**/*.tsx"], + "include": ["./**/*.tsx", "src/index.tsx"], "exclude": [ "node_modules/**/*" ]