fix(ci): stabilize web tests and retain coverage on failure (#5921)

This commit is contained in:
Dave Lane authored and GitHub committed 2026-10-13 23:11:40 -04:00
1 parent bc188c2ce2
commit 75d3897fe2
2 files changed
+23 -10

No files matched your search

+22 -10
View File
@@ -7,11 +7,10 @@ vi.mock('../../src_assets/common/assets/web/Navbar.vue', () => ({
import Troubleshooting from '../../src_assets/common/assets/web/Troubleshooting.vue'
import createSunshineI18n from '../../src_assets/common/assets/web/locale.js'
import pt from '../../src_assets/common/assets/web/public/assets/locale/pt.json'
import ptBR from '../../src_assets/common/assets/web/public/assets/locale/pt_BR.json'
import en from '../../src_assets/common/assets/web/public/assets/locale/en.json'
/**
* @brief Mount troubleshooting with mocked API responses and optional real translations.
* @brief Mount troubleshooting with mocked API responses and an optional Vue I18n instance.
*
* @param {string} platform Host platform.
* @param {string} gamepadDriver Selected gamepad driver.
@@ -77,12 +76,21 @@ afterEach(() => {
describe('virtual input troubleshooting', () => {
it.each([
['pt', pt],
['pt_BR', ptBR],
])('renders Linux permissions and device management with the bundled %s catalog', async (locale, catalog) => {
['valid', false],
['malformed', true],
])('renders Linux permissions and device management with %s translation messages', async (_description, malformed) => {
const catalog = structuredClone(en)
catalog._common.loading = malformed ? 'Loadingchar@@0' : 'Translated loading'
catalog.troubleshooting.driver_release_checking = malformed ? 'Checkingchar@@0' : 'Translated checking'
catalog.troubleshooting.permissions_name = malformed ? 'Permissionchar@@0' : 'Translated permission'
catalog.apps.delete_confirm = 'Delete translated {name}?'
catalog.troubleshooting.troubleshooting = 'Translated troubleshooting'
catalog.troubleshooting.unpair_title = 'Translated unpair'
catalog.troubleshooting.logs = 'Translated logs'
vi.spyOn(console, 'error').mockImplementation(() => {})
vi.stubGlobal('fetch', vi.fn(async url => ({
json: async () => url === './api/configLocale' ? { locale } : catalog,
json: async () => url === './api/configLocale' ? { locale: 'de' } : catalog,
})))
const i18n = await createSunshineI18n()
const wrapper = await mountTroubleshooting('linux', 'none', {}, [
@@ -90,13 +98,17 @@ describe('virtual input troubleshooting', () => {
], i18n)
try {
expect(i18n.global.t('_common.loading')).toBe('Loading...')
expect(i18n.global.t('troubleshooting.driver_release_checking')).toBe('Checking...')
expect(i18n.global.t('_common.loading')).toBe(malformed ? en._common.loading : catalog._common.loading)
expect(i18n.global.t('troubleshooting.driver_release_checking')).toBe(
malformed ? en.troubleshooting.driver_release_checking : catalog.troubleshooting.driver_release_checking
)
expect(i18n.global.t('apps.delete_confirm', { name: 'Moonlight' })).toBe(
catalog.apps.delete_confirm.replace('{name}', 'Moonlight')
)
expect(wrapper.get('h1').text()).toBe(catalog.troubleshooting.troubleshooting)
expect(wrapper.get('.permission-table-shell th').text()).toBe('Permission')
expect(wrapper.get('.permission-table-shell th').text()).toBe(
malformed ? en.troubleshooting.permissions_name : catalog.troubleshooting.permissions_name
)
expect(wrapper.get('#unpair').text()).toBe(catalog.troubleshooting.unpair_title)
expect(wrapper.get('#logs').text()).toBe(catalog.troubleshooting.logs)
expect(wrapper.find('.permission-table-shell tbody tr').exists()).toBe(true)
+1
View File
@@ -11,6 +11,7 @@ export default defineConfig({
test: {
coverage: {
provider: 'v8',
reportOnFailure: true, ///< Preserve CI coverage artifacts after test failures.
reporter: ['text', 'json', 'lcov'],
reportsDirectory: 'coverage',
},