Skip to content

Commit 91801c7

Browse files
committed
feat(header): update header links for unauthenticated users
Refactor header component to include a 'Pricing' link instead of an 'Upgrade' button for unauthenticated users. Introduce a new method to check for link visibility and update the acceptance test to validate
1 parent bc675f0 commit 91801c7

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

tests/acceptance/header-test.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,15 @@ module('Acceptance | header-test', function (hooks) {
1111
setupApplicationTest(hooks);
1212
setupAnimationTest(hooks);
1313

14-
test('header should show sign-in & upgrade button if user is unauthenticated', async function (assert) {
14+
test('header should show sign-in & pricing link if user is unauthenticated', async function (assert) {
1515
testScenario(this.server);
1616

1717
await catalogPage.visit();
1818

1919
assert.true(catalogPage.header.signInButton.isVisible, 'expect sign-in button to be visible');
20-
assert.true(catalogPage.header.upgradeButton.isVisible, 'expect billing status badge to be visible');
21-
await catalogPage.header.upgradeButton.click();
20+
assert.true(catalogPage.header.hasLink('Pricing'), 'expect pricing link to be visible');
2221

22+
await catalogPage.header.clickOnHeaderLink('Pricing');
2323
assert.strictEqual(currentURL(), '/pay', 'expect to be redirected to pay page');
2424
});
2525

tests/pages/components/header.js

+6-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { clickOnText, clickable, fillable, isVisible } from 'ember-cli-page-object';
1+
import { clickOnText, collection, clickable, fillable, isVisible } from 'ember-cli-page-object';
22
import BillingStatusBadge from 'codecrafters-frontend/tests/pages/components/billing-status-badge';
33

44
export default {
@@ -16,8 +16,12 @@ export default {
1616
toggle: clickable('[data-test-feedback-button]', { resetScope: true }),
1717
},
1818

19-
freeWeeksLeftButton: BillingStatusBadge.freeWeeksLeftButton,
19+
hasLink: function (linkText) {
20+
return !!this.links.toArray().find((link) => link.text === linkText);
21+
},
2022

23+
freeWeeksLeftButton: BillingStatusBadge.freeWeeksLeftButton,
24+
links: collection('[data-test-header-link]'),
2125
memberBadge: BillingStatusBadge.memberBadge,
2226

2327
scope: '[data-test-header]',

0 commit comments

Comments
 (0)