fix: fix log streaming e2e race condition

This commit is contained in:
Alex Grozav 2023-07-26 16:46:10 +03:00
parent 4f87d2d533
commit dab3d3a400
5 changed files with 14 additions and 12 deletions

View file

@ -46,6 +46,7 @@ describe('Log Streaming Settings', () => {
it('should create a destination and delete it', () => { it('should create a destination and delete it', () => {
cy.enableFeature('logStreaming'); cy.enableFeature('logStreaming');
cy.visit('/settings/log-streaming'); cy.visit('/settings/log-streaming');
cy.wait(1000); // Race condition with getDestinationDataFromBackend()
settingsLogStreamingPage.actions.clickAddFirstDestination(); settingsLogStreamingPage.actions.clickAddFirstDestination();
cy.wait(100); cy.wait(100);
settingsLogStreamingPage.getters.getDestinationModal().should('be.visible'); settingsLogStreamingPage.getters.getDestinationModal().should('be.visible');
@ -73,6 +74,7 @@ describe('Log Streaming Settings', () => {
it('should create a destination and delete it via card actions', () => { it('should create a destination and delete it via card actions', () => {
cy.enableFeature('logStreaming'); cy.enableFeature('logStreaming');
cy.visit('/settings/log-streaming'); cy.visit('/settings/log-streaming');
cy.wait(1000); // Race condition with getDestinationDataFromBackend()
settingsLogStreamingPage.actions.clickAddFirstDestination(); settingsLogStreamingPage.actions.clickAddFirstDestination();
cy.wait(100); cy.wait(100);
settingsLogStreamingPage.getters.getDestinationModal().should('be.visible'); settingsLogStreamingPage.getters.getDestinationModal().should('be.visible');

View file

@ -189,7 +189,7 @@ import {
defaultMessageEventBusDestinationSentryOptions, defaultMessageEventBusDestinationSentryOptions,
} from 'n8n-workflow'; } from 'n8n-workflow';
import type { PropType } from 'vue'; import type { PropType } from 'vue';
import { defineComponent, nextTick } from 'vue'; import { defineComponent } from 'vue';
import { LOG_STREAM_MODAL_KEY, MODAL_CONFIRM } from '@/constants'; import { LOG_STREAM_MODAL_KEY, MODAL_CONFIRM } from '@/constants';
import Modal from '@/components/Modal.vue'; import Modal from '@/components/Modal.vue';
import { useMessage } from '@/composables'; import { useMessage } from '@/composables';
@ -378,9 +378,7 @@ export default defineComponent({
if (newDestination) { if (newDestination) {
this.headerLabel = newDestination?.label ?? this.headerLabel; this.headerLabel = newDestination?.label ?? this.headerLabel;
void nextTick(() => { this.setupNode(newDestination);
this.setupNode(newDestination);
});
} }
}, },
valueChanged(parameterData: IUpdateInformation) { valueChanged(parameterData: IUpdateInformation) {

View file

@ -155,12 +155,11 @@ export default defineComponent({
} else if (keyboardEvent.key === 'Enter' && filter.value.length === 0) { } else if (keyboardEvent.key === 'Enter' && filter.value.length === 0) {
preventUpdate.value = true; preventUpdate.value = true;
// Disable blur event due to element-plus handler changes emit('blur');
// emit('blur');
// if (typeof selectRef.value?.blur === 'function') {
// if (typeof selectRef.value?.blur === 'function') { selectRef.value.blur();
// selectRef.value.blur(); }
// }
} }
}); });
} }

View file

@ -67,7 +67,7 @@ export const useLogStreamingStore = defineStore('logStreaming', {
state.items[destination.id].destination = destination; state.items[destination.id].destination = destination;
} }
// to trigger refresh // to trigger refresh
state.items = deepCopy(state.items); state.items = { ...state.items };
}); });
} }
}, },
@ -162,6 +162,8 @@ export const useLogStreamingStore = defineStore('logStreaming', {
delete this.items[id]; delete this.items[id];
}, },
clearDestinationItemTrees() { clearDestinationItemTrees() {
console.log('clearing destinations');
this.items = {} as DestinationSettingsStore; this.items = {} as DestinationSettingsStore;
}, },
setSelectionAndBuildItems(destination: MessageEventBusDestinationOptions) { setSelectionAndBuildItems(destination: MessageEventBusDestinationOptions) {

View file

@ -73,7 +73,7 @@
</template> </template>
<script lang="ts"> <script lang="ts">
import { defineComponent } from 'vue'; import { defineComponent, nextTick } from 'vue';
import { mapStores } from 'pinia'; import { mapStores } from 'pinia';
import { v4 as uuid } from 'uuid'; import { v4 as uuid } from 'uuid';
import { useWorkflowsStore } from '../stores/workflows.store'; import { useWorkflowsStore } from '../stores/workflows.store';
@ -197,6 +197,7 @@ export default defineComponent({
const newDestination = deepCopy(defaultMessageEventBusDestinationOptions); const newDestination = deepCopy(defaultMessageEventBusDestinationOptions);
newDestination.id = uuid(); newDestination.id = uuid();
this.logStreamingStore.addDestination(newDestination); this.logStreamingStore.addDestination(newDestination);
await nextTick();
this.uiStore.openModalWithData({ this.uiStore.openModalWithData({
name: LOG_STREAM_MODAL_KEY, name: LOG_STREAM_MODAL_KEY,
data: { data: {