Skip to content

Commit a157936

Browse files
committed
openvidu-components: Added basic test
1 parent 223b521 commit a157936

File tree

3 files changed

+58
-30
lines changed

3 files changed

+58
-30
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: Run OpenVidu Components Angular test
2+
3+
on:
4+
push:
5+
pull_request:
6+
workflow_dispatch:
7+
8+
jobs:
9+
build:
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- name: Checkout repository
14+
uses: actions/checkout@v4
15+
16+
- name: Set up Node.js
17+
uses: actions/setup-node@v4
18+
with:
19+
node-version: '20'
20+
21+
- name: Run tests
22+
run: |
23+
cd openvidu-components-angular/test
24+
./run-tests.sh

openvidu-components-angular/test/start-test.sh renamed to openvidu-components-angular/test/run-test.sh

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -17,64 +17,64 @@ TUTORIALS=(
1717
'../openvidu-toolbar-buttons'
1818
'../openvidu-toolbar-panel-buttons'
1919
)
20-
# Inicializar contadores de tests exitosos y fallidos
20+
# Initialize counters for successful and failed tests
2121
SUCCESS=0
2222
FAILURE=0
2323

2424
for tutorial in "${TUTORIALS[@]}"
2525
do
2626
echo "Processing $tutorial..."
2727

28-
2928
if [ -d "$tutorial" ]; then
3029

3130
cd "$tutorial" || { echo "Cannot enter directory $tutorial"; exit 1; }
3231
rm -rf node_modules
3332
rm -f package-lock.json
3433
npm install openvidu-components-angular@latest
3534

36-
37-
# Verificar si el puerto 5080 está en uso y matar el proceso si es necesario
35+
# Check if port 5080 is in use and kill the process if necessary
3836
PORT_IN_USE=$(lsof -i :5080 | grep LISTEN)
3937
if [ -n "$PORT_IN_USE" ]; then
4038
echo "Port 5080 is in use. Killing the process..."
4139
kill -9 $(lsof -ti :5080)
4240
fi
4341

44-
45-
# Iniciar la aplicación
42+
# Start the application
4643
echo "Starting the application in $tutorial..."
4744
npm run start &
4845
APP_PID=$!
4946

50-
# Esperar un tiempo para que la aplicación se inicie
47+
# Wait some time for the application to start
5148
sleep 20
5249

53-
# Ejecutar el test
50+
# Run the test
5451
echo "Running test for $tutorial..."
55-
node ../test/test.js
52+
node ../test/test.js "$tutorial"
5653

57-
# Verificar si el test falló
54+
# Check if the test failed
5855
if [ $? -eq 1 ]; then
5956
echo "ERROR!! Test failed for $tutorial"
60-
((FAILURE++)) # Incrementar el contador de fallos
57+
((FAILURE++))
6158
else
62-
((SUCCESS++)) # Incrementar el contador de éxitos
59+
((SUCCESS++))
6360
fi
6461

6562

66-
# Detener la aplicación
6763
echo "Stopping the application in $tutorial..."
6864
kill $APP_PID
69-
wait $APP_PID 2>/dev/null # Esperar a que el proceso se detenga antes de continuar
65+
wait $APP_PID 2>/dev/null # Wait for the process to stop before continuing
7066

7167
cd - || { echo "Cannot return to previous directory"; exit 1; }
7268
else
7369
echo "Directory $tutorial does not exist."
7470
fi
7571
done
7672

77-
# Mostrar resumen de los tests
7873
echo "Summary:"
7974
echo "Successful tests: $SUCCESS"
80-
echo "Failed tests: $FAILURE"
75+
echo "Failed tests: $FAILURE"
76+
77+
# Exit with an error code if there are failed tests
78+
if [ $FAILURE -gt 0 ]; then
79+
exit 1
80+
fi
Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,38 @@
11
const puppeteer = require('puppeteer');
22

33
(async () => {
4-
// Iniciar el navegador
5-
console.log('Iniciando navegador');
4+
5+
const args = process.argv.slice(2);
6+
const project = args[0];
7+
let selector;
8+
9+
// Determine the correct selector based on the project
10+
if (project.includes('openvidu-admin-dashboard')) {
11+
selector = 'ov-admin-login';
12+
} else {
13+
selector = '#join-button';
14+
}
15+
616
const browser = await puppeteer.launch({
717
args: [
818
'--use-fake-ui-for-media-stream',
919
'--use-fake-device-for-media-stream',
1020
],
1121
});
1222
const page = await browser.newPage();
23+
await page.goto('http://localhost:5080');
1324

14-
console.log('Navegando a la aplicación');
15-
16-
// Navegar a la aplicación
17-
await page.goto('https://192-168-1-47.openvidu-local.dev:5443');
18-
19-
// Esperar a que el elemento con el ID #join-button aparezca
2025
try {
21-
console.log('Esperando a que #join-button aparezca');
22-
await page.waitForSelector('#join-button', { timeout: 10000 });
23-
console.log('#join-button encontrado');
26+
console.log(`Waiting for ${selctor} to appear in the DOM...`);
27+
await page.waitForSelector(selector, { timeout: 10000 });
28+
console.log(`${selctor} found!`);
2429
} catch (error) {
2530
const screenshotPath = `screenshot-${Date.now()}.png`;
2631
await page.screenshot({ path: screenshotPath });
27-
console.error('Error: #join-button no encontrado');
32+
console.error(`Error: ${selector} not found`);
2833
console.error('ERROR!! Test failed: #join-button not found');
29-
process.exit(1); // Salir del script con un código de error
34+
process.exit(1);
3035
}
3136

32-
// Cerrar el navegador
3337
await browser.close();
3438
})();

0 commit comments

Comments
 (0)