Skip to content
This repository has been archived by the owner on May 1, 2024. It is now read-only.

Commit

Permalink
feat(settings): support changing the default Gherkin dialect (#48)
Browse files Browse the repository at this point in the history
  • Loading branch information
jkuester authored Jul 16, 2020
1 parent 496ec51 commit a503f3d
Show file tree
Hide file tree
Showing 10 changed files with 2,539 additions and 2,956 deletions.
5 changes: 3 additions & 2 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
{
"extends": "eslint-config-airbnb",
"extends": "eslint-config-airbnb-base",
"rules": {
"import/extensions": 0,
"import/no-extraneous-dependencies": 0,
"import/no-unresolved": [2, { "ignore": ["electron"] }],
"linebreak-style": 0
"linebreak-style": 0,
"no-param-reassign": 0
}
}
107 changes: 107 additions & 0 deletions features/app_settings.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
Feature: App Settings
<In order to> configure my experience with the app
<As a> user of cucumber-forge-desktop
<I want> to be able to adjust persistant settings for the app

Scenario: Toggling the settings view
Given there is a file named 'pets/dog_care.feature' with the following contents:
"""
Feature: Dog Care
Scenario: Feeding the Dog
Given the dog is hungery
When I give dog food to the dog
Then the dog will eat it
"""
When the user clicks the settings button
Then the settings view will be displayed
When the user clicks the settings button
Then the settings view will be hidden
When the user clicks the settings button
Then the settings view will be displayed
When the user selects the 'pets' directory with the folder selection button
Then the report will be displayed
And the settings view will be hidden
When the user clicks the settings button
Then the settings view will be displayed
And the report will be hidden
When the user clicks the settings button
And the settings view will be hidden
Then the report will be displayed

Scenario: Selecting an alternative Gherkin dialect
Reports can be generated for features written with alternative Gherkin dialects by selecting
the proper Default Gherkin Dialect in the Cucumber Forge settings.

Given there is a file named 'pets/afrikaans.feature' with the following contents:
"""
Besigheid Behoefte: Hondsorg
Agtergrond:
Gegewe Ek het 'n hond
Situasie: Die hond voed
Gegewe die hond is honger
Wanneer I give dog food to the dog
Dan Ek gee hondekos vir die hond
Situasie Uiteensetting: Die hondjie klapper
Wanneer Ek troeteldier van die hond se hare <direction:>
Dan die hond sal <result>
Maar die hond sal my nie byt nie
En die hond sal kalmeer
Voorbeelde:
| direction: | result |
| agteruit | lek my hand |
| voorspelers | grom |
"""
When the user clicks the settings button
And the user selects 'af' from the Default Gherkin Dialect drop-down menu
And the user selects the 'pets' directory with the folder selection button
Then the report will be displayed
And the report will contain 1 features
And the report will contain 2 scenarios

Scenario: Generating an HTML report for a feature file with an alternative Gherkin dialect when the language header is present in the feature
If there is a language header is present in the feature, that language will be prefered for that file when generating
report (regarless of the configured Default Gherkin Dialect in the Cucumber Forge setting). This allows for
generating reports for a set of feature files written with different Gherkin dialects.

Given there is a file named 'pets/dog_care.feature' with the following contents:
"""
Feature: Dog Care
Scenario: Feeding the Dog
Given the dog is hungery
When I give dog food to the dog
Then the dog will eat it
"""
And there is a file named 'pets/panjabi.feature' with the following contents:
"""
# language: pa
ਨਕਸ਼ ਨੁਹਾਰ: ਕੁੱਤੇ ਦੀ ਦੇਖਭਾਲ
ਪਿਛੋਕੜ:
ਜਿਵੇਂ ਕਿ ਮੇਰੇ ਕੋਲ ਇੱਕ ਕੁੱਤਾ ਹੈ
ਪਟਕਥਾ: ਕੁੱਤੇ ਨੂੰ ਖੁਆਉਣਾ
ਜੇਕਰ ਕੁੱਤਾ ਭੁੱਖਾ ਹੈ
ਜਦੋਂ ਮੈਂ ਕੁੱਤੇ ਨੂੰ ਖਾਣਾ ਦਿੰਦਾ ਹਾਂ
ਤਦ ਕੁੱਤਾ ਇਹ ਖਾਵੇਗਾ
ਪਟਕਥਾ ਰੂਪ ਰੇਖਾ: ਕੁੱਤਾ ਪਾਲ ਰਹੇ
ਜਦੋਂ ਮੈਂ ਕੁੱਤੇ ਦੇ ਵਾਲ ਪਾਲਤੂ ਹਾਂ <direction:>
ਤਦ ਕੁੱਤਾ ਕਰੇਗਾ <result>
ਪਰ ਕੁੱਤਾ ਮੈਨੂੰ ਨਹੀਂ ਡੰਗੇਗਾ
ਅਤੇ ਕੁੱਤਾ ਸ਼ਾਂਤ ਹੋ ਜਾਵੇਗਾ
ਉਦਾਹਰਨਾਂ:
| direction: | result |
| ਪਿੱਛੇ ਵੱਲ | ਮੇਰਾ ਹੱਥ ਚੱਟੋ |
| ਅੱਗੇ | ਫੁੱਟ |
"""
When the user clicks the settings button
And the user selects 'en' from the Default Gherkin Dialect drop-down menu
And the user selects the 'pets' directory with the folder selection button
Then the report will be displayed
And the report will contain 2 features
And the report will contain 3 scenarios
Original file line number Diff line number Diff line change
Expand Up @@ -101,19 +101,3 @@ Feature: Generate Report
| action: |
| clicks the filter button |
| presses enter |

Scenario: Saving an HTML report
Given the user selects the 'pets/felines' directory with the folder selection button
And the report is displayed
And the project title on the sidebar is 'felines'
When the user clicks the save button
Then the report will be saved in a file called 'felines.html'

Scenario: Saving an HTML report that is filtered by a tag
Given the user enters the value 'feeding' into the filter text box
And the user selects the 'pets' directory with the folder selection button
And the report is displayed
And the report name on the sidebar is 'feeding'
And the project title on the sidebar is 'pets'
When the user clicks the save button
Then the report will be saved in a file called 'feeding_pets.html'
80 changes: 80 additions & 0 deletions features/save_report.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
Feature: Save Report
<In order to> record or communicate feature documentation
<As a> user of cucumber-forge-desktop
<I want> to save HTML reports generated from the feature files

Background:
Given there is a file named 'pets/dog_care.feature' with the following contents:
"""
Feature: Dog Care
<In order to> care for and enjoy my pet
<As a> dog owner
<I want> interact with my dog
Background:
Given I have a dog
@feeding
Scenario: Feeding the Dog
Given the dog is hungery
When I give dog food to the dog
Then the dog will eat it
@petting
Scenario Outline: Petting the Dog
Dog's do not like to be pet in the wrong direction.
When I pet the dog's hair <direction:>
Then the dog will <result>
Examples:
| direction: | result |
| backwards | lick my hand |
| forwards | growl |
"""
And there is a file named 'pets/felines/cat_care.feature' with the following contents:
"""
Feature: Cat Care
<In order to> care for and enjoy my pet
<As a> cat owner
<I want> interact with my cat
Background:
Given I have a cat
@feeding
Scenario: Feeding the Cat
Given the cat is hungery
When I give the following food to the cat:
| fish |
| steak |
Then the cat will eat it
@petting
Scenario Outline: Petting the Cat
Cat's do not like to be pet in the wrong direction.
When I pet the cat's hair <direction:>
Then the cat will hiss
Examples:
| direction: |
| backwards |
| forwards |
"""

Scenario: Saving an HTML report
Given the user selects the 'pets/felines' directory with the folder selection button
And the report is displayed
And the project title on the sidebar is 'felines'
When the user clicks the save button
Then the report will be saved in a file called 'felines.html'

Scenario: Saving an HTML report that is filtered by a tag
Given the user enters the value 'feeding' into the filter text box
And the user selects the 'pets' directory with the folder selection button
And the report is displayed
And the report name on the sidebar is 'feeding'
And the project title on the sidebar is 'pets'
When the user clicks the save button
Then the report will be saved in a file called 'feeding_pets.html'
53 changes: 36 additions & 17 deletions features/support/steps.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,15 +73,15 @@ When('the user selects the {string} directory with the folder selection button',
});

