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

test: configure Codecov #658

Merged
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
14 changes: 14 additions & 0 deletions codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
coverage:
status:
patch:
default:
threshold: 5%
project:
default:
threshold: 5%
comment:
layout: 'header, diff, files, footer'
hide_project_coverage: false

codecov:
require_ci_to_pass: false
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@
"//2": "👇 Cypress executes it to perform custom reporting. With this:",
"//3": " - **same filename for local/CI**: the 'mv' command is run in both local & CI, so JSON coverage filename is the same",
"//4": " - **.nycrc* config files avoided:** could be mistakenly used by other tools",
"coverage:report": "nyc report --reporter json --report-dir coverage && mv -f coverage/coverage-final.json coverage/component-testing.json"
"coverage:report": "nyc report --reporter json --report-dir coverage && mv -f coverage/coverage-final.json coverage/component-testing.json",
"validate-codecov-yml": "curl -X POST --data-binary @codecov.yml https://codecov.io/validate"
},
"dependencies": {
"@angular/animations": "18.0.5",
Expand Down
50 changes: 22 additions & 28 deletions src/app/header/tabs/tabs.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,7 @@ export class TabsComponent implements OnDestroy {
) {
afterNextRender(
() => {
this._intersectionObserver = new IntersectionObserver(
this._onIntersectChange.bind(this),
{
root: this._elRef.nativeElement,
threshold: [INTERSECTION_THRESHOLD],
},
)
this._setupIntersectionObserver()
},
{ phase: AfterRenderPhase.Read },
)
Expand Down Expand Up @@ -137,23 +131,28 @@ export class TabsComponent implements OnDestroy {
this._intersectionObserver.observe(this._lastTab.nativeElement)
}

private _onIntersectChange(
entries: ReadonlyArray<IntersectionObserverEntry>,
) {
;(
[
[this._firstTab!, this._prevButtonDisabled],
[this._lastTab!, this._nextButtonDisabled],
] as const
).forEach(([tabElement, signalToUpdate]) => {
const entry = findEntryByTarget(entries, tabElement.nativeElement)
if (entry === undefined) {
return
}
signalToUpdate.set(entry.isIntersecting)
})
private _setupIntersectionObserver() {
this._intersectionObserver = new IntersectionObserver(
(entries) => {
;(
[
[this._firstTab!, this._prevButtonDisabled],
[this._lastTab!, this._nextButtonDisabled],
] as const
).forEach(([tabElement, signalToUpdate]) => {
const entry = entries.find(
(entry) => entry.target === tabElement.nativeElement,
)
if (!entry) return
signalToUpdate.set(entry.isIntersecting)
})
},
{
root: this._elRef.nativeElement,
threshold: [INTERSECTION_THRESHOLD],
},
)
}

protected _scrollABit(scrollDirection: ScrollDirection) {
const tabListContainer = this._tabList()?.nativeElement
/* istanbul ignore next */
Expand Down Expand Up @@ -185,8 +184,3 @@ const INTERSECTION_THRESHOLD = 0.8
type ScrollDirection = typeof DIRECTION_PREVIOUS | typeof DIRECTION_NEXT
const DIRECTION_PREVIOUS = -1
const DIRECTION_NEXT = 1

const findEntryByTarget = (
entries: ReadonlyArray<IntersectionObserverEntry>,
target: Element,
) => entries.find((entry) => entry.target === target)
Loading