diff --git a/.gitignore b/.gitignore index 2a94264ad..1a3db7964 100644 --- a/.gitignore +++ b/.gitignore @@ -30,6 +30,7 @@ npm-debug.log* /platforms /plugins /www +/www0 /mobilefirst # Custom diff --git a/package.json b/package.json index 0213b0e69..beadddbba 100644 --- a/package.json +++ b/package.json @@ -10,7 +10,8 @@ "lint": "ng lint", "e2e": "ng e2e", "nice": "node server.js", - "test": "jest --runInBand" + "test": "jest --detectOpenHandles --runInBand", + "dev": "lite-server --baseDir=www" }, "private": true, "dependencies": { diff --git a/test/0-login.spec.ts b/test/0-login.spec.ts deleted file mode 100644 index ef6493520..000000000 --- a/test/0-login.spec.ts +++ /dev/null @@ -1,62 +0,0 @@ -import { environment } from './../src/environments/environment' - -describe('Puppeteer tests', () => { - - beforeAll(async () => { - // await page.goto(process.env.PUPPETEER_HOST) - - }) - - - - test('[table] Clear Code button and set pin', async () => { - - // const browser = await puppeteer.launch({headless: false}); - await page.setViewport({width: 1200, height: 720}); - await page.goto(process.env.PUPPETEER_HOST); // wait until page load - await page.waitForSelector('.btn-ok') - - - await page.evaluate( () => { - let a: HTMLInputElement = document.querySelector('input[type="text"]') - a.value = '' - - let b: HTMLInputElement = document.querySelector('input[type="password"') - b.value = '' - }) - - await page.type('input[type="text"]', environment.defaultuser); - await page.type('input[type="password"]', environment.defaultuserpwd); - // click and wait for navigation - await Promise.all([ - page.click('.btn-ok'), - // page.waitForNavigation({ waitUntil: 'networkidle0' }), - ]); - - await page.waitForSelector('.circle') - // define code - await page.click('.circle') - await page.click('.circle') - await page.click('.circle') - - // clear code - await page.click('.cy-clear') - - // define code - await page.click('.circle') - await page.click('.circle') - await page.click('.circle') - await page.click('.circle') - - - await page.click('.div-profile') - - expect(3 + 2).toBe(5); - },30000); - - - - - -}); - diff --git a/test/Xgenda.spec.ts b/test/Agenda.spec.ts similarity index 61% rename from test/Xgenda.spec.ts rename to test/Agenda.spec.ts index 1fec9e3d3..fbc721d1e 100644 --- a/test/Xgenda.spec.ts +++ b/test/Agenda.spec.ts @@ -1,4 +1,6 @@ import { environment } from '../src/environments/environment' +import { loginTest } from './login.spec' + describe('Puppeteer tests', () => { @@ -6,24 +8,23 @@ describe('Puppeteer tests', () => { // await page.goto(process.env.PUPPETEER_HOST) }) - test('[table] create event', async () => { - // const browser = await puppeteer.launch({headless: false}); await page.setViewport({width: 1200, height: 720}); await page.goto(process.env.PUPPETEER_HOST); // wait until page load - await page.waitForSelector('ion-tab-bar ion-tab-button:nth-child(3)') - await page.click('ion-tab-bar ion-tab-button:nth-child(3)') - - await page.waitForSelector('ion-content ion-row .cy-add-event') + await page.waitForSelector('ion-app') + + await loginTest(page) + + // wait for footer button + await page.click('ion-tab-bar ion-tab-button:nth-child(2)') + // click add event + await page.click('ion-content ion-row .cy-add-event') + // await page.waitForSelector('app-new-event') expect(3 + 2).toBe(5); },30000); - - - - }); diff --git a/test/login.spec.ts b/test/login.spec.ts new file mode 100644 index 000000000..c786b33af --- /dev/null +++ b/test/login.spec.ts @@ -0,0 +1,113 @@ +import { environment } from './../src/environments/environment' + + +export const loginTest = async (page) => { + await page.setViewport({width: 1200, height: 720}); + await page.goto(process.env.PUPPETEER_HOST); // wait until page load + await page.waitForSelector('.btn-ok') + await page.waitForSelector('ion-app') + + const pathname = await page.evaluate( () => window.location.pathname) + + if (pathname == '/') { + await page.evaluate( () => { + let a: HTMLInputElement = document.querySelector('input[type="text"]') + a.value = '' + + let b: HTMLInputElement = document.querySelector('input[type="password"') + b.value = '' + }) + + await page.type('input[type="text"]', environment.defaultuser); + await page.type('input[type="password"]', environment.defaultuserpwd); + // click and wait for navigation + await Promise.all([ + page.click('.btn-ok'), + // page.waitForNavigation({ waitUntil: 'networkidle0' }), + ]); + + await page.waitForSelector('.circle') + // define code + await page.click('.circle') + await page.click('.circle') + await page.click('.circle') + + // clear code + await page.click('.cy-clear') + + // define code + await page.click('.circle') + await page.click('.circle') + await page.click('.circle') + await page.click('.circle') + + await page.waitForSelector('.div-profile') + } +} + + +describe('Puppeteer tests', () => { + + beforeAll(async () => { + // await page.goto(process.env.PUPPETEER_HOST) + + }) + + + + test('[table] Clear Code button and set pin', async () => { + + const pathname = await page.evaluate( () => window.location.pathname) + if (pathname == '/') { + + // const browser = await puppeteer.launch({headless: false}); + await page.setViewport({width: 1200, height: 720}); + await page.goto(process.env.PUPPETEER_HOST); // wait until page load + await page.waitForSelector('.btn-ok') + + + await page.evaluate( () => { + let a: HTMLInputElement = document.querySelector('input[type="text"]') + a.value = '' + + let b: HTMLInputElement = document.querySelector('input[type="password"') + b.value = '' + }) + + await page.type('input[type="text"]', environment.defaultuser); + await page.type('input[type="password"]', environment.defaultuserpwd); + // click and wait for navigation + await Promise.all([ + page.click('.btn-ok'), + // page.waitForNavigation({ waitUntil: 'networkidle0' }), + ]); + + await page.waitForSelector('.circle') + // define code + await page.click('.circle') + await page.click('.circle') + await page.click('.circle') + + // clear code + await page.click('.cy-clear') + + // define code + await page.click('.circle') + await page.click('.circle') + await page.click('.circle') + await page.click('.circle') + + await page.waitForSelector('.div-profile') + await page.click('.div-profile') + + } + + expect(3 + 2).toBe(5); + },30000); + + + + + +}); +