From 5cc22a2609dc4f827918c195c8bef0ea49f38d6e Mon Sep 17 00:00:00 2001
From: Varac <varac@varac.net>
Date: Thu, 10 Jun 2021 10:22:02 +0200
Subject: [PATCH] Test apps individually with TAIKO_TESTS env var

---
 test/taiko/ptf-demo/ptf-demo.js | 138 ++++++++++++++++++--------------
 1 file changed, 76 insertions(+), 62 deletions(-)

diff --git a/test/taiko/ptf-demo/ptf-demo.js b/test/taiko/ptf-demo/ptf-demo.js
index 0af80a78d..9e82c2a14 100644
--- a/test/taiko/ptf-demo/ptf-demo.js
+++ b/test/taiko/ptf-demo/ptf-demo.js
@@ -1,12 +1,9 @@
-// Todo:
-
-
-
-const { openBrowser, goto, textBox, into, write, click, below, link, press, button, closeBrowser } = require('taiko')
+const { openBrowser, goto, textBox, into, write, click, below, link, press, button, closeBrowser, screencast } = require('taiko')
 const assert = require('assert').strict;
 
 (async () => {
   try {
+    const taiko_tests = process.env.TAIKO_TESTS || "all"
     const username = process.env.SSO_USERNAME
     const pw = process.env.SSO_USER_PW
     const domain = process.env.DOMAIN
@@ -15,6 +12,8 @@ const assert = require('assert').strict;
 
     console.log('• Login to admin panel')
     await openBrowser()
+    await screencast.startScreencast('output.gif')
+
     await goto(adminpanel_url)
     await click('Login')
     await click('Login with OAS')
@@ -23,69 +22,84 @@ const assert = require('assert').strict;
     await click('Remember me')
     await click('Sign in')
 
-    // console.log('• Nextcloud and Onlyoffice')
-    // await click(link(below('nextcloud')))
-    // await click('Log in with OpenAppStack')
-    // await click('Continue with demo')
-
-    // // Close potential nextcloud modal
-    // await press('Escape')
-
-    // // Open document
-    // await click(link('Documents'))
-    // await click(link('Welcome to Nextcloud Hub.docx'))
-
-    // // Logout
-    // click(image())
-    // click('Log out')
-
-    // Navigate to rocketchat
-    // Breaks because of 2fa challenge which is not recieved
-    // by email
-    // TODO: Create issue
-    // await click(link(below('rocketchat')));
-    // await click('Login via OpenAppStack');
-    // await click('Continue with demo');
-
-    // console.log('• Wordpress')
-    // await goto(adminpanel_url)
-    // await click(link(below('wordpress')))
-    // await click('Log in')
-    // await click('Login with OpenID Connect')
-    // await click('Continue with demo')
-
-    console.log('• Grafana')
-    await goto(adminpanel_url)
-    await click(link(below('grafana')))
-    await click('Sign in with OpenAppStack')
-    await click('Continue with demo')
-
-    // Node exporter dashboard
-    // Couldn't select "Manage dashboards" from the sidebar menu easily,
-    // so we just go there
-    // await goto(grafana_url + '/dashboards')
-    // click('Nodes')
-
-    // Explore Loki log messages
-    await goto(grafana_url + '/explore')
-    // only visible in bigger screens
-    //await click('Prometheus')
-    await click(image(toRightOf('Explore')))
-    await click('Loki')
-    await click('Log browser')
-    await click('app')
-    await click('cert-manager')
-    await click('grafana')
-    await click('Show logs')
-    // write('{job=~".*"} |~ "error|fail|exception|fatal"')
-    //click('Run Query')
+    // Nextcloud
+    if (taiko_tests.includes('nextcloud') || taiko_tests == 'all') {
+      console.log('• Nextcloud and Onlyoffice')
+      await click(link(below('nextcloud')))
+      await click('Log in with OpenAppStack')
+      await click('Continue with ' + username)
+
+      // Close potential nextcloud modal
+      await press('Escape')
+
+      // Open document
+      await click(link('Documents'))
+      await click(link('Welcome to Nextcloud Hub.docx'))
+
+      // Logout
+      click(image())
+      click('Log out')
+    }
+
+    // Rocketchat
+    if (taiko_tests.includes('rocketchat') || taiko_tests == 'all') {
+      // Navigate to rocketchat
+      // Breaks because of 2fa challenge which is not recieved
+      // by email
+      // TODO: Create issue
+      // await click(link(below('rocketchat')));
+      // await click('Login via OpenAppStack');
+      //  await click('Continue with ' + username)
+    }
+
+    // Wordpress
+    if (taiko_tests.includes('wordpress') || taiko_tests == 'all') {
+      // console.log('• Wordpress')
+      // await goto(adminpanel_url)
+      // await click(link(below('wordpress')))
+      // await click('Log in')
+      // await click('Login with OpenID Connect')
+      //  await click('Continue with ' + username)
+    }
+
+    if (taiko_tests.includes('wordpress') || taiko_tests == 'all') {
+      console.log('• Grafana')
+      await goto(adminpanel_url)
+      await click(link(below('grafana')))
+      await click('Sign in with OpenAppStack')
+      await click('Continue with ' + username)
+    }
+
+    // Grafana
+    if (taiko_tests.includes('grafana') || taiko_tests == 'all') {
+      // Node exporter dashboard
+      // Couldn't select "Manage dashboards" from the sidebar menu easily,
+      // so we just go there
+      await goto(grafana_url + '/dashboards')
+      click('Nodes')
+
+      // Explore Loki log messages
+      await goto(grafana_url + '/explore')
+      await click(image(toRightOf('Explore')))
+      await click('Loki')
+      await click('Log browser')
+      await click('app')
+      await click('cert-manager')
+      await click('grafana')
+      await click('Show logs')
+      // write('{job=~".*"} |~ "error|fail|exception|fatal"')
+      //click('Run Query')
+    }
+
+    // Wait a bit before closing browser
     await waitFor(20000)
 
-
   } catch (error) {
     await screenshot()
+    await screencast.stopScreencast();
     console.error(error)
   } finally {
+    await screencast.stopScreencast();
     await closeBrowser()
   }
 })()
-- 
GitLab