Skip to content

Commit

Permalink
Merge pull request #15 from hemit-s/tests
Browse files Browse the repository at this point in the history
Cucumber Tests
  • Loading branch information
xenown authored Jul 12, 2022
2 parents 34d4ea1 + f1b1d7c commit d99c20d
Show file tree
Hide file tree
Showing 31 changed files with 1,295 additions and 159 deletions.
13 changes: 0 additions & 13 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"start:renderer": "cross-env NODE_ENV=development TS_NODE_TRANSPILE_ONLY=true webpack serve --config ./.erb/configs/webpack.config.renderer.dev.ts",
"test": "jest",
"test:unit": "jest --testMatch **/__tests__/unit_tests/*.ts?(x)",
"test:cucumber": "jest --testMatch **/__tests__/cucumber_tests/*.ts?(x)"
"test:cucumber": "jest --testMatch **/__tests__/cucumber_tests/*.ts?(x) --runInBand"
},
"lint-staged": {
"*.{js,jsx,ts,tsx}": [
Expand Down Expand Up @@ -157,7 +157,6 @@
"eslint-plugin-react": "^7.29.4",
"eslint-plugin-react-hooks": "^4.5.0",
"file-loader": "^6.2.0",
"get-random-values-polypony": "^1.0.0",
"html-webpack-plugin": "^5.5.0",
"husky": "^8.0.1",
"identity-obj-proxy": "^3.0.0",
Expand Down
2 changes: 1 addition & 1 deletion release/app/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "aqua",
"version": "0.0.5",
"version": "0.0.6",
"description": "An audio equalizer app",
"license": "MIT",
"author": {
Expand Down
57 changes: 57 additions & 0 deletions src/__tests__/cucumber_tests/change_number_of_bands.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/*
* @jest-environment node
*/
// This is necessary so that jest and regedit works correctly in the test environment
// Specifically, functions getRandomValues and setImmediate become well defined.

import { loadFeature, defineFeature } from 'jest-cucumber';
import {
Driver,
startChromeDriver,
stopChromeDriver,
} from '__tests__/utils/webdriver';
import { givenAquaIsRunning, givenEnabledState } from './shared_steps/aqua';
import { givenBandCount, whenChangeBandCount } from './shared_steps/aquaSlider';
import { thenBandCount } from './shared_steps/config';
import {
givenCanWriteToAquaConfig,
givenEqualizerApoIsInstalled,
} from './shared_steps/equalizerApo';

const chromeDriver = startChromeDriver();

const feature = loadFeature(
'./src/__tests__/cucumber_tests/features/change_number_of_bands.feature'
);
const webdriver: { driver: Driver } = { driver: undefined };

defineFeature(feature, (test) => {
test('Add a frequency band', async ({ given, when, then }) => {
givenEqualizerApoIsInstalled(given);
givenCanWriteToAquaConfig(given);
givenAquaIsRunning(given, webdriver, chromeDriver);
givenEnabledState(given, webdriver);
givenBandCount(given, webdriver);

whenChangeBandCount(when, webdriver);
thenBandCount(then);
}, 30000);

test('Remove a frequency band', async ({ given, when, then }) => {
givenEqualizerApoIsInstalled(given);
givenCanWriteToAquaConfig(given);
givenAquaIsRunning(given, webdriver, chromeDriver);
givenEnabledState(given, webdriver);
givenBandCount(given, webdriver);

whenChangeBandCount(when, webdriver);
thenBandCount(then);
}, 30000);
});

afterAll(() => {
if (webdriver.driver) {
webdriver.driver.deleteSession();
}
stopChromeDriver(chromeDriver);
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
Feature: Change number of frequency bands
Users want to increase or decrease the number of frequency bands

Scenario: Add a frequency band
Given EqualizerAPO is installed
And Aqua can write to Aqua config
And Aqua is running
And Aqua equalizer state is enabled
And there are 10 frequency bands
When I click to add a frequency band
Then Aqua config file should show 11 frequency bands

Scenario: Remove a frequency band
Given EqualizerAPO is installed
And Aqua can write to Aqua config
And Aqua is running
And Aqua equalizer state is enabled
And there are 10 frequency bands
When I click to remove a frequency band
Then Aqua config file should show 9 frequency bands
19 changes: 19 additions & 0 deletions src/__tests__/cucumber_tests/features/set_band_frequency.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
Feature: Set frequency for a band
Users want to change the frequency that a band represents

Scenario: Set a new frequency using the input field
Given EqualizerAPO is installed
And Aqua can write to Aqua config
And Aqua is running
And Aqua equalizer state is enabled
When I set the frequency of band 1 to 100Hz
Then Aqua config file should show a frequency of 100Hz for band 1

Scenario: Set a new frequency using the arrow buttons
Given EqualizerAPO is installed
And Aqua can write to Aqua config
And Aqua is running
And the frequency of band 1 is 32Hz
And Aqua equalizer state is enabled
When I click on the up arrow of band 1 2 times
Then Aqua config file should show a frequency of 34Hz for band 1
12 changes: 6 additions & 6 deletions src/__tests__/cucumber_tests/features/set_band_gain.feature
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ Feature: Set gain of a frequency band
Users want to change the gain of a filter applied to a certain frequency

Scenario: Move slider to bottom
Given Peace is installed
And Peace is running
And Aqua is not running
When Aqua is launched
And I set gain of slider of frequency 125Hz to bottom
Then Peace should show gain of -30dB for frequency 125Hz
Given EqualizerAPO is installed
And Aqua can write to Aqua config
And Aqua is running
And Aqua equalizer state is enabled
When I set gain of slider of frequency 1000Hz to bottom
Then Aqua config file should show gain of -30dB for frequency 1000Hz
19 changes: 19 additions & 0 deletions src/__tests__/cucumber_tests/features/set_band_quality.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
Feature: Set quality of a frequency band
Users want to change the quality that is applied to a certain frequency

Scenario: Select a new quality using the input field
Given EqualizerAPO is installed
And Aqua can write to Aqua config
And Aqua is running
And Aqua equalizer state is enabled
When I set the quality to 1.41 for the band with frequency 125Hz
Then Aqua config file should show a quality of 1.41 for the band with frequency 125Hz

Scenario: Select a new quality using the arrow buttons
Given EqualizerAPO is installed
And Aqua can write to Aqua config
And Aqua is running
And the quality for the band with frequency 125Hz is 0.5
And Aqua equalizer state is enabled
When I click on the up arrow for the quality for frequency 125Hz 2 times
Then Aqua config file should show a quality of 0.502 for the band with frequency 125Hz
18 changes: 18 additions & 0 deletions src/__tests__/cucumber_tests/features/set_enable.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
Feature: Set whether the equalizer is enabled or disabled
Users want to toggle whether the equalizer is enabled or disabled

Scenario: Enable the equalizer
Given EqualizerAPO is installed
And Aqua can write to Aqua config
And Aqua is running
And Aqua equalizer state is disabled
When I toggle the equalizer state
Then Aqua config file should be non-empty

Scenario: Disable the equalizer
Given EqualizerAPO is installed
And Aqua can write to Aqua config
And Aqua is running
And Aqua equalizer state is enabled
When I toggle the equalizer state
Then Aqua config file should be empty
11 changes: 11 additions & 0 deletions src/__tests__/cucumber_tests/features/set_filter_type.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
Feature: Set filter type of a frequency band
Users want to change the type of filter that is applied to a certain frequency

Scenario: Select a new filter type using a mouse
Given EqualizerAPO is installed
And Aqua can write to Aqua config
And Aqua is running
And the filter type is LPQ filter for the band with frequency 125Hz
And Aqua equalizer state is enabled
When I set the filter type to PK filter for the band with frequency 125Hz
Then Aqua config file should show the PK filter type for the band with frequency 125Hz
19 changes: 19 additions & 0 deletions src/__tests__/cucumber_tests/features/set_preamp_gain.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
Feature: Set preamplification gain
Users want to change the preamplification gain

Scenario: Set preamp gain using the slider
Given EqualizerAPO is installed
And Aqua can write to Aqua config
And Aqua is running
And Aqua equalizer state is enabled
When I set gain of the preamp slider to the bottom
Then Aqua config should show a preamp gain of -30dB

Scenario: Set preamp gain using the arrows
Given EqualizerAPO is installed
And Aqua can write to Aqua config
And Aqua is running
And the preamp gain is 0dB
And Aqua equalizer state is enabled
When I click on the up arrow for the preamp gain 3 times
Then Aqua config should show a preamp gain of 3dB
68 changes: 68 additions & 0 deletions src/__tests__/cucumber_tests/set_band_frequency.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
/*
* @jest-environment node
*/
// This is necessary so that jest and regedit works correctly in the test environment
// Specifically, functions getRandomValues and setImmediate become well defined.

import { loadFeature, defineFeature } from 'jest-cucumber';
import {
Driver,
startChromeDriver,
stopChromeDriver,
} from '__tests__/utils/webdriver';
import { givenAquaIsRunning, givenEnabledState } from './shared_steps/aqua';
import {
givenBandFrequency,
whenSetBandFrequency,
whenSetBandFrequencyUsingArrows,
} from './shared_steps/aquaSlider';
import { thenBandFrequency } from './shared_steps/config';
import {
givenCanWriteToAquaConfig,
givenEqualizerApoIsInstalled,
} from './shared_steps/equalizerApo';

const chromeDriver = startChromeDriver();

const feature = loadFeature(
'./src/__tests__/cucumber_tests/features/set_band_frequency.feature'
);
const webdriver: { driver: Driver } = { driver: undefined };

defineFeature(feature, (test) => {
test('Set a new frequency using the input field', async ({
given,
when,
then,
}) => {
givenEqualizerApoIsInstalled(given);
givenCanWriteToAquaConfig(given);
givenAquaIsRunning(given, webdriver, chromeDriver);
givenEnabledState(given, webdriver);

whenSetBandFrequency(when, webdriver);
thenBandFrequency(then);
}, 30000);

test('Set a new frequency using the arrow buttons', async ({
given,
when,
then,
}) => {
givenEqualizerApoIsInstalled(given);
givenCanWriteToAquaConfig(given);
givenAquaIsRunning(given, webdriver, chromeDriver);
givenBandFrequency(given, webdriver);
givenEnabledState(given, webdriver);

whenSetBandFrequencyUsingArrows(when, webdriver);
thenBandFrequency(then);
}, 30000);
});

afterAll(() => {
if (webdriver.driver) {
webdriver.driver.deleteSession();
}
stopChromeDriver(chromeDriver);
});
31 changes: 16 additions & 15 deletions src/__tests__/cucumber_tests/set_band_gain.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,23 @@
/*
* @jest-environment node
*/
// This is necessary so that jest and regedit works correctly in the test environment
// Specifically, functions getRandomValues and setImmediate become well defined.

import { loadFeature, defineFeature } from 'jest-cucumber';
import getRandomValuesPolyPony from 'get-random-values-polypony'; // Need this to fix jest-cucumber's reliance on uuid's getRandomValues
import {
Driver,
startChromeDriver,
stopChromeDriver,
} from '__tests__/utils/webdriver';
import { givenAquaIsNotRunning, whenAquaIsLaunched } from './shared_steps/aqua';
import { givenAquaIsRunning, givenEnabledState } from './shared_steps/aqua';
import { whenSetFrequencyGain } from './shared_steps/aquaSlider';
import { thenFrequencyGain } from './shared_steps/config';
import {
givenPeaceIsRunning,
givenPeaceIsInstalled,
thenPeaceFrequencyGain,
} from './shared_steps/peace';
givenCanWriteToAquaConfig,
givenEqualizerApoIsInstalled,
} from './shared_steps/equalizerApo';

// shim the getRandomValues function used in uuid which is used by jest-cucumber
// so that it works in electron environment.
getRandomValuesPolyPony.polyfill();
const chromeDriver = startChromeDriver();

const feature = loadFeature(
Expand All @@ -25,14 +27,13 @@ const webdriver: { driver: Driver } = { driver: undefined };

defineFeature(feature, (test) => {
test('Move slider to bottom', async ({ given, when, then }) => {
givenPeaceIsInstalled(given);
givenPeaceIsRunning(given);
givenAquaIsNotRunning(given);
givenEqualizerApoIsInstalled(given);
givenCanWriteToAquaConfig(given);
givenAquaIsRunning(given, webdriver, chromeDriver);
givenEnabledState(given, webdriver);

whenAquaIsLaunched(when, webdriver, chromeDriver);
whenSetFrequencyGain(when, webdriver);

thenPeaceFrequencyGain(then, webdriver);
thenFrequencyGain(then, webdriver);
}, 30000);
});

Expand Down
Loading

0 comments on commit d99c20d

Please sign in to comment.