Skip to content

Commit f584f20

Browse files
committed
Fix BrowserStack API usage and several tests
1 parent b2d1b18 commit f584f20

File tree

6 files changed

+160
-72
lines changed

6 files changed

+160
-72
lines changed

.vscode/settings.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@
33
"search.exclude": {
44
"build/**/*": true,
55
"lib/**/*": true,
6-
"src/.next/**/*": true,
6+
"src/.next/**/*": true
77
},
88
// Custom formatting rules
99
"editor.wordWrapColumn": 100,
1010
"javascript.validate.enable": false,
1111
"editor.formatOnSave": true,
1212
"editor.codeActionsOnSave": {
1313
"source.organizeImports": "always",
14-
"source.fixAll": "always",
14+
"source.fixAll": "always"
1515
},
1616
"eslint.enable": true,
1717
"javascript.format.enable": false,

run_tests.sh

100644100755
File mode changed.

tests/conf/parallel.conf.js

+102-65
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,36 @@ const { setCurrentTest } = require('../lib/currentTest');
44

55
const isLocalBuild = process.env.BROWSERSTACK_LOCAL === '1';
66

7+
function checkEnvironmentVariables() {
8+
const errorMessages = [];
9+
if (!process.env.BROWSERSTACK_USERNAME) {
10+
errorMessages.push('- Please set BROWSERSTACK_USERNAME to your BrowserStack username.');
11+
}
12+
if (!process.env.BROWSERSTACK_ACCESS_KEY) {
13+
errorMessages.push('- Please set BROWSERSTACK_ACCESS_KEY to your BrowserStack access key.');
14+
}
15+
if (!process.env.CI_TEST_DEPLOYMENT_BASE_URL) {
16+
errorMessages.push('- Please set CI_TEST_DEPLOYMENT_BASE_URL to the URL of the app to test.');
17+
}
18+
19+
if (!isLocalBuild) {
20+
if (!process.env.CI_TEST_GIT_REF) {
21+
errorMessages.push('- Please set CI_TEST_GIT_REF to the git ref of the current build.');
22+
}
23+
if (!process.env.CI_TEST_GIT_SHA1) {
24+
errorMessages.push('- Please set CI_TEST_GIT_SHA1 to the git sha1 of the current build.');
25+
}
26+
}
27+
28+
if (errorMessages.length > 0) {
29+
console.error('Error: Missing environment variables:');
30+
errorMessages.forEach((message) => console.error(message));
31+
process.exit(1);
32+
}
33+
}
34+
35+
checkEnvironmentVariables();
36+
737
// https://github.com/browserstack/webdriverio-browserstack
838
exports.config = {
939
user: process.env.BROWSERSTACK_USERNAME,
@@ -19,18 +49,19 @@ exports.config = {
1949
],
2050

2151
updateJob: false,
22-
specs: ['./tests/specs/**/*.js'],
52+
specs: ['../specs/**/*.js'],
2353
exclude: [],
24-
maxInstances: 2,
54+
maxInstances: 1,
2555

2656
commonCapabilities: {
27-
project: 'Wheelmap Frontend',
28-
build: isLocalBuild
29-
? 'Local build'
30-
: [process.env.CI_TEST_GIT_REF, process.env.CI_TEST_GIT_SHA1].join(' - '),
31-
// name: 'parallel_test',
32-
'browserstack.debug': true,
33-
'browserstack.local': 'false',
57+
'bstack:options': {
58+
project: 'Wheelmap Frontend',
59+
buildName: isLocalBuild
60+
? 'Local build'
61+
: [process.env.CI_TEST_GIT_REF, process.env.CI_TEST_GIT_SHA1].join(' - '),
62+
'debug': true,
63+
// 'browserstack.local': `${isLocalBuild}`,
64+
}
3465
},
3566

3667
// Use https://www.browserstack.com/automate/capabilities to create capability sets.
@@ -41,70 +72,76 @@ exports.config = {
4172

4273
capabilities: [
4374
{
44-
os: 'OS X',
45-
os_version: 'Catalina',
4675
browserName: 'Chrome',
47-
browser_version: '87',
48-
'browserstack.selenium_version': '4.0.0-alpha-6',
49-
autoAcceptAlerts: 'true',
50-
'goog:chromeOptions': {
51-
prefs: {
52-
// 0 - Default, 1 - Allow, 2 - Block
53-
'profile.managed_default_content_settings.geolocation': 1,
54-
},
55-
},
56-
},
57-
{
58-
os: 'Windows',
59-
os_version: '7',
60-
browserName: 'Firefox',
61-
browser_version: 'latest',
62-
autoAcceptAlerts: 'true',
63-
'browserstack.selenium_version': '3.10.0',
64-
},
65-
{
6676
'bstack:options': {
77+
browserVersion: 'latest',
6778
os: 'OS X',
68-
osVersion: 'Big Sur',
69-
local: 'false',
70-
seleniumVersion: '4.0.0-alpha-6',
79+
osVersion: 'Sonoma',
7180
userName: 'holgerdieterich1',
7281
accessKey: 'S2Lp7oshaL7SB38mn2TC',
73-
seleniumLogs: true,
82+
selfHeal: true,
7483
},
75-
browserName: 'Safari',
76-
browserVersion: '14.0',
77-
},
78-
{
79-
'bstack:options': {
80-
os: 'Windows',
81-
osVersion: '10',
82-
local: 'false',
83-
seleniumVersion: '4.0.0-alpha-6',
84-
userName: 'holgerdieterich1',
85-
accessKey: 'S2Lp7oshaL7SB38mn2TC',
84+
'goog:chromeOptions': {
85+
prefs: {
86+
// 0 - Default, 1 - Allow, 2 - Block
87+
'profile.managed_default_content_settings.geolocation': 1,
88+
},
8689
},
87-
browserName: 'Edge',
88-
browserVersion: 'latest',
89-
autoAcceptAlerts: 'true',
90-
},
91-
{
92-
os_version: '14',
93-
device: 'iPhone 12',
94-
real_mobile: 'true',
95-
browserName: 'iPhone',
96-
autoAcceptAlerts: 'true',
97-
'browserstack.appium_version': '1.19.1',
98-
},
99-
{
100-
os_version: '10.0',
101-
device: 'Samsung Galaxy S20',
102-
real_mobile: 'true',
103-
'browserstack.appium_version': '1.19.1',
104-
browserName: 'Android',
105-
// This doesn't work - we have to manually accept the alert dialog
106-
autoAcceptAlerts: 'true',
10790
},
91+
// {
92+
// browserName: 'Firefox',
93+
// 'bstack:options': {
94+
// browserVersion: '127.0',
95+
// os: 'Windows',
96+
// osVersion: '11',
97+
// selfHeal: true,
98+
// userName: 'holgerdieterich1',
99+
// accessKey: 'S2Lp7oshaL7SB38mn2TC',
100+
// }
101+
// },
102+
// {
103+
// 'bstack:options': {
104+
// os: 'OS X',
105+
// osVersion: 'Big Sur',
106+
// local: 'false',
107+
// seleniumVersion: '4.0.0-alpha-6',
108+
// userName: 'holgerdieterich1',
109+
// accessKey: 'S2Lp7oshaL7SB38mn2TC',
110+
// seleniumLogs: true,
111+
// },
112+
// browserName: 'Safari',
113+
// browserVersion: '14.0',
114+
// },
115+
// {
116+
// browserName: 'Edge',
117+
// 'bstack:options': {
118+
// browserVersion: '125.0',
119+
// os: 'Windows',
120+
// osVersion: '11',
121+
// userName: 'holgerdieterich1',
122+
// accessKey: 'S2Lp7oshaL7SB38mn2TC',
123+
// selfHeal: true,
124+
// }
125+
// },
126+
// {
127+
// browserName: 'safari',
128+
// 'bstack:options': {
129+
// deviceOrientation: 'portrait',
130+
// deviceName: 'iPhone 12 Mini',
131+
// osVersion: '16',
132+
// // autoAcceptAlerts: 'true',
133+
// }
134+
// },
135+
// {
136+
// browserName: 'samsung',
137+
// // This doesn't work - we have to manually accept the alert dialog
138+
// 'bstack:options': {
139+
// // autoGrantPermissions: 'true',
140+
// deviceOrientation: 'portrait',
141+
// deviceName: 'Samsung Galaxy S22',
142+
// osVersion: '12.0'
143+
// }
144+
// }
108145
],
109146

110147
logLevel: 'warn',

tests/specs-todo/different-place-types.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
require('dotenv').config();
22

3-
describe('Different place-of-interedt types:', () => {
3+
describe('Different place-of-interest types:', () => {
44
describe('an OpenStreetMap place', () => {
55
it('has a title');
66
it('has an icon');

tests/specs/highlighted-marker.js

+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
const acceptLocationAlertOnMobilesIfPresent = require('../lib/acceptLocationAlertOnMobilesIfPresent');
2+
const saveScreenshot = require('../lib/saveScreenshot');
3+
4+
// See the WebDriver API documentation for a list of possible actions.
5+
// https://webdriver.io/docs/api.html
6+
// https://github.com/webdriverio/expect-webdriverio/blob/HEAD/docs/API.md
7+
8+
// See the Mocha API for test structure: https://mochajs.org/
9+
const IdPropertyName = 'element-6066-11e4-a52e-4f735466cecf';
10+
11+
describe('Highlighted marker', function() {
12+
it('is shown on deeplinks', async function() {
13+
await browser.url('/node/30217208');
14+
await acceptLocationAlertOnMobilesIfPresent();
15+
16+
const $button = await $('button=Okay, let’s go!');
17+
await $button.click();
18+
19+
const $placeInfoPanel = await $('.toolbar[aria-label="Berlin Alexanderplatz"]');
20+
const $placeName = await $placeInfoPanel.$('h1=Berlin Alexanderplatz');
21+
await expect($placeName).toBeDisplayedInViewport();
22+
await saveScreenshot('After opening');
23+
24+
const $highlightedMarker = await $('a.highlighted-marker[aria-label="Berlin Alexanderplatz Fully wheelchair accessible"]');
25+
await expect($highlightedMarker).toBeDisplayedInViewport();
26+
await saveScreenshot('Marker visible');
27+
});
28+
29+
// it('has a logo', async function() {
30+
// await browser.url('/');
31+
// await acceptLocationAlertOnMobilesIfPresent();
32+
// const $dialog = await browser.$('section.modal-dialog');
33+
// const $logo = await $dialog.$('.logo');
34+
// await expect($logo).toBeDisplayedInViewport();
35+
// await expect($logo).toHaveAttr('aria-label', 'Wheelmap');
36+
// const $logoSVG = await $logo.$('svg');
37+
// await expect($logoSVG).toBeDisplayedInViewport();
38+
// });
39+
40+
// it('closes by clicking start button', async function() {
41+
// await browser.url('/');
42+
// await acceptLocationAlertOnMobilesIfPresent();
43+
// const $dialog = await browser.$('section.modal-dialog');
44+
// await expect($dialog).toBeDisplayedInViewport();
45+
// await saveScreenshot('Onboarding dialog');
46+
// const $button = await browser.$('button=Okay, let’s go!');
47+
// await $button.click();
48+
// await expect($dialog).not.toBeDisplayedInViewport();
49+
// await saveScreenshot('After closing the onboarding');
50+
// });
51+
});

tests/specs/search-by-name.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -38,21 +38,21 @@ describe('Searching a place by name', function() {
3838
await expect($results).toBeDisplayedInViewport();
3939
await saveScreenshot('Search results are loading');
4040

41-
const $result = await $results.$('header=Alexanderplatz');
41+
const $result = await $results.$('header=Berlin Alexanderplatz');
4242
await saveScreenshot('Search results are displayed');
4343

4444
// Wait for wheelchair accessibility to be loaded
4545
await browser.waitUntil(
46-
async () => await (await $results.$('header.is-on-wheelmap=Alexanderplatz')).isDisplayed()
46+
async () => await (await $results.$('header.is-on-wheelmap=Berlin Alexanderplatz')).isDisplayed()
4747
);
4848

4949
await saveScreenshot('Search results show their accessibility');
5050

51-
const $resultAfterSearch = await $results.$('header=Alexanderplatz');
51+
const $resultAfterSearch = await $results.$('header=Berlin Alexanderplatz');
5252
await $resultAfterSearch.waitForClickable();
5353
await $resultAfterSearch.click();
5454

55-
await browser.waitUntil(async () => (await getCurrentUrl()).match(/\/nodes\//));
55+
await browser.waitUntil(async () => (await getCurrentUrl()).match(/\/node\//));
5656
const results = await browser.findElement('css selector', '.search-results');
5757
await expect(results[IdPropertyName]).toBeUndefined();
5858
const $placeInfoPanel = await $('.toolbar[aria-label~="Alexanderplatz"');

0 commit comments

Comments
 (0)