Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: update social links #1295

Merged
merged 4 commits into from
Jan 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file removed base-theme/assets/images/LinkedIn.png
Binary file not shown.
Binary file removed base-theme/assets/images/Twitter.png
Binary file not shown.
Binary file added base-theme/assets/images/linkedin-black.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions base-theme/layouts/partials/footer-v2-social-icons.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
</div>
<div>
<a href="https://twitter.com/MITOCW" target="_blank">
<img class="footer-social-icon" src="{{ partial "get_asset_webpack_url.html" "images/Twitter.png"}}" alt="twitter"/>
<img class="footer-social-icon" src="{{ partial "get_asset_webpack_url.html" "images/x-formerly-twitter-black.png"}}" alt="x (formerly twitter)"/>
</a>
</div>
<div>
Expand All @@ -21,7 +21,7 @@
</div>
<div>
<a href="https://www.linkedin.com/company/mit-opencourseware/" target="_blank">
<img class="footer-social-icon" src="{{ partial "get_asset_webpack_url.html" "images/LinkedIn.png"}}" alt="LinkedIn"/>
<img class="footer-social-icon" src="{{ partial "get_asset_webpack_url.html" "images/linkedin-black.png"}}" alt="linkedin"/>
</a>
</div>
</div>
6 changes: 3 additions & 3 deletions base-theme/layouts/partials/footer.html
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@
</li>
<li>
<a class="img-link" href="https://twitter.com/MITOCW" target="_blank">
<img class="footer-social-icon" src="{{ partial "get_asset_webpack_url.html" "images/Twitter.png" }}" alt="twitter" />
<img class="footer-social-icon" src="{{ partial "get_asset_webpack_url.html" "images/x-formerly-twitter-black.png" }}" alt="x (formerly twitter)" />
</a>
</li>
<li>
Expand All @@ -101,8 +101,8 @@
>
<img
class="footer-social-icon"
src="{{ partial "get_asset_webpack_url.html" "images/LinkedIn.png" }}"
alt="LinkedIn"
src="{{ partial "get_asset_webpack_url.html" "images/linkedin-black.png" }}"
alt="linkedin"
/>
</a>
</li>
Expand Down
18 changes: 18 additions & 0 deletions tests-e2e/ocw-ci-test-course/footer.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { test, expect } from "@playwright/test"
import { CoursePage } from "../util"
import { SOCIAL_LINKS } from "../util/constants"

test("Social links exist and open correct social media pages", async ({
page
}) => {
const course = new CoursePage(page, "course")
await course.goto()

for (const [name, url] of SOCIAL_LINKS) {
const link = page
.locator(".footer-main-content")
.getByRole("link", { name, exact: true })
await expect(link).toBeVisible()
await expect(link).toHaveAttribute("href", url)
Copy link
Contributor Author

@HussainTaj-arbisoft HussainTaj-arbisoft Jan 11, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Originally, I simulated a click and ran assertions on the navigation (i.e. open tab's URL). However, these external links can have uncontrollable behaviors.

For instance, I can open the Instagram link locally without being signed in but, in GitHub Action runner, this URL redirects to the login screen.

For that reason, I have now placed an assertion on the href attribute. Feel free to suggest improvements.

}
})
22 changes: 20 additions & 2 deletions tests-e2e/ocw-ci-test-www/homepage.spec.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,27 @@
import { test, expect } from "@playwright/test"
import { siteUrl } from "../util"
import { WwwPage, siteUrl } from "../util"
import { SOCIAL_LINKS } from "../util/constants"

test("Course page have title in <head>", async ({ page }) => {
test("Home page has title in <head>", async ({ page }) => {
await page.goto(siteUrl("www"))
await expect(page).toHaveTitle(
"MIT OpenCourseWare | Free Online Course Materials"
)
})

test("Social links exist and open correct social media pages", async ({
page
}) => {
const www = new WwwPage(page)
await www.goto()

for (const [name, url] of SOCIAL_LINKS) {
for (const location of [".social-icon-row", "#footer-container"]) {
const link = page
.locator(location)
.getByRole("link", { name, exact: true })
await expect(link).toBeVisible()
await expect(link).toHaveAttribute("href", url)
}
}
})
7 changes: 7 additions & 0 deletions tests-e2e/util/constants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export const SOCIAL_LINKS = [
["facebook", /^https:\/\/www.facebook.com\/MITOCW\/?$/],
["instagram", /^https:\/\/www.instagram.com\/mitocw\/?$/],
["x (formerly twitter)", /^https:\/\/twitter.com\/MITOCW\/?$/],
["youtube", /^https:\/\/www.youtube.com\/mitocw\/?$/],
["linkedin", /^https:\/\/www.linkedin.com\/company\/mit-opencourseware\/?$/]
]
2 changes: 1 addition & 1 deletion www/assets/css/home.scss
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ $searchbox-height: 50px;
}

.social-icon-row {
width: 225px;
width: 270px;
}

> div {
Expand Down
5 changes: 4 additions & 1 deletion www/layouts/home.html
Original file line number Diff line number Diff line change
Expand Up @@ -128,11 +128,14 @@ <h2>Your Donation Makes a Difference</h2>
<img class="social-icon" src="/images/social-instagram-blue.svg" alt="instagram" />
</a>
<a class="img-link" href="https://twitter.com/MITOCW" target="_blank">
<img class="social-icon" src="/images/social-twitter-blue.svg" alt="twitter" />
<img class="social-icon" src="/images/social-x-formerly-twitter-blue.svg" alt="x (formerly twitter)" />
</a>
<a class="img-link" href="https://www.youtube.com/mitocw" target="_blank">
<img class="social-icon" src="/images/social-youtube-blue.svg" alt="youtube" />
</a>
<a class="img-link" href="https://www.linkedin.com/company/mit-opencourseware" target="_blank">
<img class="social-icon" src="/images/social-linkedin-blue.svg" alt="linkedin" />
</a>
</div>
</div>
</div>
Expand Down
1 change: 1 addition & 0 deletions www/static/images/social-linkedin-blue.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 0 additions & 1 deletion www/static/images/social-twitter-blue.svg

This file was deleted.

1 change: 1 addition & 0 deletions www/static/images/social-x-formerly-twitter-blue.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.