feat: add CodeCov to cloud tests (#7154)

* feat: add CodeCov to cloud tests

* Update codecov.yml

* Update codecov.yml

* get cov to 80%

* remove unneeded test
This commit is contained in:
Brendan Wong 2023-08-17 11:30:56 -04:00 committed by GitHub
parent 5e4108fbdc
commit 0feddebcc3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 47 additions and 1 deletions

@ -214,7 +214,6 @@ jobs:
name: Cloud typecheck name: Cloud typecheck
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_TEST_REPORTER_WEBHOOK }} SLACK_WEBHOOK_URL: ${{ secrets.SLACK_TEST_REPORTER_WEBHOOK }}
# TODO(WEB-2537): Setup CodeCOV
cloud-tests: cloud-tests:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
@ -227,6 +226,11 @@ jobs:
restore-keys: ${{ runner.os }}-cloud-jest- restore-keys: ${{ runner.os }}-cloud-jest-
# Only use 1 worker, so the other can be used for the proxy server under test. # Only use 1 worker, so the other can be used for the proxy server under test.
- run: yarn test:cloud --coverage --maxWorkers=1 - run: yarn test:cloud --coverage --maxWorkers=1
- uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}
fail_ci_if_error: false
flags: cloud-tests
pre: pre:
if: ${{ github.ref_name == 'main' || github.ref_name == 'releases/staging' }} if: ${{ github.ref_name == 'main' || github.ref_name == 'releases/staging' }}

@ -28,6 +28,10 @@ flag_management:
target: 50% target: 50%
individual_flags: individual_flags:
- name: unit-tests - name: unit-tests
- name: cloud-tests
statuses:
- type: project
target: 80%
comment: comment:
layout: flags layout: flags

@ -0,0 +1,38 @@
import { MetaTagInjector } from './metaTagInjector'
test('should append meta tag to element', () => {
const element = {
append: jest.fn(),
} as unknown as Element
const property = 'property'
const content = 'content'
const injector = new MetaTagInjector({
title: 'test',
url: 'testUrl',
image: 'testImage',
description: 'testDescription',
})
injector.append(element, property, content)
expect(element.append).toHaveBeenCalledWith(`<meta property="${property}" content="${content}"/>`, { html: true })
injector.element(element)
expect(element.append).toHaveBeenCalledWith(`<meta property="og:title" content="test"/>`, { html: true })
expect(element.append).toHaveBeenCalledWith(`<meta property="og:description" content="testDescription"/>`, {
html: true,
})
expect(element.append).toHaveBeenCalledWith(`<meta property="og:image" content="testImage"/>`, { html: true })
expect(element.append).toHaveBeenCalledWith(`<meta property="og:image:width" content="1200"/>`, { html: true })
expect(element.append).toHaveBeenCalledWith(`<meta property="og:image:height" content="630"/>`, { html: true })
expect(element.append).toHaveBeenCalledWith(`<meta property="og:image:alt" content="test"/>`, { html: true })
expect(element.append).toHaveBeenCalledWith(`<meta property="og:type" content="website"/>`, { html: true })
expect(element.append).toHaveBeenCalledWith(`<meta property="og:url" content="testUrl"/>`, { html: true })
expect(element.append).toHaveBeenCalledWith(`<meta property="twitter:card" content="summary_large_image"/>`, {
html: true,
})
expect(element.append).toHaveBeenCalledWith(`<meta property="twitter:title" content="test"/>`, { html: true })
expect(element.append).toHaveBeenCalledWith(`<meta property="twitter:image" content="testImage"/>`, { html: true })
expect(element.append).toHaveBeenCalledWith(`<meta property="twitter:image:alt" content="test"/>`, { html: true })
expect(element.append).toHaveBeenCalledTimes(13)
})