Skip to content

Commit 7f267fc

Browse files
authored
Merge pull request github#16665 from github/repo-sync
repo sync
2 parents 916dc90 + f4884a3 commit 7f267fc

File tree

4 files changed

+55
-18
lines changed

4 files changed

+55
-18
lines changed

.github/workflows/test.yml

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,15 @@ jobs:
3131
fail-fast: false
3232
matrix:
3333
# The same array lives in test-windows.yml, so make any updates there too.
34-
test-group: [
34+
test-group:
35+
[
3536
content,
3637
graphql,
3738
meta,
3839
rendering,
3940
routing,
4041
unit,
41-
# linting,
42+
linting,
4243
translations,
4344
]
4445
steps:
@@ -47,7 +48,10 @@ jobs:
4748
- name: Check out repo
4849
uses: actions/checkout@ec3a7ce113134d7a93b817d10a8272cb61118579
4950
with:
50-
lfs: true
51+
# Not all test suites need the LFS files. So instead, we opt to
52+
# NOT clone them initially and instead, include them manually
53+
# only for the test groups that we know need the files.
54+
lfs: ${{ matrix.test-group == 'content' }}
5155
# Enables cloning the Early Access repo later with the relevant PAT
5256
persist-credentials: 'false'
5357

@@ -98,23 +102,25 @@ jobs:
98102
mv docs-early-access/data data/early-access
99103
rm -r docs-early-access
100104
105+
# This is necessary when LFS files where cloned but does nothing
106+
# if actions/checkout was run with `lfs:false`.
101107
- name: Checkout LFS objects
102108
run: git lfs checkout
103109

104-
# - name: Gather files changed
105-
# uses: trilom/file-changes-action@a6ca26c14274c33b15e6499323aac178af06ad4b
106-
# id: get_diff_files
107-
# with:
108-
# # So that `steps.get_diff_files.outputs.files` becomes
109-
# # a string like `foo.js path/bar.md`
110-
# output: ' '
110+
- name: Gather files changed
111+
uses: trilom/file-changes-action@a6ca26c14274c33b15e6499323aac178af06ad4b
112+
id: get_diff_files
113+
with:
114+
# So that `steps.get_diff_files.outputs.files` becomes
115+
# a string like `foo.js path/bar.md`
116+
output: ' '
111117

112-
# - name: Insight into changed files
113-
# run: |
118+
- name: Insight into changed files
119+
run: |
114120
115-
# # Must to do this because the list of files can be HUGE. Especially
116-
# # in a repo-sync when there are lots of translation files involved.
117-
# echo "${{ steps.get_diff_files.outputs.files }}" > get_diff_files.txt
121+
# Must to do this because the list of files can be HUGE. Especially
122+
# in a repo-sync when there are lots of translation files involved.
123+
echo "${{ steps.get_diff_files.outputs.files }}" > get_diff_files.txt
118124
119125
- name: Setup node
120126
uses: actions/setup-node@1f8c6b94b26d0feae1e387ca63ccbdc44d27b561
@@ -136,6 +142,6 @@ jobs:
136142

137143
- name: Run tests
138144
env:
139-
# DIFF_FILE: get_diff_files.txt
145+
DIFF_FILE: get_diff_files.txt
140146
CHANGELOG_CACHE_FILE_PATH: tests/fixtures/changelog-feed.json
141147
run: npm test -- tests/${{ matrix.test-group }}/

components/context/MainContext.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ export type MainContextT = {
124124

125125
status: number
126126
fullUrl: string
127+
isDotComAuthenticated: boolean
127128
}
128129

129130
export const getMainContext = (req: any, res: any): MainContextT => {
@@ -189,6 +190,7 @@ export const getMainContext = (req: any, res: any): MainContextT => {
189190
nonEnterpriseDefaultVersion: req.context.nonEnterpriseDefaultVersion,
190191
status: res.statusCode,
191192
fullUrl: req.protocol + '://' + req.get('host') + req.originalUrl,
193+
isDotComAuthenticated: Boolean(req.cookies.dotcom_user),
192194
}
193195
}
194196

components/page-header/Header.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import styles from './Header.module.scss'
1717

1818
export const Header = () => {
1919
const router = useRouter()
20-
const { relativePath, error } = useMainContext()
20+
const { isDotComAuthenticated, relativePath, error } = useMainContext()
2121
const { currentVersion } = useVersion()
2222
const { t } = useTranslation(['header', 'homepage'])
2323
const [isMenuOpen, setIsMenuOpen] = useState(
@@ -26,7 +26,8 @@ export const Header = () => {
2626
const [scroll, setScroll] = useState(false)
2727

2828
const signupCTAVisible =
29-
currentVersion === 'free-pro-team@latest' || currentVersion === 'enterprise-cloud@latest'
29+
!isDotComAuthenticated &&
30+
(currentVersion === 'free-pro-team@latest' || currentVersion === 'enterprise-cloud@latest')
3031

3132
useEffect(() => {
3233
function onScroll() {

tests/rendering/signup-button.js

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import { getDOM } from '../helpers/e2etest.js'
2+
import { describe, expect } from '@jest/globals'
3+
4+
describe('GHEC sign up button', () => {
5+
test('present by default', async () => {
6+
const $ = await getDOM('/en')
7+
expect($('a[href^="https://github.com/signup"]').length).toBeGreaterThan(0)
8+
})
9+
10+
test('present on enterprise-cloud pages', async () => {
11+
const $ = await getDOM('/en/enterprise-cloud@latest')
12+
expect($('a[href^="https://github.com/signup"]').length).toBeGreaterThan(0)
13+
})
14+
15+
test('not present on enterprise-server pages', async () => {
16+
const $ = await getDOM('/en/enterprise-server@latest')
17+
expect($('a[href^="https://github.com/signup"]').length).toBe(0)
18+
})
19+
20+
test('not present if dotcom_user cookie', async () => {
21+
const $ = await getDOM('/en', {
22+
headers: {
23+
cookie: 'dotcom_user=peterbe',
24+
},
25+
})
26+
expect($('a[href^="https://github.com/signup"]').length).toBe(0)
27+
})
28+
})

0 commit comments

Comments
 (0)