From ee7d5a841eeb46be980ced24b1dd8ef5850ade0a Mon Sep 17 00:00:00 2001 From: Csaba Tuncsik Date: Fri, 14 Apr 2023 13:17:20 +0200 Subject: [PATCH] test(editor): Set 'data-test-id' in unit tests, so they match with Cypress (#5976) --- packages/editor-ui/src/__tests__/setup.ts | 3 +++ .../src/components/ExecutionFilter.vue | 24 +++++++++---------- .../src/components/ExecutionsList.vue | 20 ++++++++-------- .../src/components/__tests__/SSOLogin.test.ts | 2 +- packages/editor-ui/src/views/SettingsSso.vue | 8 +++---- .../src/views/__tests__/AuthView.test.ts | 2 +- 6 files changed, 31 insertions(+), 28 deletions(-) diff --git a/packages/editor-ui/src/__tests__/setup.ts b/packages/editor-ui/src/__tests__/setup.ts index 350dbc992..28fef7c5d 100644 --- a/packages/editor-ui/src/__tests__/setup.ts +++ b/packages/editor-ui/src/__tests__/setup.ts @@ -1,8 +1,11 @@ import '@testing-library/jest-dom'; +import { configure } from '@testing-library/vue'; import Vue from 'vue'; import '../plugins'; import { I18nPlugin } from '@/plugins/i18n'; +configure({ testIdAttribute: 'data-test-id' }); + Vue.config.productionTip = false; Vue.config.devtools = false; diff --git a/packages/editor-ui/src/components/ExecutionFilter.vue b/packages/editor-ui/src/components/ExecutionFilter.vue index 2b0e0dd87..371a5e43f 100644 --- a/packages/editor-ui/src/components/ExecutionFilter.vue +++ b/packages/editor-ui/src/components/ExecutionFilter.vue @@ -141,19 +141,19 @@ onBeforeMount(() => { type="tertiary" size="medium" :active="!!countSelectedFilterProps" - data-testid="executions-filter-button" + data-test-id="executions-filter-button" > {{ countSelectedFilterProps }} {{ $locale.baseText('executionsList.filters') }} -
+
@@ -263,7 +263,7 @@ onBeforeMount(() => { {{ $locale.baseText('executionsFilter.customData.inputTooltip.link') }} @@ -278,7 +278,7 @@ onBeforeMount(() => { :placeholder="$locale.baseText('executionsFilter.savedDataKeyPlaceholder')" :value="filter.metadata[0]?.key" @input="onFilterMetaChange(0, 'key', $event)" - data-testid="execution-filter-saved-data-key-input" + data-test-id="execution-filter-saved-data-key-input" />
@@ -314,7 +314,7 @@ onBeforeMount(() => { @click="onFilterReset" size="large" text - data-testid="executions-filter-reset-button" + data-test-id="executions-filter-reset-button" > {{ $locale.baseText('executionsFilter.reset') }} diff --git a/packages/editor-ui/src/components/ExecutionsList.vue b/packages/editor-ui/src/components/ExecutionsList.vue index 992a0f16b..7fb081d31 100644 --- a/packages/editor-ui/src/components/ExecutionsList.vue +++ b/packages/editor-ui/src/components/ExecutionsList.vue @@ -8,7 +8,7 @@ class="mr-xl" v-model="autoRefresh" @change="handleAutoRefreshToggle" - data-testid="execution-auto-refresh-checkbox" + data-test-id="execution-auto-refresh-checkbox" > {{ $locale.baseText('executionsList.autoRefresh') }} @@ -27,7 +27,7 @@ " :value="allExistingSelected" @change="handleCheckAllExistingChange" - data-testid="select-all-executions-checkbox" + data-test-id="select-all-executions-checkbox" /> @@ -39,7 +39,7 @@ @change="handleCheckAllVisibleChange" :disabled="finishedExecutionsCount < 1" label="" - data-testid="select-visible-executions-checkbox" + data-test-id="select-visible-executions-checkbox" /> @@ -64,7 +64,7 @@ :value="selectedItems[execution.id] || allExistingSelected" @change="handleCheckboxChanged(execution.id)" label="" - data-testid="select-execution-checkbox" + data-test-id="select-execution-checkbox" />
{{ $locale.baseText('executionsList.name') }} @@ -212,7 +212,7 @@
{{ $locale.baseText('executionsList.empty') }}
@@ -228,17 +228,17 @@ :label="$locale.baseText('executionsList.loadMore')" @click="loadMore()" :loading="isDataLoading" - data-testid="load-more-button" + data-test-id="load-more-button" /> -
+
{{ $locale.baseText('executionsList.loadedAll') }}
{{ @@ -252,13 +252,13 @@ :label="$locale.baseText('generic.delete')" type="tertiary" @click="handleDeleteSelected" - data-testid="delete-selected-button" + data-test-id="delete-selected-button" />
diff --git a/packages/editor-ui/src/components/__tests__/SSOLogin.test.ts b/packages/editor-ui/src/components/__tests__/SSOLogin.test.ts index fd09c860e..3c168c521 100644 --- a/packages/editor-ui/src/components/__tests__/SSOLogin.test.ts +++ b/packages/editor-ui/src/components/__tests__/SSOLogin.test.ts @@ -19,7 +19,7 @@ const renderComponent = (renderOptions: Parameters[1] = {}) => pinia, stubs: { 'n8n-button': { - template: '', + template: '', }, }, }, diff --git a/packages/editor-ui/src/views/SettingsSso.vue b/packages/editor-ui/src/views/SettingsSso.vue index cd58958f3..ade350455 100644 --- a/packages/editor-ui/src/views/SettingsSso.vue +++ b/packages/editor-ui/src/views/SettingsSso.vue @@ -112,7 +112,7 @@ onBeforeMount(async () => { -
+
{ :disabled="!ssoSettingsSaved" type="tertiary" @click="onTest" - data-testid="sso-test" + data-test-id="sso-test" > {{ locale.baseText('settings.sso.settings.test') }} - + {{ locale.baseText('settings.sso.settings.save') }}
[1] = {}) => pinia: createTestingPinia(), stubs: { SSOLogin: { - template: '
', + template: '
', }, }, },