diff --git a/test/taiko/apps.js b/test/taiko/apps.js new file mode 100644 index 0000000000000000000000000000000000000000..ba4aafd8e086310ce4372112a1ef5a6196b87396 --- /dev/null +++ b/test/taiko/apps.js @@ -0,0 +1,127 @@ +const { openBrowser, goto, textBox, into, write, click, toRightOf, below, link, press, image, waitFor, closeBrowser, screenshot } = require('taiko'); +const assert = require('assert'); + +(async () => { + try { + const taikoTests = process.env.TAIKO_TESTS || 'all' + const domain = process.env.DOMAIN + const globalTimeout = 60000 + + // https://docs.taiko.dev/api/setconfig/ + // setConfig( { observeTime: 1000}); + setConfig( { observeTime: 0, navigationTimeout: globalTimeout }); + + console.log('Executing these tests: ' + taikoTests) + await openBrowser() + // await screencast.startScreencast('output.gif') + + // Wait for manual screencast recording + // await waitFor(5000) + + // Nextcloud + if (taikoTests.includes('nextcloud') || taikoTests === 'all') { + const nextcloudUrl = 'https://files.' + domain + const nextcloudUsername = process.env.NEXTCLOUD_USERNAME || 'admin' + const nextcloudPassword = process.env.NEXTCLOUD_PASSWORD + console.log('• Nextcloud and Onlyoffice') + + await goto(nextcloudUrl) + await write(nextcloudUsername, into(textBox('Username'))) + await write(nextcloudPassword, into(textBox('Password'))) + + await click('Log in') + + // Close potential nextcloud modal + await press('Escape') + + // Open document and type some text + await click(link(), above('Add notes')) + await click('Document') + await press('Enter') + + let italicButtonId = '#id-toolbar-btn-italic' + await waitFor($(italicButtonId), globalTimeout) + + // Activate italic button + let buttonStateBefore = await evaluate($(italicButtonId), (elem) => {return elem.getAttribute('class')}) + await assert.ok(!buttonStateBefore.includes('active')) + await click($(italicButtonId)) + let buttonStateAfter = await evaluate($(italicButtonId), (elem) => {return elem.getAttribute('class')}) + await assert.ok(buttonStateAfter.includes('active')) + + await press(['H', 'i', ' ', 'f', 'r', 'o', 'm', ' ', 't', 'a', 'i', 'k', 'o', '!', 'Enter']) + + // Deactivate italic finially + await click($(italicButtonId)) + await closeTab() + } + + // Rocketchat + if (taikoTests.includes('rocketchat') || taikoTests === 'all') { + const rocketchatUrl = 'https://chat.' + domain + const rocketchatUsername = process.env.ROCKETCHAT_USERNAME || 'admin' + const rocketchatPassword = process.env.ROCKETCHAT_PASSWORD + + console.log('• Rocketchat') + await goto(rocketchatUrl) + await write(rocketchatUsername, into(textBox('Username'))) + await write(rocketchatPassword, into(textBox('Password'))) + await click('Login') + await waitFor('Welcome to Rocket.Chat!') + } + + // Wordpress + if (taikoTests.includes('wordpress') || taikoTests === 'all') { + const wordpressUrl = 'https://www.' + domain + const wordpressUsername = process.env.WORDPRESS_USERNAME || 'admin' + const wordpressPassword = process.env.WORDPRESS_PASSWORD + + console.log('• Wordpress') + await goto(wordpressUrl) + await click('Log in') + await write(wordpressUsername, into(textBox('Username'))) + await write(wordpressPassword, into(textBox('Password'))) + await click('Log in') + await assert.ok(await link('Dashboard').exists()) + } + + // Grafana + if (taikoTests.includes('grafana') || taikoTests === 'all') { + const grafanaUrl = 'https://grafana.' + domain + const grafanaUsername = process.env.GRAFANA_USERNAME || 'admin' + const grafanaPassword = process.env.GRAFANA_PASSWORD + + console.log('• Grafana') + await goto(grafanaUrl) + await write(grafanaUsername, into(textBox('Username'))) + await write(grafanaPassword, into(textBox('Password'))) + await click('Log in') + + // Node exporter dashboard + // Couldn't select "Manage dashboards" from the sidebar menu easily, + // so we just go there + await goto(grafanaUrl + '/dashboards') + await click(link('Nodes')) + await('CPU Usage') + + // Explore Loki log messages + await goto(grafanaUrl + '/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') + } + + } catch (error) { + await screenshot() + // await screencast.stopScreencast() + console.error(error) + process.exitCode = 1 + } finally { + // await screencast.stopScreencast() + await closeBrowser() + } +})() diff --git a/test/taiko/taiko-tests.js b/test/taiko/single-sign-on.js similarity index 98% rename from test/taiko/taiko-tests.js rename to test/taiko/single-sign-on.js index 72b1f295df1ee370bf768c7f99294a0e52568e49..bf487a071f616460b70131b6c2656fe74d01da6c 100644 --- a/test/taiko/taiko-tests.js +++ b/test/taiko/single-sign-on.js @@ -71,7 +71,7 @@ const assert = require('assert'); // Navigate to rocketchat // Breaks because of 2fa challenge which is not recieved // by email - // TODO: Create issue + // https://open.greenhost.net/openappstack/openappstack/-/issues/819 // await click(link(below('rocketchat'))); // await click('Login via OpenAppStack'); // await click('Continue with ' + username)