Skip to content

Commit bc21f1e

Browse files
authored
Refactor event history routing (#984)
* Refactor event history routing * Remove console.log * Add layout to each page * Remove log * Remove view routes but keep fallback redirect * Update and improve cypress tests * Fix stale data flash by setting loading=true onDestroy of layout of workflow run * Remove console.log * Move clearPreviousEventParameters to layout * Broadcast event view type store * Bump to 2.1.92
1 parent 6079d46 commit bc21f1e

33 files changed

+231
-186
lines changed

cypress/integration/event-history-empty-states.spec.js

+21-11
Original file line numberDiff line numberDiff line change
@@ -23,26 +23,36 @@ describe('Workflow Executions List', () => {
2323
).as('workflow-api');
2424
});
2525

26-
for (const view of ['feed', 'compact']) {
27-
it(`should show an empty state in the ${view} view`, () => {
28-
cy.visit(workflowUrl + `/history/${view}`);
26+
it(`should show an empty state in the feed view`, () => {
27+
cy.visit(workflowUrl + `/history`);
2928

30-
cy.wait('@workflow-api');
31-
cy.wait('@event-history-api');
32-
cy.wait('@query-api');
29+
cy.wait('@workflow-api');
30+
cy.wait('@event-history-api');
3331

34-
cy.contains('No Events Match');
35-
});
36-
}
32+
cy.contains('No Events Match');
33+
});
34+
35+
it(`should show an empty state in the compact view`, () => {
36+
cy.visit(workflowUrl + `/history`);
37+
38+
cy.wait('@workflow-api');
39+
cy.wait('@event-history-api');
40+
41+
cy.get('[data-cy="compact"]').click();
3742

38-
it.only('should display a custom empty state if there are events, but no event groups', () => {
43+
cy.contains('No Events Match');
44+
});
45+
46+
it('should display a custom empty state if there are events, but no event groups', () => {
3947
cy.intercept(
4048
Cypress.env('VITE_API_HOST') +
4149
`/api/v1/namespaces/default/workflows/*/runs/*/events*`,
4250
{ fixture: 'event-history-with-no-activities.json' },
4351
).as('event-history-api');
4452

45-
cy.visit(workflowUrl + `/history/compact`);
53+
cy.visit(workflowUrl + `/history`);
54+
55+
cy.get('[data-cy="compact"]').click();
4656

4757
cy.contains('No Events Match');
4858
});

cypress/integration/event-history.spec.js

+32-14
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ describe('Workflow Events', () => {
4848
cy.wait('@workflow-api');
4949
cy.wait('@event-history-descending');
5050

51-
cy.url().should('contain', '/feed');
51+
cy.url().should('contain', '/history');
5252
});
5353

5454
it('default to last viewed event view when visiting a workflow', () => {
@@ -57,21 +57,41 @@ describe('Workflow Events', () => {
5757
cy.wait('@workflow-api');
5858
cy.wait('@event-history-descending');
5959

60-
cy.url().should('contain', '/feed');
60+
cy.url().should('contain', '/history');
6161

62-
cy.get('[data-cy="feed"]').click();
63-
cy.url().should('contain', '/feed');
62+
cy.get('[data-cy="feed"]').should('have.class', 'active');
63+
cy.get('[data-cy="compact"]').should('not.have.class', 'active');
64+
cy.get('[data-cy="json"]').should('not.have.class', 'active');
65+
66+
cy.get('[data-cy="compact"]').click();
67+
68+
cy.visit('/namespaces/default/workflows');
69+
70+
cy.visit(`/namespaces/default/workflows/${workflowId}/${runId}`);
71+
72+
cy.url().should('contain', '/history');
73+
cy.get('[data-cy="compact"]').should('have.class', 'active');
74+
cy.get('[data-cy="json"]').should('not.have.class', 'active');
75+
cy.get('[data-cy="feed"]').should('not.have.class', 'active');
76+
77+
cy.get('[data-cy="event-summary-row"]')
78+
.should('not.have.length', 0)
79+
.should('not.have.length', eventsFixtureDescending.history.events.length);
80+
cy.get('table').contains('activity.timeout');
81+
82+
cy.get('[data-cy="json"]').click();
6483

6584
cy.visit('/namespaces/default/workflows');
6685

6786
cy.visit(`/namespaces/default/workflows/${workflowId}/${runId}`);
68-
cy.url().should('contain', '/feed');
87+
88+
cy.get('[data-cy="json"]').should('have.class', 'active');
89+
cy.get('[data-cy="compact"]').should('not.have.class', 'active');
90+
cy.get('[data-cy="feed"]').should('not.have.class', 'active');
6991
});
7092

7193
it('should render events in feed view', () => {
72-
cy.visit(
73-
`/namespaces/default/workflows/${workflowId}/${runId}/history/feed`,
74-
);
94+
cy.visit(`/namespaces/default/workflows/${workflowId}/${runId}/history`);
7595

7696
cy.wait('@workflow-api');
7797
cy.wait('@event-history-descending');
@@ -85,9 +105,7 @@ describe('Workflow Events', () => {
85105
});
86106

87107
it('should render event time in various formats', () => {
88-
cy.visit(
89-
`/namespaces/default/workflows/${workflowId}/${runId}/history/feed`,
90-
);
108+
cy.visit(`/namespaces/default/workflows/${workflowId}/${runId}/history`);
91109

92110
cy.wait('@workflow-api');
93111
cy.wait('@event-history-descending');
@@ -111,13 +129,13 @@ describe('Workflow Events', () => {
111129
});
112130

113131
it('should render events in compact view', () => {
114-
cy.visit(
115-
`/namespaces/default/workflows/${workflowId}/${runId}/history/compact`,
116-
);
132+
cy.visit(`/namespaces/default/workflows/${workflowId}/${runId}/history`);
117133

118134
cy.wait('@workflow-api');
119135
cy.wait('@event-history-descending');
120136

137+
cy.get('[data-cy="compact"]').click();
138+
121139
cy.get('[data-cy="event-summary-row"]')
122140
.should('not.have.length', 0)
123141
.should('not.have.length', eventsFixtureDescending.history.events.length);

cypress/integration/event-ordering-fallback-for-older-versions.spec.js

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
/// <reference types="cypress" />
22

33
const visitWorkflow = (suffix = '') => {
4-
cy.visit(
5-
`/namespaces/default/workflows/workflowId/runId/history/feed${suffix}`,
6-
);
4+
cy.visit(`/namespaces/default/workflows/workflowId/runId/history${suffix}`);
75
};
86

97
describe('Fallback to Ascending Ordering of Event History on Older Versions of Temporal Server', () => {

cypress/integration/events-in-ascending-order-in-json-view.spec.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
/// <reference types="cypress" />
22

33
const visitWorkflow = (suffix = '') => {
4-
cy.visit(
5-
`/namespaces/default/workflows/workflowId/runId/history/json${suffix}`,
6-
);
4+
cy.visit(`/namespaces/default/workflows/workflowId/runId/history${suffix}`);
5+
6+
cy.get('[data-cy="json"]').click();
77
};
88

99
describe('Fallback to Ascending Ordering of Event History on Older Versions of Temporal Server', () => {

cypress/integration/workers.spec.js

+65-10
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,72 @@ describe('Workflow Workers', () => {
4040

4141
cy.wait('@namespaces-api');
4242
cy.wait('@workflow-api');
43+
cy.wait('@worker-task-queues-api');
44+
cy.wait('@activity-task-queues-api');
4345
});
4446

4547
it('View both worker and activity poller', () => {
48+
cy.get('[data-cy=worker-row]').should('have.length', 1);
49+
cy.get('[data-cy=worker-identity]').contains(wtq.pollers[0].identity);
50+
cy.get('[data-cy=worker-last-access-time]').contains(
51+
dateTz.formatInTimeZone(
52+
new Date(atq.pollers[0].lastAccessTime),
53+
'UTC',
54+
'yyyy-MM-dd z HH:mm:ss.SS',
55+
),
56+
);
57+
58+
cy.get('[data-cy="workflow-poller"] > .text-blue-700').should('exist');
59+
cy.get('[data-cy="activity-poller"] > .text-blue-700').should('exist');
60+
});
61+
});
62+
63+
describe('Navigate to Workflow Workers', () => {
64+
beforeEach(() => {
65+
cy.interceptApi();
66+
67+
cy.intercept(
68+
Cypress.env('VITE_API_HOST') +
69+
`/api/v1/namespaces/default/workflows/${workflowId}/runs/${runId}?`,
70+
{ fixture: 'workflow-completed.json' },
71+
).as('workflow-api');
72+
73+
cy.intercept(
74+
Cypress.env('VITE_API_HOST') +
75+
`/api/v1/namespaces/default/task-queues/${name}?taskQueueType=1`,
76+
{
77+
fixture: 'worker-task-queues.json',
78+
},
79+
).as('worker-task-queues-api');
80+
81+
cy.intercept(
82+
Cypress.env('VITE_API_HOST') +
83+
`/api/v1/namespaces/default/task-queues/${name}?taskQueueType=2`,
84+
{
85+
fixture: 'activity-task-queues.json',
86+
},
87+
).as('activity-task-queues-api');
88+
89+
cy.intercept(
90+
Cypress.env('VITE_API_HOST') +
91+
`/api/v1/namespaces/default/workflows/*/runs/*/events/reverse*`,
92+
{ fixture: 'event-history-completed-reverse.json' },
93+
).as('event-history-descending');
94+
95+
cy.visit(`/namespaces/default/workflows/${workflowId}/${runId}`);
96+
97+
cy.wait('@namespaces-api');
98+
cy.wait('@workflow-api');
99+
cy.wait('@event-history-descending');
100+
});
101+
102+
it('View both worker and activity poller', () => {
103+
cy.url().should('contain', '/history');
104+
46105
cy.get('[data-cy=workers-tab]').click();
47106

107+
cy.url().should('contain', '/workers');
108+
48109
cy.wait('@worker-task-queues-api');
49110
cy.wait('@activity-task-queues-api');
50111

@@ -93,14 +154,11 @@ describe('Workflow Workers - Workflow Worker Only', () => {
93154

94155
cy.wait('@namespaces-api');
95156
cy.wait('@workflow-api');
96-
});
97-
98-
it('View workflow worker only poller', () => {
99-
cy.get('[data-cy=workers-tab]').click();
100-
101157
cy.wait('@worker-task-queues-api');
102158
cy.wait('@activity-task-queues-api');
159+
});
103160

161+
it('View workflow worker only poller', () => {
104162
cy.get('[data-cy=worker-row]').should('have.length', 1);
105163
cy.get('[data-cy=worker-identity]').contains(wtq.pollers[0].identity);
106164
cy.get('[data-cy=worker-last-access-time]').contains(
@@ -146,14 +204,11 @@ describe('Workflow Workers - Activity Worker Only', () => {
146204

147205
cy.wait('@namespaces-api');
148206
cy.wait('@workflow-api');
149-
});
150-
151-
it('View activity worker only poller', () => {
152-
cy.get('[data-cy=workers-tab]').click();
153-
154207
cy.wait('@worker-task-queues-api');
155208
cy.wait('@activity-task-queues-api');
209+
});
156210

211+
it('View activity worker only poller', () => {
157212
cy.get('[data-cy=worker-row]').should('have.length', 1);
158213
cy.get('[data-cy=worker-identity]').contains(atq.pollers[0].identity);
159214
cy.get('[data-cy=worker-last-access-time]').contains(

cypress/integration/workflow-actions.spec.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ describe('Workflow Actions', () => {
2525
describe('Terminate', () => {
2626
it('works if the workflow is running and write actions are enabled', () => {
2727
cy.visit(
28-
`/namespaces/default/workflows/${workflowId}/${runId}/history/feed?sort=descending`,
28+
`/namespaces/default/workflows/${workflowId}/${runId}/history?sort=descending`,
2929
);
3030

3131
cy.wait('@settings-api');
@@ -42,7 +42,7 @@ describe('Workflow Actions', () => {
4242
describe('Cancel', () => {
4343
it('works if the workflow is running a write actions are enabled', () => {
4444
cy.visit(
45-
`/namespaces/default/workflows/${workflowId}/${runId}/history/feed?sort=descending`,
45+
`/namespaces/default/workflows/${workflowId}/${runId}/history?sort=descending`,
4646
);
4747

4848
cy.wait('@settings-api');
@@ -62,7 +62,7 @@ describe('Workflow Actions', () => {
6262
}).as('settings-api');
6363

6464
cy.visit(
65-
`/namespaces/default/workflows/${workflowId}/${runId}/history/feed?sort=descending`,
65+
`/namespaces/default/workflows/${workflowId}/${runId}/history?sort=descending`,
6666
);
6767

6868
cy.wait('@settings-api');

cypress/integration/workflow-executions-with-new-search.spec.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ describe('Workflow Executions List With Search', () => {
205205
cy.wait('@workflow-api');
206206
cy.wait('@event-history-api');
207207

208-
cy.url().should('contain', '/feed');
208+
cy.url().should('contain', '/history');
209209
cy.get('[data-cy="back-to-workflows"]').click();
210210

211211
cy.url().should(

cypress/integration/workflow-executions.spec.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ describe('Workflow Executions List', () => {
110110
cy.wait('@workflow-api');
111111
cy.wait('@event-history-api');
112112

113-
cy.url().should('contain', '/feed');
113+
cy.url().should('contain', '/history');
114114
cy.get('[data-cy="back-to-workflows"]').click();
115115

116116
cy.url().should(

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@temporalio/ui",
3-
"version": "2.1.91",
3+
"version": "2.1.92",
44
"type": "module",
55
"description": "Temporal.io UI",
66
"keywords": [

src/lib/components/event/event-details-row-expanded.svelte

-3
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
import Link from '$lib/holocene/link.svelte';
1919
import Copyable from '../copyable.svelte';
2020
import type { CombinedAttributes } from '$lib/utilities/format-event-attributes';
21-
import { eventViewType } from '$lib/stores/event-view';
2221
2322
export let key: string;
2423
export let value: string | Record<string, unknown>;
@@ -51,7 +50,6 @@
5150
<Link
5251
newTab
5352
href={routeForEventHistory({
54-
view: $eventViewType,
5553
namespace,
5654
workflow,
5755
run: value,
@@ -70,7 +68,6 @@
7068
<Link
7169
newTab
7270
href={routeForEventHistory({
73-
view: $eventViewType,
7471
namespace,
7572
workflow: attributes.workflowExecutionWorkflowId,
7673
run: attributes.workflowExecutionRunId,

src/lib/components/event/event-details-row.svelte

-3
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
import Link from '$lib/holocene/link.svelte';
1919
import Copyable from '../copyable.svelte';
2020
import type { CombinedAttributes } from '$lib/utilities/format-event-attributes';
21-
import { eventViewType } from '$lib/stores/event-view';
2221
2322
export let key: string;
2423
export let value: string | Record<string, unknown>;
@@ -49,7 +48,6 @@
4948
class="truncate"
5049
newTab
5150
href={routeForEventHistory({
52-
view: $eventViewType,
5351
namespace,
5452
workflow,
5553
run: value,
@@ -69,7 +67,6 @@
6967
class="truncate"
7068
newTab
7169
href={routeForEventHistory({
72-
view: $eventViewType,
7370
namespace,
7471
workflow: attributes.workflowExecutionWorkflowId,
7572
run: attributes.workflowExecutionRunId,

src/lib/components/schedule/schedule-recent-runs.svelte

-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
import EmptyState from '$lib/holocene/empty-state.svelte';
1010
import { routeForEventHistory } from '$lib/utilities/route-for';
1111
import Link from '$lib/holocene/link.svelte';
12-
import { eventViewType } from '$lib/stores/event-view';
1312
1413
export let recentRuns: ScheduleActionResult[] = [];
1514
export let namespace: string;
@@ -27,7 +26,6 @@
2726
<Link
2827
sveltekit:prefetch
2928
href={routeForEventHistory({
30-
view: $eventViewType,
3129
workflow: run.startWorkflowResult.workflowId,
3230
run: run.startWorkflowResult.runId,
3331
namespace,

src/lib/components/schedule/schedules-table-row.svelte

-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
1313
import ScheduleFrequency from './schedule-frequency.svelte';
1414
import TableRow from '$lib/holocene/table/table-row.svelte';
15-
import { eventViewType } from '$lib/stores/event-view';
1615
1716
let { namespace } = $page.params;
1817
@@ -59,7 +58,6 @@
5958
<p>
6059
<Link
6160
href={routeForEventHistory({
62-
view: $eventViewType,
6361
namespace,
6462
workflow: run?.startWorkflowResult?.workflowId,
6563
run: run?.startWorkflowResult?.runId,

0 commit comments

Comments
 (0)