Skip to content

Commit

Permalink
refactor: remove flag WEBINARS
Browse files Browse the repository at this point in the history
refactor: more removals

test: fix tests
  • Loading branch information
asadali145 committed Jan 13, 2025
1 parent 602b7dd commit d523dbb
Show file tree
Hide file tree
Showing 8 changed files with 63 additions and 79 deletions.
12 changes: 0 additions & 12 deletions cms/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -855,17 +855,6 @@ def testimonials(self):
"""
return self._get_child_page_of_type(UserTestimonialsPage)

@property
def news_and_events(self):
"""
Gets the news and events section subpage
"""
webinars_enabled = settings.FEATURES.get("WEBINARS", False)
if webinars_enabled:
return None

return self._get_child_page_of_type(NewsAndEventsPage)

@property
def upcoming_courseware(self):
"""
Expand Down Expand Up @@ -909,7 +898,6 @@ def get_context(self, request, *args, **kwargs): # noqa: ARG002
"image_carousel_section": self.image_carousel_section,
"inquiry_section": self.inquiry_section,
"learning_experience": self.learning_experience,
"news_and_events": self.news_and_events,
"testimonials": self.testimonials,
"upcoming_courseware": self.upcoming_courseware,
}
Expand Down
21 changes: 0 additions & 21 deletions cms/models_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -351,27 +351,6 @@ def test_home_page_testimonials():
assert testimonial.value.get("quote") == "quote"


def test_home_page_news_and_events():
"""
NewsAndEvents subpage should provide expected values
"""
home_page = HomePageFactory.create()
assert not home_page.news_and_events

del home_page.child_pages

news_and_events_page = create_news_and_events(parent=home_page)
assert home_page.news_and_events == news_and_events_page
assert news_and_events_page.heading == "heading"
for count, news_and_events in enumerate(news_and_events_page.items):
assert news_and_events.value.get("content_type") == f"content_type-{count}"
assert news_and_events.value.get("title") == f"title-{count}"
assert news_and_events.value.get("image").title == f"image-{count}"
assert news_and_events.value.get("content") == f"content-{count}"
assert news_and_events.value.get("call_to_action") == f"call_to_action-{count}"
assert news_and_events.value.get("action_url") == f"action_url-{count}"


def test_home_page_inquiry_section():
"""
inquiry_section property should return expected values
Expand Down
3 changes: 0 additions & 3 deletions cms/templates/home_page.html
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,6 @@
{% if testimonials %}
{% include "partials/testimonial-carousel.html" with page=testimonials %}
{% endif %}
{% if news_and_events %}
{% include "partials/news-and-events-carousel.html" with page=news_and_events %}
{% endif %}
{% if inquiry_section %}
{% include "partials/for-teams.html" with page=inquiry_section %}
{% endif %}
Expand Down
1 change: 0 additions & 1 deletion mitxpro/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -599,7 +599,6 @@ def get_js_settings(request: HttpRequest):
},
"digital_credentials": settings.FEATURES.get("DIGITAL_CREDENTIALS", False),
"digital_credentials_supported_runs": settings.DIGITAL_CREDENTIALS_SUPPORTED_RUNS,
"webinars": settings.FEATURES.get("WEBINARS", False),
"is_tax_applicable": is_tax_applicable(request),
"enable_enterprise": settings.FEATURES.get("ENABLE_ENTERPRISE", False),
"posthog_api_token": settings.POSTHOG_PROJECT_API_KEY,
Expand Down
2 changes: 0 additions & 2 deletions mitxpro/utils_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -471,7 +471,6 @@ def test_get_js_settings(settings, rf, user, mocker):
}
settings.FEATURES["DIGITAL_CREDENTIALS"] = True
settings.DIGITAL_CREDENTIALS_SUPPORTED_RUNS = "test_run1,test_run2"
settings.FEATURES["WEBINARS"] = False
settings.FEATURES["ENABLE_ENTERPRISE"] = False
mocker.patch("ecommerce.api.is_tax_applicable", return_value=False)

Expand All @@ -491,7 +490,6 @@ def test_get_js_settings(settings, rf, user, mocker):
"zendesk_config": {"help_widget_enabled": False, "help_widget_key": "fake_key"},
"digital_credentials": settings.FEATURES.get("DIGITAL_CREDENTIALS", False),
"digital_credentials_supported_runs": settings.DIGITAL_CREDENTIALS_SUPPORTED_RUNS,
"webinars": settings.FEATURES.get("WEBINARS", False),
"is_tax_applicable": is_tax_applicable(request),
"enable_enterprise": settings.FEATURES.get("ENABLE_ENTERPRISE", False),
"posthog_api_token": settings.POSTHOG_PROJECT_API_KEY,
Expand Down
20 changes: 9 additions & 11 deletions static/js/components/TopAppBar.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,17 +74,15 @@ const TopAppBar = ({
</a>
</li>
) : null}
{SETTINGS.webinars ? (
<li>
<a
href={routes.webinars}
className="webinar-link"
aria-label="webinars"
>
Webinars
</a>
</li>
) : null}
<li>
<a
href={routes.webinars}
className="webinar-link"
aria-label="webinars"
>
Webinars
</a>
</li>
<li>
<a href={routes.blog} className="blog-link" aria-label="blog">
Blog
Expand Down
82 changes: 54 additions & 28 deletions static/js/components/TopAppBar_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,34 +112,60 @@ describe("TopAppBar component", () => {
.exists(),
);
});
[true, false].forEach((courseDropdown) => {
it("has a CatalogMenu component", () => {
assert.isOk(
shallow(
<TopAppBar
currentUser={user}
location={null}
errorPageHeader={null}
courseTopics={courseTopics}
/>,
)
.find("CatalogMenu")
.exists(),
);
assert.isNotOk(
shallow(
<TopAppBar
currentUser={user}
location={null}
errorPageHeader={null}
courseTopics={courseTopics}
/>,
)
.find("a")
.at(1)
.exists(),
);
});
it("has a CatalogMenu component", () => {
assert.isOk(
shallow(
<TopAppBar
currentUser={user}
location={null}
errorPageHeader={null}
courseTopics={courseTopics}
/>,
)
.find("CatalogMenu")
.exists(),
);
assert.isNotOk(
shallow(
<TopAppBar
currentUser={user}
location={null}
errorPageHeader={null}
courseTopics={courseTopics}
/>,
)
.find("a")
.at(1)
.exists(),
);
assert.equal(
shallow(
<TopAppBar
currentUser={user}
location={null}
errorPageHeader={null}
courseTopics={courseTopics}
/>,
)
.find("a")
.at(2)
.prop("href"),
routes.webinars,
);
assert.equal(
shallow(
<TopAppBar
currentUser={user}
location={null}
errorPageHeader={null}
courseTopics={courseTopics}
/>,
)
.find("a")
.at(3)
.prop("href"),
routes.blog,
);
});

it("does have a button to collapse the menu", () => {
Expand Down
1 change: 0 additions & 1 deletion static/js/flow/declarations.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ declare type Settings = {
},
digital_credentials: boolean,
digital_credentials_supported_runs: Array<string>,
webinars: boolean,
is_tax_applicable: boolean,
enable_enterprise: boolean,
posthog_api_token: ?string,
Expand Down

0 comments on commit d523dbb

Please sign in to comment.