Skip to content

Commit

Permalink
Merge pull request #79 from IrvingYHM/irving
Browse files Browse the repository at this point in the history
Irving
  • Loading branch information
IrvingYHM authored Oct 29, 2024
2 parents 5780367 + e8a2b05 commit a987727
Show file tree
Hide file tree
Showing 18 changed files with 38,673 additions and 7,928 deletions.
40 changes: 19 additions & 21 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -1,37 +1,35 @@
name: PWA CI/CD Workflow # Nombre del flujo de trabajo
name: Cypress CI

# Definir los eventos que activan el flujo de trabajo
on:
push:
branches:
- Irving
- Julio
- Jesus
- Master
- master # Despliegue en producción
- julio # Ramas de desarrollo
- irving # Ramas de desarrollo
- jesus # Ramas de desarrollo
- feature/*
pull_request:
branches:
- Irving
- Julio
- Jesus
- Master
workflow_dispatch: # Activación manual opcional
- master
- julio
- irving
- jesus
workflow_dispatch: # Activación manual opcional

# Definir los trabajos (jobs) a ejecutar
jobs:
build:
runs-on: ubuntu-latest # Sistema operativo donde se ejecutará el flujo

cypress:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3 # Descargar el código del repositorio
uses: actions/checkout@v2 # Clonar el repositorio

- name: Set up Node.js
uses: actions/setup-node@v2 # Configurar Node.js
uses: actions/setup-node@v2
with:
node-version: '16' # Especificar la versión de Node.js
node-version: '16'

- name: Install dependencies
run: npm install # Instalar las dependencias del proyecto
run: npm install --legacy-peer-deps # Instalar dependencias

- name: Run tests
run: npm test # Ejecutar las pruebas del proyecto
- name: Run Cypress tests
run: npx cypress run # Ejecutar las pruebas de Cypress
10 changes: 10 additions & 0 deletions cypress.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { defineConfig } from "cypress";

export default defineConfig({
e2e: {
baseUrl: 'https://opticenter-hu.vercel.app', // Cambia al puerto que estés usando
setupNodeEvents(on, config) {
// Implementa aquí los node event listeners si los necesitas
},
},
});
5 changes: 5 additions & 0 deletions cypress/e2e/home.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
describe('Mi primera prueba', () => {
it('Visita la página de ejemplo', () => {
cy.visit('https://opticenter-hu.vercel.app');
});
});
10 changes: 10 additions & 0 deletions cypress/e2e/login.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
describe('Validación de Campos', () => {
it('Mostrar error cuando el correo está vacío en el formulario de inicio de sesión', () => {
cy.visit('/inicioS'); // Ruta a la página de login
cy.get('input[placeholder="Correo electronico"]').clear();
cy.get('input[placeholder="Contraseña"]').type('password123');
cy.get('button[type="submit"]').click();
cy.contains('El campo es requerido'); // Mensaje de error esperado
});
});

11 changes: 11 additions & 0 deletions cypress/e2e/producto.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
//carga inicial y visualización de productos


describe('Página de productos', () => {
it('Carga y muestra productos', () => {
cy.visit('/lentes'); // Visita la ruta de productos
cy.contains('¡Descubre nuestra colección de lentes!'); // Asegura que el mensaje de bienvenida esté visible
cy.get('.w-80').should('have.length.greaterThan', 0); // Comprueba que al menos un producto esté visible
});
});

5 changes: 5 additions & 0 deletions cypress/fixtures/example.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"name": "Using fixtures to represent data",
"email": "[email protected]",
"body": "Fixtures are a great way to mock data for responses to routes"
}
25 changes: 25 additions & 0 deletions cypress/support/commands.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// ***********************************************
// This example commands.js shows you how to
// create various custom commands and overwrite
// existing commands.
//
// For more comprehensive examples of custom
// commands please read more here:
// https://on.cypress.io/custom-commands
// ***********************************************
//
//
// -- This is a parent command --
// Cypress.Commands.add('login', (email, password) => { ... })
//
//
// -- This is a child command --
// Cypress.Commands.add('drag', { prevSubject: 'element'}, (subject, options) => { ... })
//
//
// -- This is a dual command --
// Cypress.Commands.add('dismiss', { prevSubject: 'optional'}, (subject, options) => { ... })
//
//
// -- This will overwrite an existing command --
// Cypress.Commands.overwrite('visit', (originalFn, url, options) => { ... })
20 changes: 20 additions & 0 deletions cypress/support/e2e.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// ***********************************************************
// This example support/e2e.js is processed and
// loaded automatically before your test files.
//
// This is a great place to put global configuration and
// behavior that modifies Cypress.
//
// You can change the location of this file or turn off
// automatically serving support files with the
// 'supportFile' configuration option.
//
// You can read more here:
// https://on.cypress.io/configuration
// ***********************************************************

// Import commands.js using ES2015 syntax:
import './commands'

// Alternatively you can use CommonJS syntax:
// require('./commands')
115 changes: 115 additions & 0 deletions dev-dist/sw.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
/**
* Copyright 2018 Google Inc. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

// If the loader is already loaded, just stop.
if (!self.define) {
let registry = {};

// Used for `eval` and `importScripts` where we can't get script URL by other means.
// In both cases, it's safe to use a global var because those functions are synchronous.
let nextDefineUri;

const singleRequire = (uri, parentUri) => {
uri = new URL(uri + ".js", parentUri).href;
return registry[uri] || (

new Promise(resolve => {
if ("document" in self) {
const script = document.createElement("script");
script.src = uri;
script.onload = resolve;
document.head.appendChild(script);
} else {
nextDefineUri = uri;
importScripts(uri);
resolve();
}
})

.then(() => {
let promise = registry[uri];
if (!promise) {
throw new Error(`Module ${uri} didn’t register its module`);
}
return promise;
})
);
};

self.define = (depsNames, factory) => {
const uri = nextDefineUri || ("document" in self ? document.currentScript.src : "") || location.href;
if (registry[uri]) {
// Module is already loading or loaded.
return;
}
let exports = {};
const require = depUri => singleRequire(depUri, uri);
const specialDeps = {
module: { uri },
exports,
require
};
registry[uri] = Promise.all(depsNames.map(
depName => specialDeps[depName] || require(depName)
)).then(deps => {
factory(...deps);
return exports;
});
};
}
define(['./workbox-fec928b6'], (function (workbox) { 'use strict';

self.skipWaiting();
workbox.clientsClaim();

/**
* The precacheAndRoute() method efficiently caches and responds to
* requests for URLs in the manifest.
* See https://goo.gl/S9QRab
*/
workbox.precacheAndRoute([{
"url": "/offline.html",
"revision": "0.p67sb6el2t"
}], {});
workbox.cleanupOutdatedCaches();
workbox.registerRoute(new workbox.NavigationRoute(workbox.createHandlerBoundToURL("/offline.html"), {
allowlist: [/^\/$/]
}));
workbox.registerRoute(/https:\/\/backopt-production.up.railway.app\/productos\/productos/, new workbox.StaleWhileRevalidate({
"cacheName": "productos-cache",
plugins: [new workbox.ExpirationPlugin({
maxEntries: 50,
maxAgeSeconds: 86400
})]
}), 'GET');
workbox.registerRoute(({
request
}) => request.destination === "document" || request.destination === "script" || request.destination === "style", new workbox.CacheFirst({
"cacheName": "app-shell-cache",
plugins: [new workbox.ExpirationPlugin({
maxEntries: 10,
maxAgeSeconds: 604800
})]
}), 'GET');
workbox.registerRoute(({
request
}) => request.destination === "image", new workbox.CacheFirst({
"cacheName": "images-cache",
plugins: [new workbox.ExpirationPlugin({
maxEntries: 50,
maxAgeSeconds: 2592000
})]
}), 'GET');
workbox.initialize({});

}));
Loading

0 comments on commit a987727

Please sign in to comment.