From ef1f84ee7c5c7158749f7470dce56bbf045e1aae Mon Sep 17 00:00:00 2001 From: Kailash Nadh Date: Tue, 1 Nov 2022 20:59:21 +0530 Subject: [PATCH] Add new `description` field to lists. Closes #925. --- cmd/install.go | 2 ++ frontend/cypress/e2e/lists.cy.js | 20 +++++++++++++++++++ frontend/src/views/Forms.vue | 2 +- frontend/src/views/ListForm.vue | 5 +++++ i18n/ca.json | 1 + i18n/cs-cz.json | 1 + i18n/de.json | 1 + i18n/en.json | 1 + i18n/es.json | 1 + i18n/fi.json | 1 + i18n/fr.json | 1 + i18n/hu.json | 1 + i18n/it.json | 1 + i18n/jp.json | 1 + i18n/ml.json | 1 + i18n/nl.json | 1 + i18n/pl.json | 1 + i18n/pt-BR.json | 1 + i18n/pt.json | 1 + i18n/ro.json | 1 + i18n/ru.json | 1 + i18n/tr.json | 1 + i18n/vi.json | 1 + i18n/zh-CN.json | 1 + i18n/zh-TW.json | 1 + internal/core/lists.go | 4 ++-- internal/migrations/v2.3.0.go | 7 ++++++- models/models.go | 1 + queries.sql | 3 ++- schema.sql | 1 + static/public/static/style.css | 13 +++++++++++- .../public/templates/subscription-form.html | 3 +++ 32 files changed, 76 insertions(+), 6 deletions(-) diff --git a/cmd/install.go b/cmd/install.go index 3056d837e..42883a32c 100644 --- a/cmd/install.go +++ b/cmd/install.go @@ -74,6 +74,7 @@ func install(lastVer string, db *sqlx.DB, fs stuffbin.FileSystem, prompt, idempo models.ListTypePrivate, models.ListOptinSingle, pq.StringArray{"test"}, + "", ); err != nil { lo.Fatalf("error creating list: %v", err) } @@ -83,6 +84,7 @@ func install(lastVer string, db *sqlx.DB, fs stuffbin.FileSystem, prompt, idempo models.ListTypePublic, models.ListOptinDouble, pq.StringArray{"test"}, + "", ); err != nil { lo.Fatalf("error creating list: %v", err) } diff --git a/frontend/cypress/e2e/lists.cy.js b/frontend/cypress/e2e/lists.cy.js index 7a5b3c57a..5e47b6729 100644 --- a/frontend/cypress/e2e/lists.cy.js +++ b/frontend/cypress/e2e/lists.cy.js @@ -51,6 +51,7 @@ describe('Lists', () => { cy.get('select[name=type]').select('public'); cy.get('select[name=optin]').select('double'); cy.get('input[name=tags]').clear().type(`tag${n}{enter}`); + cy.get('textarea[name=description]').clear().type(`desc${n}`); cy.get('[data-cy=btn-save]').click(); cy.wait(100); }); @@ -94,6 +95,7 @@ describe('Lists', () => { cy.get('select[name=type]').select(t); cy.get('select[name=optin]').select(o); cy.get('input[name=tags]').type(`tag${n}{enter}${t}{enter}${o}{enter}`); + cy.get('textarea[name=description]').clear().type(`desc-${t}-${n}`); cy.get('[data-cy=btn-save]').click(); cy.wait(200); @@ -133,4 +135,22 @@ describe('Lists', () => { cy.sortTable('thead th.cy-updated_at', [3, 4, 5, 6]); cy.sortTable('thead th.cy-updated_at', [6, 5, 4, 3]); }); + + it('Opens forms page', () => { + const apiUrl = Cypress.env('apiUrl'); + cy.loginAndVisit(`${apiUrl}/subscription/form`); + cy.get('ul li').its('length').should('eq', 2); + + const cases = [ + { 'name': 'list-public-single-2', 'description': 'desc-public-2' }, + { 'name': 'list-public-double-3', 'description': 'desc-public-3' } + ]; + + cases.forEach((c, n) => { + cy.get('ul li').eq(n).then(($el) => { + cy.wrap($el).get('label').contains(c.name); + cy.wrap($el).get('.description').contains(c.description); + }); + }); + }); }); diff --git a/frontend/src/views/Forms.vue b/frontend/src/views/Forms.vue index b032a6517..c9452feac 100644 --- a/frontend/src/views/Forms.vue +++ b/frontend/src/views/Forms.vue @@ -47,7 +47,7 @@ <p><input type="submit" value="{{ $t('public.sub') }}" /></p> diff --git a/frontend/src/views/ListForm.vue b/frontend/src/views/ListForm.vue index 0a0a912d0..e233b83df 100644 --- a/frontend/src/views/ListForm.vue +++ b/frontend/src/views/ListForm.vue @@ -38,6 +38,11 @@ + + + +