From 9a0e8c1d1c76827199344d05681507e0f693abf7 Mon Sep 17 00:00:00 2001 From: Brian Pilati Date: Tue, 15 Aug 2023 11:38:48 -0600 Subject: [PATCH 1/3] Added additional tests for the branded header --- .../branded-header/component-test.ts | 27 +++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/tests/integration/components/branded-header/component-test.ts b/tests/integration/components/branded-header/component-test.ts index 56fa054ebb4..fab059978f5 100644 --- a/tests/integration/components/branded-header/component-test.ts +++ b/tests/integration/components/branded-header/component-test.ts @@ -26,28 +26,51 @@ module('Integration | Component | branded-header', hooks => { @showHelp=true @searchPlaceholder={{this.searchPlaceholder}} as |branded-header| - > + > + {{#branded-header.lead}} +
+ This is the lead +
+ {{/branded-header.lead}} + {{#branded-header.row}} +
+ This is the row +
+ {{/branded-header.row}} + `); // Then the header container is verified const headerContainer = this.element.querySelector('[data-test-header-container]'); assert.dom(headerContainer).exists(); - // Then the header container is verified + // And the brand logo container is verified assert.dom(this.element.querySelector('[data-test-brand-logo]')).hasAttribute('aria-label', 'OSF Preprints'); + // And the perform search button is verified // eslint-disable-next-line max-len assert.dom(this.element.querySelector('[data-test-perform-search-button]')).hasAttribute('aria-label', 'Perform search'); assert.dom(this.element.querySelector('[data-test-perform-search-button]')).hasAttribute('type', 'button'); + // And the search icon is verified // eslint-disable-next-line max-len assert.dom(this.element.querySelector('[data-test-search-icon]')).hasAttribute('data-icon', 'search'); + // And the search box is verified // eslint-disable-next-line max-len assert.dom(this.element.querySelector('[data-test-search-box]')).hasAttribute('placeholder', 'preprints.header.search_placeholder'); + // And the search help button is verified // eslint-disable-next-line max-len assert.dom(this.element.querySelector('[data-test-search-help-button]')).hasAttribute('aria-label', 'Search help'); assert.dom(this.element.querySelector('[data-test-search-help-button]')).hasAttribute('type', 'button'); + + // And the lead yield is verified + // eslint-disable-next-line max-len + assert.dom(this.element.querySelector('[data-test-lead-yield]')).hasText('This is the lead', 'The lead in yielded correctly'); + + // And the row yield is verified + // eslint-disable-next-line max-len + assert.dom(this.element.querySelector('[data-test-row-yield]')).hasText('This is the row', 'The lead in yielded correctly'); }); }); From 768a9e15786c97062b0e1f35ebab8e83e4a46f09 Mon Sep 17 00:00:00 2001 From: Brian Pilati Date: Tue, 15 Aug 2023 11:55:23 -0600 Subject: [PATCH 2/3] Added Branded footer tests --- .../-components/branded-footer/component.ts | 2 +- .../-components/branded-footer/template.hbs | 2 +- .../preprints/branded-footer-test.ts | 45 +++++++++++++++++++ 3 files changed, 47 insertions(+), 2 deletions(-) create mode 100644 tests/acceptance/preprints/branded-footer-test.ts diff --git a/app/preprints/-components/branded-footer/component.ts b/app/preprints/-components/branded-footer/component.ts index e2119aa03eb..97f70031bcd 100644 --- a/app/preprints/-components/branded-footer/component.ts +++ b/app/preprints/-components/branded-footer/component.ts @@ -8,6 +8,6 @@ export default class BrandedFooter extends Component { footerLinks = this.args.footerLinks; get hasFooters(): boolean { - return this.footerLinks !== ''; + return this.footerLinks !== '' && this.footerLinks !== undefined; } } diff --git a/app/preprints/-components/branded-footer/template.hbs b/app/preprints/-components/branded-footer/template.hbs index ffee3b5b5a9..b431f780d88 100644 --- a/app/preprints/-components/branded-footer/template.hbs +++ b/app/preprints/-components/branded-footer/template.hbs @@ -1,5 +1,5 @@ {{#if this.hasFooters}} -
+
{{html-safe this.footerLinks}}
{{/if}} \ No newline at end of file diff --git a/tests/acceptance/preprints/branded-footer-test.ts b/tests/acceptance/preprints/branded-footer-test.ts new file mode 100644 index 00000000000..d5319026146 --- /dev/null +++ b/tests/acceptance/preprints/branded-footer-test.ts @@ -0,0 +1,45 @@ +import { render } from '@ember/test-helpers'; +import { hbs } from 'ember-cli-htmlbars'; +import { setupRenderingTest } from 'ember-qunit'; +import { module, test } from 'qunit'; + +module('Acceptance | preprints | branded-footer', hooks => { + setupRenderingTest(hooks); + + test('it inserts the footerLink when present', async function(assert) { + // Given no list is provided + // When the component is rendered + await render(hbs` + + + `); + + // Then the footer links are verified + assert.dom('[data-test-footer-links]').hasText('these are the footer links', 'The footer links are present'); + }); + + test('it does not insert the footerLink when undefined', async function(assert) { + // Given no list is provided + // When the component is rendered + await render(hbs``); + + // Then the footer links are verified + assert.dom('[data-test-footer-links]').doesNotExist('The footer links are not present'); + }); + + test('it does no insert the footerLink when it an empty string', async function(assert) { + // Given no list is provided + // When the component is rendered + await render(hbs` + + + `); + + // Then the footer links are verified + assert.dom('[data-test-footer-links]').doesNotExist('The footer links are not present'); + }); +}); From 2a7b50d7d2348282fb4f4224e6ff34d3bf8b5ab7 Mon Sep 17 00:00:00 2001 From: Brian Pilati Date: Tue, 15 Aug 2023 11:57:27 -0600 Subject: [PATCH 3/3] Pruned an unused providerModel from the branded-header --- .../components/branded-header/component.ts | 20 ++++--------------- .../components/branded-header/template.hbs | 5 ----- 2 files changed, 4 insertions(+), 21 deletions(-) diff --git a/lib/osf-components/addon/components/branded-header/component.ts b/lib/osf-components/addon/components/branded-header/component.ts index 82d03c32182..ef88ea8663d 100644 --- a/lib/osf-components/addon/components/branded-header/component.ts +++ b/lib/osf-components/addon/components/branded-header/component.ts @@ -4,7 +4,6 @@ import { inject as service } from '@ember/service'; import Intl from 'ember-intl/services/intl'; import Media from 'ember-responsive'; -import ProviderModel from 'ember-osf-web/models/provider'; import Analytics from 'ember-osf-web/services/analytics'; import { tracked } from '@glimmer/tracking'; import { requiredAction } from 'ember-osf-web/decorators/component'; @@ -23,7 +22,6 @@ export default class BrandedHeader extends Component { @requiredAction onSearch!: (value: string) => void; @tracked showingHelp = false; - providerModel?: ProviderModel; notBranded = true; localClassNameBindings = ['notBranded:Header']; today = new Date(); @@ -43,20 +41,14 @@ export default class BrandedHeader extends Component { : this.intl.t(`${this.args.translationParent}.header.search_placeholder`); } - @computed('providerModel.name', 'args.translationParent') + @computed('args.translationParent') get headerAriaLabel() { - return this.providerModel ? - this.providerModel.name.concat(' ', this.intl.t(`${this.args.translationParent}.header.registrations`)) - : this.intl.t(`${this.args.translationParent}.header.osf_registrations`); + return this.intl.t(`${this.args.translationParent}.header.osf_registrations`); } @action onSubmit() { - if (this.providerModel) { - this.analytics.click('link', `Discover - Search ${this.providerModel.name}`, this.value); - } else { - this.analytics.click('link', 'Discover - Search', this.value); - } + this.analytics.click('link', 'Discover - Search', this.value); this.args.onSearch(this.value); } @@ -68,11 +60,7 @@ export default class BrandedHeader extends Component { @action keyPress(event: KeyboardEvent) { if (event.keyCode !== 13) { - if (this.providerModel) { - this.analytics.track('input', 'onkeyup', `Discover - Search ${this.providerModel.name}`, this.value); - } else { - this.analytics.track('input', 'onkeyup', 'Discover - Search', this.value); - } + this.analytics.track('input', 'onkeyup', 'Discover - Search', this.value); } } } diff --git a/lib/osf-components/addon/components/branded-header/template.hbs b/lib/osf-components/addon/components/branded-header/template.hbs index 64a7fba6e7c..395d29e4157 100644 --- a/lib/osf-components/addon/components/branded-header/template.hbs +++ b/lib/osf-components/addon/components/branded-header/template.hbs @@ -49,11 +49,6 @@ {{/if}}
- {{#if @providerModel.htmlSafeDescription}} -
- {{@providerModel.htmlSafeDescription}} -
- {{/if}}
{{yield (hash row=(element ''))}}