When('the user enters the value {string} into the filter text box', function (tag) {
return this.app.client.addValue('#tagBox', tag);
return this.app.client.$('#tagBox').then((tagBoxElem) => tagBoxElem.addValue(tag));
});

When('the user clicks the filter button', function () {
return this.app.client.waitUntilWindowLoaded().click('#tagButton');
return this.app.client.$('#tagButton').then((buttonElem) => buttonElem.click());
});

When('the user presses enter', function () {
return this.app.client.addValue('#tagBox', '\n');
return this.app.client.$('#tagBox').then((tagBoxElem) => tagBoxElem.addValue('\n'));
});

When('the user clicks the save button', function () {
Expand All @@ -91,10 +91,29 @@ When('the user clicks the save button', function () {
});
});

Then(/the report (?:will be|is) displayed/, { timeout: 60 * 1000 }, function () {
// Wait for a second for the loading ind to disappear
return this.app.client.waitUntilWindowLoaded().getText('#output')
.should.eventually.not.equal('');
When('the user clicks the settings button', function () {
return this.app.client.$('#appSettingsButton').then((element) => element.click());
});

When('the user selects {string} from the Default Gherkin Dialect drop-down menu', function (dialect) {
return this.app.client.$('#dialectSelection').then((element) => element.selectByVisibleText(dialect));
});

Then(/the report (?:will be|is) (displayed|hidden)/, { timeout: 60000 }, async function (reportStatus) {
const displayed = reportStatus === 'displayed';
const outputElem = await this.app.client.$('#output');
if (displayed) {
const outputText = await outputElem.getText();
expect(outputText).to.not.equal('');
}
const isDisplayed = await outputElem.isDisplayed();
expect(isDisplayed).to.equal(displayed);
});

Then(/the settings view will be (displayed|hidden)/, function (settingsStatus) {
const displayed = settingsStatus === 'displayed';
return this.app.client.$('#appSettings')
.then((settingsElem) => settingsElem.isDisplayed().should.eventually.equal(displayed));
});

Then('the report will be saved in a file called {string}', function (fileName) {
Expand All @@ -103,15 +122,15 @@ Then('the report will be saved in a file called {string}', function (fileName) {
});

Then(/^the report name on the sidebar (?:is|will be) '(.+)'$/, function (reportTitle) {
return this.app.client.getText('#sidenavTitle').then((reportText) => {
expect(reportText).to.eql(reportTitle);
});
return this.app.client.$('#sidenavTitle')
.then((sideNavElem) => sideNavElem.getText())
.then((text) => expect(text).to.equal(reportTitle));
});

Then(/^the project title on the sidebar (?:is|will be) '(\w+)'$/, function (projectTitle) {
return this.app.client.getText('#headerTitle').then((reportText) => {
expect(reportText).to.eql(projectTitle);
});
return this.app.client.$('#headerTitle')
.then((titleElem) => titleElem.getText())
.then((reportText) => expect(reportText).to.eql(projectTitle));
});

Then(/^the report will contain (\d+) features?$/, function (featureCount) {
Expand All @@ -120,10 +139,10 @@ Then(/^the report will contain (\d+) features?$/, function (featureCount) {
});
});

Then(/^the report (?:will contain|contains) (\d+) scenarios?$/, function (scenarioCount) {
return this.app.client.$$('.feature-wrapper').then((features) => this.app.client.$$('.scenario-divider').then((scenarios) => {
expect(scenarios.length).to.eql(scenarioCount - features.length);
}));
Then(/^the report (?:will contain|contains) (\d+) scenarios?$/, async function (scenarioCount) {
const features = await this.app.client.$$('.feature-wrapper');
const scenarios = await this.app.client.$$('.scenario-body');
expect(scenarios.length).to.eql(scenarioCount + features.length);
});

After({ timeout: 119 * 1000 }, function () {
Expand Down
Loading

0 comments on commit a503f3d

Please sign in to comment.