Skip to content

Commit

Permalink
Test for the settings-rollback location (#5065)
Browse files Browse the repository at this point in the history
  • Loading branch information
bakulf authored Nov 30, 2022
1 parent 18152e6 commit 412b283
Show file tree
Hide file tree
Showing 6 changed files with 139 additions and 16 deletions.
8 changes: 1 addition & 7 deletions .github/workflows/functional_tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -130,13 +130,7 @@ jobs:
- name: Build addons
shell: bash
if: steps.cache-build.outputs.cache-hit != 'true'
run: |
for i in tests/functional/addons/*; do
if ! [ -f $i/manifest.json ]; then
./scripts/addon/generate_all.py -p $i
fi
done
run: ./scripts/addon/generate_all_tests.py

- name: Running ${{matrix.test.name}} Tests
id: runTests
Expand Down
8 changes: 1 addition & 7 deletions .github/workflows/wasm.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -128,13 +128,7 @@ jobs:

- name: Build addons
shell: bash
if: steps.cache-build.outputs.cache-hit != 'true'
run: |
for i in tests/functional/addons/*; do
if ! [ -f $i/manifest.json ]; then
./scripts/addon/generate_all.py -p $i -q /opt/$QTVERSION/gcc_64/bin
fi
done
run: ./scripts/addon/generate_all_tests.py -q /opt/$QTVERSION/gcc_64/bin

- name: Running ${{matrix.test.name}} Tests
id: runTests
Expand Down
34 changes: 34 additions & 0 deletions scripts/addon/generate_all_tests.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#! /usr/bin/env python3
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.

import argparse
import os
import subprocess
import sys

parser = argparse.ArgumentParser(description="Generate an addon package")
parser.add_argument(
"-q",
"--qt_path",
default=None,
dest="qtpath",
help="The QT binary path. If not set, we try to guess.",
)
args = parser.parse_args()

generateall_path = os.path.join(os.path.dirname(os.path.realpath(__file__)), "generate_all.py")
addons_path = os.path.join(os.path.dirname(os.path.realpath(__file__)), "..", "..", "tests", "functional", "addons")

for file in os.listdir(addons_path):
manifest_path = os.path.join(addons_path, file, "manifest.json")
if os.path.exists(manifest_path):
print(f"Ignoring path {file} because the manifest already exists.")
continue

build_cmd = [sys.executable, generateall_path, "-p", os.path.join(addons_path, file)]
if args.qtpath:
build_cmd.append("-q")
build_cmd.append(args.qtpath)
subprocess.call(build_cmd)
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
"api_version": "0.1",
"id": "tutorial_01",
"name": "Tutorial: 01",
"type": "tutorial",
"tutorial": {
"id": "01",
"highlighted": true,
"settings_rollback_needed": true,
"image": "qrc:/addons/tutorial_01/image.svg",
"title": "Tutorial 01",
"subtitle": "Tutorial 01 sub",
"completion_message": "You’ve successfully completed tutorial 01",
"steps": [
{
"id": "mainScreen",
"element": "serverListButton-btn",
"tooltip": "Select your location",
"before": [{
"op": "vpn_off"
},{
"op": "vpn_location_set",
"exitCountryCode": "at",
"exitCity": "Vienna",
"entryCountryCode": "",
"entryCity": ""
}],
"next": {
"op": "signal",
"qml_emitter": "serverListButton-btn",
"signal": "visibleChanged"
}
}
]
}
}
4 changes: 2 additions & 2 deletions tests/functional/servers/addon.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ function createScenario(scenario, addonPath) {
if (!fs.existsSync(generatedPath)) {
const manifestPath = path.join(addonPath, 'manifest.json');
if (!fs.existsSync(manifestPath)) {
throw new Error(
`No generated and not manifest file! ${manifestPath} should exist!`);
throw new Error(`No generated and not manifest file! ${
manifestPath} should exist! Have you executed \`./scripts/addon/generate_all_tests.py'?`);
}

const obj = {};
Expand Down
65 changes: 65 additions & 0 deletions tests/functional/testAddons.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */

const assert = require('assert');
const {navBar, settingsScreen, homeScreen} = require('./elements.js');
const vpn = require('./helper.js');

describe('Addons', function() {
Expand Down Expand Up @@ -55,4 +56,68 @@ describe('Addons', function() {
10) === 1;
});
});

it('Settings rollback - location', async () => {
// Loading the custom tutorial
await vpn.resetAddons('05_settings_rollback');

await vpn.waitForCondition(async () => {
return parseInt(
await vpn.getElementProperty('VPNAddonManager', 'count'),
10) === 1;
});

const exitCityName =
await vpn.getElementProperty('VPNCurrentServer', 'exitCityName');
const exitCountryCode =
await vpn.getElementProperty('VPNCurrentServer', 'exitCountryCode');

// Let's start the tutorial
await vpn.waitForElementAndClick(navBar.SETTINGS);
await vpn.waitForElementAndClick(settingsScreen.TIPS_AND_TRICKS);
await vpn.waitForElementAndClick(homeScreen.TUTORIAL_LIST_HIGHLIGHT);

// Confirmation dialog for settings-rollback
await vpn.waitForElementProperty(
homeScreen.TUTORIAL_POPUP_PRIMARY_BUTTON, 'visible', 'true');
assert(
(await vpn.getElementProperty(
homeScreen.TUTORIAL_POPUP_PRIMARY_BUTTON, 'text')) === 'Continue');
await vpn.waitForElementAndClick(homeScreen.TUTORIAL_POPUP_PRIMARY_BUTTON);

await vpn.waitForCondition(async () => {
return await vpn.getElementProperty(
'VPNCurrentServer', 'exitCityName') === 'Vienna';
});

assert(
await vpn.getElementProperty('VPNCurrentServer', 'exitCityName') ===
'Vienna');
assert(
await vpn.getElementProperty('VPNCurrentServer', 'exitCountryCode') ===
'at');

await vpn.waitForElementAndClick('serverListButton-btn');

// Final dialog
await vpn.waitForElementProperty(
homeScreen.TUTORIAL_POPUP_PRIMARY_BUTTON, 'visible', 'true');
assert(
(await vpn.getElementProperty(
homeScreen.TUTORIAL_POPUP_PRIMARY_BUTTON, 'text')) === 'Let’s go!');
await vpn.waitForElementAndClick(
homeScreen.TUTORIAL_POPUP_SECONDARY_BUTTON);

await vpn.waitForCondition(async () => {
return await vpn.getElementProperty(
'VPNCurrentServer', 'exitCityName') === exitCityName;
});

assert(
await vpn.getElementProperty('VPNCurrentServer', 'exitCityName') ===
exitCityName);
assert(
await vpn.getElementProperty('VPNCurrentServer', 'exitCountryCode') ===
exitCountryCode);
});
});

0 comments on commit 412b283

Please sign in to comment.