1
+ import { test , expect } from '@playwright/test' ;
2
+
3
+ test . describe ( 'Footer social media buttons' , ( ) => {
4
+ test . beforeEach ( async ( { page } ) => {
5
+ await page . goto ( '/' ) ;
6
+ await page . waitForSelector ( 'button.ch2-btn.ch2-btn-primary' ) ;
7
+ await page . click ( 'button.ch2-btn.ch2-btn-primary' ) ;
8
+ await page . evaluate ( ( ) => {
9
+ window . scrollTo ( 0 , document . body . scrollHeight ) ;
10
+ } ) ;
11
+ } ) ;
12
+
13
+ test ( 'GitHub button should navigate to Kotlin GitHub page' , async ( { page, context } ) => {
14
+ const githubButton = page . getByRole ( 'link' , { name : 'Kotlin on GitHub' } ) ;
15
+ await expect ( githubButton ) . toBeVisible ( ) ;
16
+ const newPagePromise = context . waitForEvent ( 'page' ) ;
17
+ await githubButton . click ( ) ;
18
+ const newPage = await newPagePromise ;
19
+ await newPage . waitForLoadState ( ) ;
20
+ await expect ( newPage . url ( ) ) . toContain ( 'github.com/JetBrains/kotlin' ) ;
21
+ } ) ;
22
+
23
+ test ( 'Twitter/X button should navigate to Kotlin Twitter page' , async ( { page, context } ) => {
24
+ const twitterButton = page . getByRole ( 'link' , { name : 'Kotlin on Twitter' } ) ;
25
+ await expect ( twitterButton ) . toBeVisible ( ) ;
26
+ const newPagePromise = context . waitForEvent ( 'page' ) ;
27
+ await twitterButton . click ( ) ;
28
+ const newPage = await newPagePromise ;
29
+ await newPage . waitForLoadState ( )
30
+ await expect ( newPage . url ( ) ) . toContain ( 'https://x.com/kotlin' ) ;
31
+ } ) ;
32
+
33
+ test ( 'Bluesky button should navigate to Bluesky page' , async ( { page, context } ) => {
34
+ const blueskyButton = page . getByRole ( 'link' , { name : 'Kotlin on Bluesky' } ) ;
35
+ await expect ( blueskyButton ) . toBeVisible ( ) ;
36
+ const newPagePromise = context . waitForEvent ( 'page' ) ;
37
+ await blueskyButton . click ( ) ;
38
+ const newPage = await newPagePromise ;
39
+ await newPage . waitForLoadState ( )
40
+ await expect ( newPage . url ( ) ) . toContain ( 'https://bsky.app/profile/kotlinlang.org' ) ;
41
+ } ) ;
42
+
43
+ test ( 'Slack button should navigate to Kotlin Slack Sign-up page' , async ( { page, context } ) => {
44
+ const slackButton = page . getByRole ( 'link' , { name : 'Kotlin Slack' } ) ;
45
+ await expect ( slackButton ) . toBeVisible ( ) ;
46
+ const newPagePromise = context . waitForEvent ( 'page' ) ;
47
+ await slackButton . click ( ) ;
48
+ const newPage = await newPagePromise ;
49
+ await newPage . waitForLoadState ( )
50
+ await expect ( newPage . url ( ) ) . toContain ( 'https://surveys.jetbrains.com/s3/kotlin-slack-sign-up' ) ;
51
+ } ) ;
52
+
53
+ test ( 'Reddit button should navigate to Kotlin on Reddit' , async ( { page, context } ) => {
54
+ const redditButton = page . getByRole ( 'link' , { name : 'Kotlin on Reddit' } ) ;
55
+ await expect ( redditButton ) . toBeVisible ( ) ;
56
+ const newPagePromise = context . waitForEvent ( 'page' ) ;
57
+ await redditButton . click ( ) ;
58
+ const newPage = await newPagePromise ;
59
+ await newPage . waitForLoadState ( )
60
+ await expect ( newPage . url ( ) ) . toContain ( 'https://www.reddit.com/r/Kotlin/' ) ;
61
+ } ) ;
62
+
63
+ test ( 'Stackoverflow button should navigate to Kotlin on Stackoverflow' , async ( { page, context } ) => {
64
+ const stackoverflowButton = page . getByRole ( 'link' , { name : 'Kotlin on Stack Overflow' } ) ;
65
+ await expect ( stackoverflowButton ) . toBeVisible ( ) ;
66
+ const newPagePromise = context . waitForEvent ( 'page' ) ;
67
+ await stackoverflowButton . click ( ) ;
68
+ const newPage = await newPagePromise ;
69
+ await newPage . waitForLoadState ( )
70
+ await expect ( newPage . url ( ) ) . toContain ( 'https://stackoverflow.com/questions/tagged/kotlin' ) ;
71
+ } ) ;
72
+
73
+ //Without click on YouTube button, because of YouTube Cookies page, but it checks that the button contains the right link.
74
+ test ( 'YouTube button should navigate to Kotlin on YouTube' , async ( { page } ) => {
75
+ const youTubeButton = page . getByRole ( 'link' , { name : ' Kotlin on YouTube' } ) ;
76
+ await expect ( youTubeButton ) . toBeVisible ( ) ;
77
+ const href = await youTubeButton . getAttribute ( 'href' ) ;
78
+ expect ( href ) . toBe ( 'https://www.youtube.com/channel/UCP7uiEZIqci43m22KDl0sNw' )
79
+
80
+ } ) ;
81
+ } ) ;
0 commit comments