-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(vue): Ensure Vue
trackComponents
list matches components with o…
…r without `<>` (#13543) Ensure that the component names listed in the `trackComponent` option match regardless of if they were specified as `<Name>` or `Name`. Add unit and e2e tests for component tracking. --------- Signed-off-by: Kaung Zin Hein <[email protected]>
- Loading branch information
1 parent
facaae4
commit a7d3a9d
Showing
8 changed files
with
178 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
dev-packages/e2e-tests/test-applications/vue-3/src/views/ComponentMainView.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<script setup lang="ts"> | ||
import ComponentOneView from './ComponentOneView.vue'; | ||
import ComponentTwoView from './ComponentTwoView.vue'; | ||
</script> | ||
|
||
<template> | ||
<h1>Demonstrating Component Tracking</h1> | ||
<ComponentOneView /> | ||
<ComponentTwoView /> | ||
</template> |
10 changes: 10 additions & 0 deletions
10
dev-packages/e2e-tests/test-applications/vue-3/src/views/ComponentOneView.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<script setup lang="ts"> | ||
function log() { | ||
console.log('Component One!'); | ||
} | ||
</script> | ||
|
||
<template> | ||
<h1>Component One</h1> | ||
<button id="componentOneBtn" @click="log">Click to Log</button> | ||
</template> |
10 changes: 10 additions & 0 deletions
10
dev-packages/e2e-tests/test-applications/vue-3/src/views/ComponentTwoView.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<script setup lang="ts"> | ||
function log() { | ||
console.log('Component Two!'); | ||
} | ||
</script> | ||
|
||
<template> | ||
<h1>Component One</h1> | ||
<button id="componentTwoBtn" @click="log">Click to Log</button> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import { describe, expect, it } from 'vitest'; | ||
import { findTrackComponent } from '../../src/tracing'; | ||
|
||
describe('findTrackComponent', () => { | ||
describe('when user-defined array contains `<Component>`', () => { | ||
it('returns true if a match is found', () => { | ||
// arrange | ||
const trackComponents = ['<ABC>', '<XYZ>']; | ||
const formattedComponentName = '<XYZ>'; | ||
|
||
// act | ||
const shouldTrack = findTrackComponent(trackComponents, formattedComponentName); | ||
|
||
// assert | ||
expect(shouldTrack).toBe(true); | ||
}); | ||
}); | ||
describe('when user-defined array contains `Component` without the `<>`', () => { | ||
it('returns true if a match is found', () => { | ||
// arrange | ||
const trackComponents = ['ABC', 'XYZ']; | ||
const formattedComponentName = '<XYZ>'; | ||
|
||
// act | ||
const shouldTrack = findTrackComponent(trackComponents, formattedComponentName); | ||
|
||
// assert | ||
expect(shouldTrack).toBe(true); | ||
}); | ||
}); | ||
describe('when the vue file name is include in the formatted component name', () => { | ||
it('returns true if a match is found', () => { | ||
// arrange | ||
const trackComponents = ['ABC', 'XYZ']; | ||
const formattedComponentName = '<XYZ> at XYZ.vue'; | ||
|
||
// act | ||
const shouldTrack = findTrackComponent(trackComponents, formattedComponentName); | ||
|
||
// assert | ||
expect(shouldTrack).toBe(true); | ||
}); | ||
}); | ||
}); |