-
Notifications
You must be signed in to change notification settings - Fork 8.3k
/
copy_saved_objects.ts
197 lines (153 loc) · 6.27 KB
/
copy_saved_objects.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/
import expect from '@kbn/expect';
import { FtrProviderContext } from '../../ftr_provider_context';
export default function spaceSelectorFunctionalTests({
getService,
getPageObjects,
}: FtrProviderContext) {
const kbnServer = getService('kibanaServer');
const spaces = getService('spaces');
const testSubjects = getService('testSubjects');
const PageObjects = getPageObjects(['security', 'settings', 'copySavedObjectsToSpace']);
const log = getService('log');
describe('Copy Saved Objects to Space', function () {
before(async () => {
log.debug('Loading test data for the following spaces: default, sales');
await Promise.all([
kbnServer.importExport.load(
'x-pack/test/functional/fixtures/kbn_archiver/spaces/copy_saved_objects_default_space.json'
),
kbnServer.importExport.load(
'x-pack/test/functional/fixtures/kbn_archiver/spaces/copy_saved_objects_sales_space.json',
{ space: 'sales' }
),
]);
await spaces.create({
id: 'marketing',
name: 'Marketing',
disabledFeatures: [],
});
await spaces.create({
id: 'sales',
name: 'Sales',
disabledFeatures: [],
});
await PageObjects.security.forceLogout();
await PageObjects.security.login(undefined, undefined, {
expectSpaceSelector: true,
});
await PageObjects.settings.navigateTo();
await PageObjects.settings.clickKibanaSavedObjects();
});
after(async () => {
log.debug('Removing data from the following spaces: default, sales');
await Promise.all(
['default', 'sales'].map((spaceId) =>
kbnServer.savedObjects.cleanStandardList({ space: spaceId })
)
);
await spaces.delete('sales');
await spaces.delete('marketing');
});
it('allows a dashboard to be copied to the marketing space, with all references', async () => {
const destinationSpaceId = 'marketing';
await PageObjects.copySavedObjectsToSpace.openCopyToSpaceFlyoutForObject('A Dashboard');
await PageObjects.copySavedObjectsToSpace.setupForm({
createNewCopies: false,
overwrite: true,
destinationSpaceId,
});
await PageObjects.copySavedObjectsToSpace.startCopy();
// Wait for successful copy
await testSubjects.waitForDeleted(`cts-summary-indicator-loading-${destinationSpaceId}`);
await testSubjects.existOrFail(`cts-summary-indicator-success-${destinationSpaceId}`);
const summaryCounts = await PageObjects.copySavedObjectsToSpace.getSummaryCounts();
expect(summaryCounts).to.eql({
success: 3,
pending: 0,
skipped: 0,
errors: 0,
});
await PageObjects.copySavedObjectsToSpace.finishCopy();
});
it('allows conflicts to be resolved', async () => {
const destinationSpaceId = 'sales';
await PageObjects.copySavedObjectsToSpace.openCopyToSpaceFlyoutForObject('A Dashboard');
await PageObjects.copySavedObjectsToSpace.setupForm({
createNewCopies: false,
overwrite: false,
destinationSpaceId,
});
await PageObjects.copySavedObjectsToSpace.startCopy();
// Wait for successful copy with conflict warning
await testSubjects.waitForDeleted(`cts-summary-indicator-loading-${destinationSpaceId}`);
await testSubjects.existOrFail(`cts-summary-indicator-conflicts-${destinationSpaceId}`);
const summaryCounts = await PageObjects.copySavedObjectsToSpace.getSummaryCounts();
expect(summaryCounts).to.eql({
success: 0,
pending: 2,
skipped: 1,
errors: 0,
});
// Mark conflict for overwrite
await testSubjects.click(`cts-space-result-${destinationSpaceId}`);
await testSubjects.click(`cts-overwrite-conflict-index-pattern:logstash-*`);
// Verify summary changed
const updatedSummaryCounts = await PageObjects.copySavedObjectsToSpace.getSummaryCounts();
expect(updatedSummaryCounts).to.eql({
success: 0,
pending: 3,
skipped: 0,
errors: 0,
});
await PageObjects.copySavedObjectsToSpace.finishCopy();
});
it('avoids conflicts when createNewCopies is enabled', async () => {
const destinationSpaceId = 'sales';
await PageObjects.copySavedObjectsToSpace.openCopyToSpaceFlyoutForObject('A Dashboard');
await PageObjects.copySavedObjectsToSpace.setupForm({
createNewCopies: true,
overwrite: false,
destinationSpaceId,
});
await PageObjects.copySavedObjectsToSpace.startCopy();
// Wait for successful copy
await testSubjects.waitForDeleted(`cts-summary-indicator-loading-${destinationSpaceId}`);
await testSubjects.existOrFail(`cts-summary-indicator-success-${destinationSpaceId}`);
const summaryCounts = await PageObjects.copySavedObjectsToSpace.getSummaryCounts();
expect(summaryCounts).to.eql({
success: 3,
pending: 0,
skipped: 0,
errors: 0,
});
await PageObjects.copySavedObjectsToSpace.finishCopy();
});
it('allows a dashboard to be copied to the marketing space, with circular references', async () => {
const destinationSpaceId = 'marketing';
await PageObjects.copySavedObjectsToSpace.openCopyToSpaceFlyoutForObject('Dashboard Foo');
await PageObjects.copySavedObjectsToSpace.setupForm({
createNewCopies: false,
overwrite: true,
destinationSpaceId,
});
await PageObjects.copySavedObjectsToSpace.startCopy();
// Wait for successful copy
await testSubjects.waitForDeleted(`cts-summary-indicator-loading-${destinationSpaceId}`);
await testSubjects.existOrFail(`cts-summary-indicator-success-${destinationSpaceId}`);
const summaryCounts = await PageObjects.copySavedObjectsToSpace.getSummaryCounts();
expect(summaryCounts).to.eql({
success: 2,
pending: 0,
skipped: 0,
errors: 0,
});
await PageObjects.copySavedObjectsToSpace.finishCopy();
});
});
}