diff --git a/cypress/e2e/Group.Create.feature b/cypress/e2e/Group.Create.feature new file mode 100644 index 000000000..13b6d0b3a --- /dev/null +++ b/cypress/e2e/Group.Create.feature @@ -0,0 +1,27 @@ +Feature: Create a group + As an logged in user + I would like to create a group + To invite my friends + + Background: + Given the following "users" are in the database: + | slug | email | password | id | name | termsAndConditionsAgreedVersion | + | narrator | narrator@example.org | 1234 | narrator | Nathan Narrator | 0.0.4 | + And I am logged in as "narrator" + And I navigate to page "/groups" + + Scenario: Create a group + When I click on "create group button" + Then I am on page "groups/create" + When I choose "My group " as the name + And I choose "public" as the visibility + And I choose "to invite my friends" as the about + And I choose the following text as description: + """ + This is the group where I want to exchange + my views with my friends. + """ + And I choose "regional" as the action radius + And I click on "save button" + Then I am on page "/groups/.*/my-group" + And the group was saved successfully diff --git a/cypress/support/step_definitions/Group.Create/I_choose_the_following_text_as_description.js b/cypress/support/step_definitions/Group.Create/I_choose_the_following_text_as_description.js new file mode 100644 index 000000000..278cab547 --- /dev/null +++ b/cypress/support/step_definitions/Group.Create/I_choose_the_following_text_as_description.js @@ -0,0 +1,9 @@ +import { defineStep } from '@badeball/cypress-cucumber-preprocessor' + +defineStep('I choose the following text as description:', text => { + cy.task('getValue', 'lastGroup').then(lastGroup => { + lastGroup.description = text.replace('\n', ' ') + cy.task('pushValue', { name: 'lastGroup', value: lastGroup }) + cy.get('.editor .ProseMirror').type(lastGroup.description) + }) +}) diff --git a/cypress/support/step_definitions/Group.Create/I_choose_{string}_as_the_about.js b/cypress/support/step_definitions/Group.Create/I_choose_{string}_as_the_about.js new file mode 100644 index 000000000..7106ad44a --- /dev/null +++ b/cypress/support/step_definitions/Group.Create/I_choose_{string}_as_the_about.js @@ -0,0 +1,9 @@ +import { defineStep } from '@badeball/cypress-cucumber-preprocessor' + +defineStep('I choose {string} as the about', about => { + cy.task('getValue', 'lastGroup').then(lastGroup => { + lastGroup.about = about.replace('\n', ' ') + cy.task('pushValue', { name: 'lastGroup', value: lastGroup }) + cy.get('input[name="about"]').type(lastGroup.about) + }) +}) diff --git a/cypress/support/step_definitions/Group.Create/I_choose_{string}_as_the_action_radius.js b/cypress/support/step_definitions/Group.Create/I_choose_{string}_as_the_action_radius.js new file mode 100644 index 000000000..6d1fd8615 --- /dev/null +++ b/cypress/support/step_definitions/Group.Create/I_choose_{string}_as_the_action_radius.js @@ -0,0 +1,9 @@ +import { defineStep } from '@badeball/cypress-cucumber-preprocessor' + +defineStep('I choose {string} as the action radius', actionRadius => { + cy.task('getValue', 'lastGroup').then(lastGroup => { + lastGroup.actionRadius = actionRadius.replace('\n', ' ') + cy.task('pushValue', { name: 'lastGroup', value: lastGroup }) + cy.get('select[name="actionRadius"]').select(lastGroup.actionRadius) + }) +}) diff --git a/cypress/support/step_definitions/Group.Create/I_choose_{string}_as_the_name.js b/cypress/support/step_definitions/Group.Create/I_choose_{string}_as_the_name.js new file mode 100644 index 000000000..1c5c1b1e8 --- /dev/null +++ b/cypress/support/step_definitions/Group.Create/I_choose_{string}_as_the_name.js @@ -0,0 +1,8 @@ +import { defineStep } from '@badeball/cypress-cucumber-preprocessor' + +defineStep('I choose {string} as the name', name => { + const lastGroup = {} + lastGroup.name = name.replace('\n', ' ') + cy.task('pushValue', { name: 'lastGroup', value: lastGroup }) + cy.get('input[name="name"]').type(lastGroup.name) +}) diff --git a/cypress/support/step_definitions/Group.Create/I_choose_{string}_as_the_visibility.js b/cypress/support/step_definitions/Group.Create/I_choose_{string}_as_the_visibility.js new file mode 100644 index 000000000..ed1a78ac2 --- /dev/null +++ b/cypress/support/step_definitions/Group.Create/I_choose_{string}_as_the_visibility.js @@ -0,0 +1,9 @@ +import { defineStep } from '@badeball/cypress-cucumber-preprocessor' + +defineStep('I choose {string} as the visibility', groupType => { + cy.task('getValue', 'lastGroup').then(lastGroup => { + lastGroup.groupType = groupType.replace('\n', ' ') + cy.task('pushValue', { name: 'lastGroup', value: lastGroup }) + cy.get('select[name="groupType"]').select(lastGroup.groupType) + }) +}) diff --git a/cypress/support/step_definitions/Group.Create/the_group_was_saved_successfully.js b/cypress/support/step_definitions/Group.Create/the_group_was_saved_successfully.js new file mode 100644 index 000000000..591d5ba75 --- /dev/null +++ b/cypress/support/step_definitions/Group.Create/the_group_was_saved_successfully.js @@ -0,0 +1,7 @@ +import { defineStep } from '@badeball/cypress-cucumber-preprocessor' + +defineStep('the group was saved successfully', () => { + cy.task('getValue', 'lastGroup').then(lastGroup => { + cy.get('h3.ds-heading').should('contain', lastGroup.name) + }) +}) diff --git a/cypress/support/step_definitions/common/I_click_on_{string}.js b/cypress/support/step_definitions/common/I_click_on_{string}.js index 799357784..3df19246d 100644 --- a/cypress/support/step_definitions/common/I_click_on_{string}.js +++ b/cypress/support/step_definitions/common/I_click_on_{string}.js @@ -4,6 +4,7 @@ defineStep('I click on {string}', element => { const elementSelectors = { 'submit button': 'button[name=submit]', 'create post button': '.post-add-button', + 'create group button': '.group-add-button', 'save button': 'button[type=submit]', 'the first post': '.post-teaser:first-child', 'comment button': 'button[type=submit]',