diff --git a/cypress/integration/common/steps.js b/cypress/integration/common/steps.js index 493c54e38..c51c863d1 100644 --- a/cypress/integration/common/steps.js +++ b/cypress/integration/common/steps.js @@ -5,9 +5,12 @@ import { } from "cypress-cucumber-preprocessor/steps"; import helpers from "../../support/helpers"; import { VERSION } from '../../constants/terms-and-conditions-version.js' +import locales from '../../../webapp/locales' +import orderBy from 'lodash/orderBy' /* global cy */ +const languages = orderBy(locales, 'name') let lastPost = {}; let loginCredentials = { @@ -245,6 +248,12 @@ Then("I select a category", () => { .click(); }); +When("I choose {string} as the language for the post", (languageCode) => { + cy.get('.ds-flex-item > .ds-form-item .ds-select ') + .click().get('.ds-select-option') + .eq(languages.findIndex(l => l.code === languageCode)).click() +}) + Then("the post shows up on the landing page at position {int}", index => { cy.openPage("landing"); const selector = `.post-card:nth-child(${index}) > .ds-card-content`; @@ -536,4 +545,4 @@ Then("I see only one post with the title {string}", title => { .find(".post-link") .should("have.length", 1); cy.get(".main-container").contains(".post-link", title); -}); \ No newline at end of file +}); diff --git a/cypress/integration/notifications/Mentions.feature b/cypress/integration/notifications/Mentions.feature index 7523e3d05..ef2694abc 100644 --- a/cypress/integration/notifications/Mentions.feature +++ b/cypress/integration/notifications/Mentions.feature @@ -20,6 +20,7 @@ Feature: Notification for a mention """ And mention "@matt-rider" in the text And I select a category + And I choose "en" as the language for the post And I click on "Save" When I log out And I log in with the following credentials: diff --git a/cypress/integration/post/WritePost.feature b/cypress/integration/post/WritePost.feature index 461766532..0d74606ad 100644 --- a/cypress/integration/post/WritePost.feature +++ b/cypress/integration/post/WritePost.feature @@ -17,7 +17,8 @@ Feature: Create a post Human Connection is a free and open-source social network for active citizenship. """ - Then I select a category + And I select a category + And I choose "en" as the language for the post And I click on "Save" Then I get redirected to ".../my-first-post" And the post was saved successfully diff --git a/webapp/components/CategoriesSelect/CategoriesSelect.spec.js b/webapp/components/CategoriesSelect/CategoriesSelect.spec.js index 199dacb74..56534c6ad 100644 --- a/webapp/components/CategoriesSelect/CategoriesSelect.spec.js +++ b/webapp/components/CategoriesSelect/CategoriesSelect.spec.js @@ -8,10 +8,12 @@ localVue.use(Styleguide) describe('CategoriesSelect.vue', () => { let wrapper let mocks + let provide let democracyAndPolitics let environmentAndNature let consumptionAndSustainablity + const propsData = { model: 'categoryIds' } const categories = [ { id: 'cat9', @@ -35,6 +37,11 @@ describe('CategoriesSelect.vue', () => { }, ] beforeEach(() => { + provide = { + $parentForm: { + update: jest.fn(), + }, + } mocks = { $t: jest.fn(), } @@ -42,7 +49,7 @@ describe('CategoriesSelect.vue', () => { describe('shallowMount', () => { const Wrapper = () => { - return mount(CategoriesSelect, { mocks, localVue }) + return mount(CategoriesSelect, { propsData, mocks, localVue, provide }) } beforeEach(() => { @@ -60,8 +67,8 @@ describe('CategoriesSelect.vue', () => { expect(wrapper.vm.selectedCategoryIds).toEqual([categories[0].id]) }) - it('emits an updateCategories event when the selectedCategoryIds changes', () => { - expect(wrapper.emitted().updateCategories[0][0]).toEqual([categories[0].id]) + it('calls $parent.update with selected category ids', () => { + expect(provide.$parentForm.update).toHaveBeenCalledWith('categoryIds', ['cat9']) }) it('removes categories when clicked a second time', () => { diff --git a/webapp/components/CategoriesSelect/CategoriesSelect.vue b/webapp/components/CategoriesSelect/CategoriesSelect.vue index cbe46b890..9b54b3283 100644 --- a/webapp/components/CategoriesSelect/CategoriesSelect.vue +++ b/webapp/components/CategoriesSelect/CategoriesSelect.vue @@ -28,16 +28,23 @@