@sprucelabs/spruce-cli 24.0.0 → 24.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/build/__tests__/behavioral/conversations/CreatingAConversationTopic.test.js +2 -2
- package/build/__tests__/behavioral/conversations/CreatingAConversationTopic.test.js.map +1 -1
- package/build/__tests__/behavioral/conversations/RegisteringConversationsOnBoot.test.js +1 -1
- package/build/__tests__/behavioral/conversations/RegisteringConversationsOnBoot.test.js.map +1 -1
- package/build/__tests__/behavioral/conversations/TestingAConversation.test.js +5 -5
- package/build/__tests__/behavioral/conversations/TestingAConversation.test.js.map +1 -1
- package/build/__tests__/behavioral/organization/CreatingAnOrg.test.js.map +1 -1
- package/build/__tests__/behavioral/tests/migrationToInstance/AbstractInstanceTest.d.ts +11 -0
- package/build/__tests__/behavioral/tests/migrationToInstance/AbstractInstanceTest.js +49 -0
- package/build/__tests__/behavioral/tests/migrationToInstance/AbstractInstanceTest.js.map +1 -0
- package/build/__tests__/behavioral/tests/migrationToInstance/InstanceBasedTesting.test.d.ts +5 -0
- package/build/__tests__/behavioral/tests/migrationToInstance/InstanceBasedTesting.test.js +34 -0
- package/build/__tests__/behavioral/tests/migrationToInstance/InstanceBasedTesting.test.js.map +1 -0
- package/build/__tests__/behavioral/tests/migrationToInstance/MigratingTests.test.d.ts +12 -0
- package/build/__tests__/behavioral/tests/migrationToInstance/MigratingTests.test.js +88 -0
- package/build/__tests__/behavioral/tests/migrationToInstance/MigratingTests.test.js.map +1 -0
- package/build/__tests__/behavioral/tests/migrationToInstance/StaticTestFinder.test.d.ts +13 -0
- package/build/__tests__/behavioral/tests/migrationToInstance/StaticTestFinder.test.js +109 -0
- package/build/__tests__/behavioral/tests/migrationToInstance/StaticTestFinder.test.js.map +1 -0
- package/build/__tests__/behavioral/tests/migrationToInstance/StaticTestsWhenAlreadyExists.test.d.ts +4 -0
- package/build/__tests__/behavioral/tests/migrationToInstance/StaticTestsWhenAlreadyExists.test.js +29 -0
- package/build/__tests__/behavioral/tests/migrationToInstance/StaticTestsWhenAlreadyExists.test.js.map +1 -0
- package/build/__tests__/behavioral/tests/migrationToInstance/StaticToInstanceMigrator.test.d.ts +26 -0
- package/build/__tests__/behavioral/tests/migrationToInstance/StaticToInstanceMigrator.test.js +259 -0
- package/build/__tests__/behavioral/tests/migrationToInstance/StaticToInstanceMigrator.test.js.map +1 -0
- package/build/__tests__/behavioral/tests/migrationToInstance/StaticToInstanceTestFileMigrator.test.d.ts +26 -0
- package/build/__tests__/behavioral/tests/migrationToInstance/StaticToInstanceTestFileMigrator.test.js +202 -0
- package/build/__tests__/behavioral/tests/migrationToInstance/StaticToInstanceTestFileMigrator.test.js.map +1 -0
- package/build/__tests__/behavioral/tests/migrationToInstance/support/AbstractInstanceTest.txt +24 -0
- package/build/__tests__/behavioral/tests/migrationToInstance/support/AbstractStaticTest.txt +24 -0
- package/build/__tests__/behavioral/tests/migrationToInstance/support/InstanceTest.txt +36 -0
- package/build/__tests__/behavioral/tests/migrationToInstance/support/InstanceTest2.txt +63 -0
- package/build/__tests__/behavioral/tests/migrationToInstance/support/InstanceTest3.txt +222 -0
- package/build/__tests__/behavioral/tests/migrationToInstance/support/StaticTest.txt +34 -0
- package/build/__tests__/behavioral/tests/migrationToInstance/support/StaticTest2.txt +62 -0
- package/build/__tests__/behavioral/tests/migrationToInstance/support/StaticTest3.txt +221 -0
- package/build/__tests__/behavioral/tests/migrationToInstance/testFileContentsGenerators.d.ts +2 -0
- package/build/__tests__/behavioral/tests/migrationToInstance/testFileContentsGenerators.js +51 -0
- package/build/__tests__/behavioral/tests/migrationToInstance/testFileContentsGenerators.js.map +1 -0
- package/build/__tests__/behavioral/versions/ResolvingVersions.test.js +0 -3
- package/build/__tests__/behavioral/versions/ResolvingVersions.test.js.map +1 -1
- package/build/__tests__/implementation/OrganizationStore.test.js +2 -2
- package/build/__tests__/implementation/OrganizationStore.test.js.map +1 -1
- package/build/__tests__/testDirsAndFiles/static_test_migration_1/src/__tests__/AnotherStaticTest.test.ts +33 -0
- package/build/__tests__/testDirsAndFiles/static_test_migration_1/src/__tests__/ShouldBeIgnored.ts +0 -0
- package/build/__tests__/testDirsAndFiles/static_test_migration_1/src/__tests__/StaticTest1.test.ts +33 -0
- package/build/__tests__/testDirsAndFiles/static_test_migration_2/src/DoNotInclude.ts +0 -0
- package/build/__tests__/testDirsAndFiles/static_test_migration_2/src/__tests__/AStaticTest.test.ts +33 -0
- package/build/__tests__/testDirsAndFiles/static_test_migration_2/src/__tests__/AnotherStaticTest1.test.ts +33 -0
- package/build/__tests__/testDirsAndFiles/static_test_migration_3/NotAFileThatShouldBeMigrated.ts +0 -0
- package/build/__tests__/testDirsAndFiles/static_test_migration_3/src/__tests__/AStaticTest2.test.ts +17 -0
- package/build/__tests__/testDirsAndFiles/static_test_migration_3/src/__tests__/AbstractWhateverTest.ts +3 -0
- package/build/features/test/actions/CreateAction.d.ts +1 -0
- package/build/features/test/actions/CreateAction.js +13 -0
- package/build/features/test/actions/CreateAction.js.map +1 -1
- package/build/features/test/actions/MigrateAction.d.ts +17 -0
- package/build/features/test/actions/MigrateAction.js +39 -0
- package/build/features/test/actions/MigrateAction.js.map +1 -0
- package/build/tests/staticToInstanceMigration/StaticTestFinder.d.ts +8 -0
- package/build/tests/staticToInstanceMigration/StaticTestFinder.js +23 -0
- package/build/tests/staticToInstanceMigration/StaticTestFinder.js.map +1 -0
- package/build/tests/staticToInstanceMigration/StaticToInstanceMigrator.d.ts +58 -0
- package/build/tests/staticToInstanceMigration/StaticToInstanceMigrator.js +48 -0
- package/build/tests/staticToInstanceMigration/StaticToInstanceMigrator.js.map +1 -0
- package/build/tests/staticToInstanceMigration/StaticToInstanceTestFileMigrator.d.ts +12 -0
- package/build/tests/staticToInstanceMigration/StaticToInstanceTestFileMigrator.js +138 -0
- package/build/tests/staticToInstanceMigration/StaticToInstanceTestFileMigrator.js.map +1 -0
- package/package.json +27 -27
- package/src/__tests__/behavioral/conversations/CreatingAConversationTopic.test.ts +2 -2
- package/src/__tests__/behavioral/conversations/RegisteringConversationsOnBoot.test.ts +1 -1
- package/src/__tests__/behavioral/conversations/TestingAConversation.test.ts +5 -5
- package/src/__tests__/behavioral/organization/CreatingAnOrg.test.ts +0 -1
- package/src/__tests__/behavioral/tests/migrationToInstance/AbstractInstanceTest.ts +77 -0
- package/src/__tests__/behavioral/tests/migrationToInstance/InstanceBasedTesting.test.ts +19 -0
- package/src/__tests__/behavioral/tests/migrationToInstance/MigratingTests.test.ts +99 -0
- package/src/__tests__/behavioral/tests/migrationToInstance/StaticTestFinder.test.ts +72 -0
- package/src/__tests__/behavioral/tests/migrationToInstance/StaticTestsWhenAlreadyExists.test.ts +31 -0
- package/src/__tests__/behavioral/tests/migrationToInstance/StaticToInstanceMigrator.test.ts +252 -0
- package/src/__tests__/behavioral/tests/migrationToInstance/StaticToInstanceTestFileMigrator.test.ts +193 -0
- package/src/__tests__/behavioral/tests/migrationToInstance/support/AbstractInstanceTest.txt +24 -0
- package/src/__tests__/behavioral/tests/migrationToInstance/support/AbstractStaticTest.txt +24 -0
- package/src/__tests__/behavioral/tests/migrationToInstance/support/InstanceTest.txt +36 -0
- package/src/__tests__/behavioral/tests/migrationToInstance/support/InstanceTest2.txt +63 -0
- package/src/__tests__/behavioral/tests/migrationToInstance/support/InstanceTest3.txt +222 -0
- package/src/__tests__/behavioral/tests/migrationToInstance/support/StaticTest.txt +34 -0
- package/src/__tests__/behavioral/tests/migrationToInstance/support/StaticTest2.txt +62 -0
- package/src/__tests__/behavioral/tests/migrationToInstance/support/StaticTest3.txt +221 -0
- package/src/__tests__/behavioral/tests/migrationToInstance/testFileContentsGenerators.ts +50 -0
- package/src/__tests__/behavioral/versions/ResolvingVersions.test.ts +1 -3
- package/src/__tests__/implementation/OrganizationStore.test.ts +6 -2
- package/src/__tests__/testDirsAndFiles/static_test_migration_1/src/__tests__/AnotherStaticTest.test.ts +33 -0
- package/src/__tests__/testDirsAndFiles/static_test_migration_1/src/__tests__/ShouldBeIgnored.ts +0 -0
- package/src/__tests__/testDirsAndFiles/static_test_migration_1/src/__tests__/StaticTest1.test.ts +33 -0
- package/src/__tests__/testDirsAndFiles/static_test_migration_2/src/DoNotInclude.ts +0 -0
- package/src/__tests__/testDirsAndFiles/static_test_migration_2/src/__tests__/AStaticTest.test.ts +33 -0
- package/src/__tests__/testDirsAndFiles/static_test_migration_2/src/__tests__/AnotherStaticTest1.test.ts +33 -0
- package/src/__tests__/testDirsAndFiles/static_test_migration_3/NotAFileThatShouldBeMigrated.ts +0 -0
- package/src/__tests__/testDirsAndFiles/static_test_migration_3/src/__tests__/AStaticTest2.test.ts +17 -0
- package/src/__tests__/testDirsAndFiles/static_test_migration_3/src/__tests__/AbstractWhateverTest.ts +3 -0
- package/src/features/test/actions/CreateAction.ts +17 -0
- package/src/features/test/actions/MigrateAction.ts +41 -0
- package/src/tests/staticToInstanceMigration/StaticTestFinder.ts +25 -0
- package/src/tests/staticToInstanceMigration/StaticToInstanceMigrator.ts +73 -0
- package/src/tests/staticToInstanceMigration/StaticToInstanceTestFileMigrator.ts +197 -0
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
import {
|
|
2
|
+
activeRecordCardAssert,
|
|
3
|
+
buttonAssert,
|
|
4
|
+
interactor,
|
|
5
|
+
MockActiveRecordCard,
|
|
6
|
+
vcAssert,
|
|
7
|
+
} from '@sprucelabs/heartwood-view-controllers'
|
|
8
|
+
import { eventFaker, fake } from '@sprucelabs/spruce-test-fixtures'
|
|
9
|
+
import { test, suite, generateId, assert } from '@sprucelabs/test-utils'
|
|
10
|
+
import { PublicHomeIntegration } from '../../google.types'
|
|
11
|
+
import RootSkillViewController from '../../skillViewControllers/Root.svc'
|
|
12
|
+
import AddHomeIntegrationCardViewController from '../../viewControllers/AddHomeIntegrationCard.vc'
|
|
13
|
+
import AbstractGoogleTest from '../support/AbstractGoogleTest'
|
|
14
|
+
import { DeleteHomeIntergrationTargetAndPayload } from '../support/EventFaker'
|
|
15
|
+
import SpyAddHomeIntegrationCard from './homeIntegrations/SpyAddHomeIntegrationCard'
|
|
16
|
+
|
|
17
|
+
@fake.login()
|
|
18
|
+
@suite()
|
|
19
|
+
export default class RootSkillViewTest extends AbstractGoogleTest {
|
|
20
|
+
private vc!: SpyRootSkillView
|
|
21
|
+
private fakedIntegrations: PublicHomeIntegration[] = []
|
|
22
|
+
protected names: string[] = []
|
|
23
|
+
|
|
24
|
+
protected async beforeEach(): Promise<void> {
|
|
25
|
+
await super.beforeEach()
|
|
26
|
+
|
|
27
|
+
this.fakedIntegrations = []
|
|
28
|
+
this.names = []
|
|
29
|
+
|
|
30
|
+
this.views.setController(
|
|
31
|
+
'google.add-home-integration-card',
|
|
32
|
+
SpyAddHomeIntegrationCard
|
|
33
|
+
)
|
|
34
|
+
this.views.setController('active-record-card', MockActiveRecordCard)
|
|
35
|
+
this.views.setController('google.root', SpyRootSkillView)
|
|
36
|
+
this.vc = this.views.Controller('google.root', {}) as SpyRootSkillView
|
|
37
|
+
|
|
38
|
+
await this.eventFaker.fakeListHomeIntegrations(() => {
|
|
39
|
+
return this.fakedIntegrations
|
|
40
|
+
})
|
|
41
|
+
|
|
42
|
+
await this.eventFaker.fakeDeleteHomeIntegration()
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
@test()
|
|
46
|
+
protected async rendersACard() {
|
|
47
|
+
vcAssert.assertSkillViewRendersCard(this.vc, 'home-cloud-integrations')
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
@test()
|
|
51
|
+
protected async cardRendersList() {
|
|
52
|
+
activeRecordCardAssert.skillViewRendersActiveRecordCard(this.vc)
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
@test()
|
|
56
|
+
protected async requiresLogin() {
|
|
57
|
+
await vcAssert.assertLoginIsRequired(this.vc)
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
@test()
|
|
61
|
+
protected async returnsAListOfIntegrations() {
|
|
62
|
+
const integration = this.seedIntegration()
|
|
63
|
+
await this.load()
|
|
64
|
+
this.assertRendersIntegrationRow(integration.id)
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
@test()
|
|
68
|
+
protected async homeIntegrationsCardRendersExpectedButtons() {
|
|
69
|
+
buttonAssert.cardRendersButtons(this.homeIntegrationsCardVc, [
|
|
70
|
+
'instructions',
|
|
71
|
+
'add',
|
|
72
|
+
])
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
@test()
|
|
76
|
+
protected async clickingAddIntegrationRendersDialog() {
|
|
77
|
+
await this.loadClickAddAndAssertRendersDialog()
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
@test()
|
|
81
|
+
protected async callingOnDoneInAddCardHidesDialog() {
|
|
82
|
+
const { addCardVc, dialogVc } =
|
|
83
|
+
await this.loadClickAddAndAssertRendersDialog()
|
|
84
|
+
await addCardVc.simulateClickDone()
|
|
85
|
+
|
|
86
|
+
assert.isFalse(dialogVc.getIsVisible())
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
@test()
|
|
90
|
+
protected async eachRowRendersDeleteButton() {
|
|
91
|
+
const integration = await this.seedOneIntegrationAndLoad()
|
|
92
|
+
|
|
93
|
+
this.homeIntegrationsCardVc.assertRowRendersButton(
|
|
94
|
+
integration.id,
|
|
95
|
+
'delete'
|
|
96
|
+
)
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
@test()
|
|
100
|
+
protected async clickingDeleteButtonRendersAlert() {
|
|
101
|
+
await this.seedLoadClickDeleteAndAssertConfirm()
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
@test()
|
|
105
|
+
protected async clickingDeleteAndConfirmingRemovesRow() {
|
|
106
|
+
const integration = await this.seedLoadClickDeleteAndConfirm()
|
|
107
|
+
this.homeIntegrationsCardVc.assertDoesNotRenderRow(integration.id)
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
@test()
|
|
111
|
+
protected async doesNotRefreshListIfUserCancels() {
|
|
112
|
+
const int = await this.seedLoadClickDeleteAndDecline()
|
|
113
|
+
|
|
114
|
+
this.assertRendersIntegrationRow(int.id)
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
@test()
|
|
118
|
+
protected async confirmingDeleteShouldEmitDeleteEvent() {
|
|
119
|
+
let passedTarget:
|
|
120
|
+
| DeleteHomeIntergrationTargetAndPayload['target']
|
|
121
|
+
| undefined
|
|
122
|
+
|
|
123
|
+
await this.eventFaker.fakeDeleteHomeIntegration(({ target }) => {
|
|
124
|
+
passedTarget = target
|
|
125
|
+
})
|
|
126
|
+
|
|
127
|
+
const integration = await this.seedLoadClickDeleteAndConfirm()
|
|
128
|
+
|
|
129
|
+
assert.isEqualDeep(passedTarget, {
|
|
130
|
+
integrationId: integration.id,
|
|
131
|
+
})
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
@test()
|
|
135
|
+
protected async doesNotEmitEventIfDeclined() {
|
|
136
|
+
await eventFaker.makeEventThrow(
|
|
137
|
+
'google.delete-home-integration::v2025_02_08'
|
|
138
|
+
)
|
|
139
|
+
|
|
140
|
+
await this.seedLoadClickDeleteAndDecline()
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
private async loadClickAddAndAssertRendersDialog() {
|
|
144
|
+
await this.load()
|
|
145
|
+
const dialogVc = await vcAssert.assertRendersDialog(this.vc, () =>
|
|
146
|
+
interactor.clickButton(this.homeIntegrationsCardVc, 'add')
|
|
147
|
+
)
|
|
148
|
+
|
|
149
|
+
const addCardVc = vcAssert.assertRendersAsInstanceOf(
|
|
150
|
+
dialogVc,
|
|
151
|
+
AddHomeIntegrationCardViewController
|
|
152
|
+
) as SpyAddHomeIntegrationCard
|
|
153
|
+
return { dialogVc, addCardVc }
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
private async seedLoadClickDeleteAndConfirm() {
|
|
157
|
+
const { confirmVc, integration } =
|
|
158
|
+
await this.seedLoadClickDeleteAndAssertConfirm()
|
|
159
|
+
|
|
160
|
+
await confirmVc.accept()
|
|
161
|
+
|
|
162
|
+
return integration
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
private async seedLoadClickDeleteAndDecline() {
|
|
166
|
+
const { confirmVc, integration } =
|
|
167
|
+
await this.seedLoadClickDeleteAndAssertConfirm()
|
|
168
|
+
|
|
169
|
+
const int = integration
|
|
170
|
+
|
|
171
|
+
await confirmVc.decline()
|
|
172
|
+
return int
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
private assertRendersIntegrationRow(id: string) {
|
|
176
|
+
this.homeIntegrationsCardVc.assertRendersRow(id)
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
private async seedLoadClickDeleteAndAssertConfirm() {
|
|
180
|
+
const integration = await this.seedOneIntegrationAndLoad()
|
|
181
|
+
|
|
182
|
+
const confirmVc = await vcAssert.assertRendersConfirm(this.vc, () =>
|
|
183
|
+
interactor.clickButtonInRow(this.listVc, integration.id, 'delete')
|
|
184
|
+
)
|
|
185
|
+
return { confirmVc, integration }
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
private get listVc() {
|
|
189
|
+
return this.homeIntegrationsCardVc.getListVc()
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
private async seedOneIntegrationAndLoad() {
|
|
193
|
+
const integration = this.seedIntegration()
|
|
194
|
+
await this.load()
|
|
195
|
+
return integration
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
private seedIntegration() {
|
|
199
|
+
const integration: PublicHomeIntegration = {
|
|
200
|
+
description: generateId(),
|
|
201
|
+
id: generateId(),
|
|
202
|
+
name: generateId(),
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
this.fakedIntegrations.push(integration)
|
|
206
|
+
return integration
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
private async load() {
|
|
210
|
+
await this.views.load(this.vc)
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
private get homeIntegrationsCardVc() {
|
|
214
|
+
return this.vc.getHomeIntegrationsCardVc()
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
class SpyRootSkillView extends RootSkillViewController {
|
|
219
|
+
public getHomeIntegrationsCardVc() {
|
|
220
|
+
return this.activeRecordCardVc as MockActiveRecordCard
|
|
221
|
+
}
|
|
222
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { assertOptions } from '@sprucelabs/schema'
|
|
2
|
+
import { fake } from '@sprucelabs/spruce-test-fixtures'
|
|
3
|
+
import AbstractSpruceTest, {
|
|
4
|
+
test,
|
|
5
|
+
assert,
|
|
6
|
+
errorAssert,
|
|
7
|
+
} from '@sprucelabs/test-utils'
|
|
8
|
+
|
|
9
|
+
@fake.login()
|
|
10
|
+
export default class StaticTestFinderTest extends AbstractSpruceTest {
|
|
11
|
+
@test()
|
|
12
|
+
protected static async throwsWithMissing() {
|
|
13
|
+
const finder = StaticTestFinder.Finder()
|
|
14
|
+
const err = await assert.doesThrowAsync(() => finder.find())
|
|
15
|
+
errorAssert.assertError(err, 'MISSING_PARAMETERS', {
|
|
16
|
+
parameters: ['lookupDir'],
|
|
17
|
+
})
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
@test()
|
|
21
|
+
protected static async yourNextTest() {
|
|
22
|
+
assert.isTrue(false)
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
class StaticTestFinder {
|
|
27
|
+
public static Finder() {
|
|
28
|
+
return new this()
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
public async find() {
|
|
32
|
+
assertOptions({}, ['lookupDir'])
|
|
33
|
+
}
|
|
34
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { fake, seed } from '@sprucelabs/spruce-test-fixtures'
|
|
2
|
+
import { assert, test } from '@sprucelabs/test-utils'
|
|
3
|
+
import { HomeIntegration, PublicHomeIntegration } from '../../../google.types'
|
|
4
|
+
import AbstractGoogleTest from '../../support/AbstractGoogleTest'
|
|
5
|
+
|
|
6
|
+
@fake.login()
|
|
7
|
+
export default class ListHomeIntegrationsLIstenerTest extends AbstractGoogleTest {
|
|
8
|
+
protected static async beforeEach(): Promise<void> {
|
|
9
|
+
await super.beforeEach()
|
|
10
|
+
await this.bootSkill()
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
protected static async afterEach(): Promise<void> {
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
@test()
|
|
17
|
+
protected static async skillIsListening() {
|
|
18
|
+
await this.emit()
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
@test()
|
|
22
|
+
@seed('homeIntegrations', 1)
|
|
23
|
+
protected static async canReturnFirstHomeIntegration() {
|
|
24
|
+
const expected = await this.getFirstHomeIntegration()
|
|
25
|
+
const integrations = await this.emit()
|
|
26
|
+
assert.isLength(integrations, 1)
|
|
27
|
+
const first = integrations[0]
|
|
28
|
+
this.assertIntegrationEqualsExpected(first, expected)
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
@test()
|
|
32
|
+
@seed('homeIntegrations', 2)
|
|
33
|
+
protected static async canReturnMultipleHomeIntegrations() {
|
|
34
|
+
const expected = await this.homeIntegrations.find(
|
|
35
|
+
{},
|
|
36
|
+
{},
|
|
37
|
+
{ shouldIncludePrivateFields: true }
|
|
38
|
+
)
|
|
39
|
+
const integrations = await this.emit()
|
|
40
|
+
assert.isLength(integrations, 2)
|
|
41
|
+
this.assertIntegrationEqualsExpected(integrations[0], expected[0])
|
|
42
|
+
this.assertIntegrationEqualsExpected(integrations[1], expected[1])
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
private static assertIntegrationEqualsExpected(
|
|
46
|
+
first: PublicHomeIntegration,
|
|
47
|
+
expected: HomeIntegration
|
|
48
|
+
) {
|
|
49
|
+
assert.isEqual(first.id, expected.id)
|
|
50
|
+
assert.isEqual(first.name, expected.name)
|
|
51
|
+
assert.isEqual(first.description, expected.description)
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
private static async emit() {
|
|
55
|
+
const [{ integrations }] =
|
|
56
|
+
await this.fakedClient.emitAndFlattenResponses(
|
|
57
|
+
'google.list-home-integrations::v2025_02_08'
|
|
58
|
+
)
|
|
59
|
+
|
|
60
|
+
return integrations
|
|
61
|
+
}
|
|
62
|
+
}
|
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
import {
|
|
2
|
+
activeRecordCardAssert,
|
|
3
|
+
buttonAssert,
|
|
4
|
+
interactor,
|
|
5
|
+
MockActiveRecordCard,
|
|
6
|
+
vcAssert,
|
|
7
|
+
} from '@sprucelabs/heartwood-view-controllers'
|
|
8
|
+
import { eventFaker, fake } from '@sprucelabs/spruce-test-fixtures'
|
|
9
|
+
import { test, generateId, assert } from '@sprucelabs/test-utils'
|
|
10
|
+
import { PublicHomeIntegration } from '../../google.types'
|
|
11
|
+
import RootSkillViewController from '../../skillViewControllers/Root.svc'
|
|
12
|
+
import AddHomeIntegrationCardViewController from '../../viewControllers/AddHomeIntegrationCard.vc'
|
|
13
|
+
import AbstractGoogleTest from '../support/AbstractGoogleTest'
|
|
14
|
+
import { DeleteHomeIntergrationTargetAndPayload } from '../support/EventFaker'
|
|
15
|
+
import SpyAddHomeIntegrationCard from './homeIntegrations/SpyAddHomeIntegrationCard'
|
|
16
|
+
|
|
17
|
+
@fake.login()
|
|
18
|
+
export default class RootSkillViewTest extends AbstractGoogleTest {
|
|
19
|
+
private static vc: SpyRootSkillView
|
|
20
|
+
private static fakedIntegrations: PublicHomeIntegration[] = []
|
|
21
|
+
protected static names: string[] = []
|
|
22
|
+
|
|
23
|
+
protected static async beforeEach(): Promise<void> {
|
|
24
|
+
await super.beforeEach()
|
|
25
|
+
|
|
26
|
+
this.fakedIntegrations = []
|
|
27
|
+
this.names = []
|
|
28
|
+
|
|
29
|
+
this.views.setController(
|
|
30
|
+
'google.add-home-integration-card',
|
|
31
|
+
SpyAddHomeIntegrationCard
|
|
32
|
+
)
|
|
33
|
+
this.views.setController('active-record-card', MockActiveRecordCard)
|
|
34
|
+
this.views.setController('google.root', SpyRootSkillView)
|
|
35
|
+
this.vc = this.views.Controller('google.root', {}) as SpyRootSkillView
|
|
36
|
+
|
|
37
|
+
await this.eventFaker.fakeListHomeIntegrations(() => {
|
|
38
|
+
return this.fakedIntegrations
|
|
39
|
+
})
|
|
40
|
+
|
|
41
|
+
await this.eventFaker.fakeDeleteHomeIntegration()
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
@test()
|
|
45
|
+
protected static async rendersACard() {
|
|
46
|
+
vcAssert.assertSkillViewRendersCard(this.vc, 'home-cloud-integrations')
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
@test()
|
|
50
|
+
protected static async cardRendersList() {
|
|
51
|
+
activeRecordCardAssert.skillViewRendersActiveRecordCard(this.vc)
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
@test()
|
|
55
|
+
protected static async requiresLogin() {
|
|
56
|
+
await vcAssert.assertLoginIsRequired(this.vc)
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
@test()
|
|
60
|
+
protected static async returnsAListOfIntegrations() {
|
|
61
|
+
const integration = this.seedIntegration()
|
|
62
|
+
await this.load()
|
|
63
|
+
this.assertRendersIntegrationRow(integration.id)
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
@test()
|
|
67
|
+
protected static async homeIntegrationsCardRendersExpectedButtons() {
|
|
68
|
+
buttonAssert.cardRendersButtons(this.homeIntegrationsCardVc, [
|
|
69
|
+
'instructions',
|
|
70
|
+
'add',
|
|
71
|
+
])
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
@test()
|
|
75
|
+
protected static async clickingAddIntegrationRendersDialog() {
|
|
76
|
+
await this.loadClickAddAndAssertRendersDialog()
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
@test()
|
|
80
|
+
protected static async callingOnDoneInAddCardHidesDialog() {
|
|
81
|
+
const { addCardVc, dialogVc } =
|
|
82
|
+
await this.loadClickAddAndAssertRendersDialog()
|
|
83
|
+
await addCardVc.simulateClickDone()
|
|
84
|
+
|
|
85
|
+
assert.isFalse(dialogVc.getIsVisible())
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
@test()
|
|
89
|
+
protected static async eachRowRendersDeleteButton() {
|
|
90
|
+
const integration = await this.seedOneIntegrationAndLoad()
|
|
91
|
+
|
|
92
|
+
this.homeIntegrationsCardVc.assertRowRendersButton(
|
|
93
|
+
integration.id,
|
|
94
|
+
'delete'
|
|
95
|
+
)
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
@test()
|
|
99
|
+
protected static async clickingDeleteButtonRendersAlert() {
|
|
100
|
+
await this.seedLoadClickDeleteAndAssertConfirm()
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
@test()
|
|
104
|
+
protected static async clickingDeleteAndConfirmingRemovesRow() {
|
|
105
|
+
const integration = await this.seedLoadClickDeleteAndConfirm()
|
|
106
|
+
this.homeIntegrationsCardVc.assertDoesNotRenderRow(integration.id)
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
@test()
|
|
110
|
+
protected static async doesNotRefreshListIfUserCancels() {
|
|
111
|
+
const int = await this.seedLoadClickDeleteAndDecline()
|
|
112
|
+
|
|
113
|
+
this.assertRendersIntegrationRow(int.id)
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
@test()
|
|
117
|
+
protected static async confirmingDeleteShouldEmitDeleteEvent() {
|
|
118
|
+
let passedTarget:
|
|
119
|
+
| DeleteHomeIntergrationTargetAndPayload['target']
|
|
120
|
+
| undefined
|
|
121
|
+
|
|
122
|
+
await this.eventFaker.fakeDeleteHomeIntegration(({ target }) => {
|
|
123
|
+
passedTarget = target
|
|
124
|
+
})
|
|
125
|
+
|
|
126
|
+
const integration = await this.seedLoadClickDeleteAndConfirm()
|
|
127
|
+
|
|
128
|
+
assert.isEqualDeep(passedTarget, {
|
|
129
|
+
integrationId: integration.id,
|
|
130
|
+
})
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
@test()
|
|
134
|
+
protected static async doesNotEmitEventIfDeclined() {
|
|
135
|
+
await eventFaker.makeEventThrow(
|
|
136
|
+
'google.delete-home-integration::v2025_02_08'
|
|
137
|
+
)
|
|
138
|
+
|
|
139
|
+
await this.seedLoadClickDeleteAndDecline()
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
private static async loadClickAddAndAssertRendersDialog() {
|
|
143
|
+
await this.load()
|
|
144
|
+
const dialogVc = await vcAssert.assertRendersDialog(this.vc, () =>
|
|
145
|
+
interactor.clickButton(this.homeIntegrationsCardVc, 'add')
|
|
146
|
+
)
|
|
147
|
+
|
|
148
|
+
const addCardVc = vcAssert.assertRendersAsInstanceOf(
|
|
149
|
+
dialogVc,
|
|
150
|
+
AddHomeIntegrationCardViewController
|
|
151
|
+
) as SpyAddHomeIntegrationCard
|
|
152
|
+
return { dialogVc, addCardVc }
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
private static async seedLoadClickDeleteAndConfirm() {
|
|
156
|
+
const { confirmVc, integration } =
|
|
157
|
+
await this.seedLoadClickDeleteAndAssertConfirm()
|
|
158
|
+
|
|
159
|
+
await confirmVc.accept()
|
|
160
|
+
|
|
161
|
+
return integration
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
private static async seedLoadClickDeleteAndDecline() {
|
|
165
|
+
const { confirmVc, integration } =
|
|
166
|
+
await this.seedLoadClickDeleteAndAssertConfirm()
|
|
167
|
+
|
|
168
|
+
const int = integration
|
|
169
|
+
|
|
170
|
+
await confirmVc.decline()
|
|
171
|
+
return int
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
private static assertRendersIntegrationRow(id: string) {
|
|
175
|
+
this.homeIntegrationsCardVc.assertRendersRow(id)
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
private static async seedLoadClickDeleteAndAssertConfirm() {
|
|
179
|
+
const integration = await this.seedOneIntegrationAndLoad()
|
|
180
|
+
|
|
181
|
+
const confirmVc = await vcAssert.assertRendersConfirm(this.vc, () =>
|
|
182
|
+
interactor.clickButtonInRow(this.listVc, integration.id, 'delete')
|
|
183
|
+
)
|
|
184
|
+
return { confirmVc, integration }
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
private static get listVc() {
|
|
188
|
+
return this.homeIntegrationsCardVc.getListVc()
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
private static async seedOneIntegrationAndLoad() {
|
|
192
|
+
const integration = this.seedIntegration()
|
|
193
|
+
await this.load()
|
|
194
|
+
return integration
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
private static seedIntegration() {
|
|
198
|
+
const integration: PublicHomeIntegration = {
|
|
199
|
+
description: generateId(),
|
|
200
|
+
id: generateId(),
|
|
201
|
+
name: generateId(),
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
this.fakedIntegrations.push(integration)
|
|
205
|
+
return integration
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
private static async load() {
|
|
209
|
+
await this.views.load(this.vc)
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
private static get homeIntegrationsCardVc() {
|
|
213
|
+
return this.vc.getHomeIntegrationsCardVc()
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
class SpyRootSkillView extends RootSkillViewController {
|
|
218
|
+
public getHomeIntegrationsCardVc() {
|
|
219
|
+
return this.activeRecordCardVc as MockActiveRecordCard
|
|
220
|
+
}
|
|
221
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { namesUtil } from '@sprucelabs/spruce-skill-utils'
|
|
2
|
+
|
|
3
|
+
export function generateExpectedInstanceTestContents(name: string) {
|
|
4
|
+
const pascal = namesUtil.toPascal(name)
|
|
5
|
+
const camel = namesUtil.toCamel(name)
|
|
6
|
+
|
|
7
|
+
return `import { fake } from '@sprucelabs/spruce-test-fixtures'
|
|
8
|
+
import AbstractSpruceTest, { test, suite, assert } from '@sprucelabs/test-utils'
|
|
9
|
+
|
|
10
|
+
@fake.login()
|
|
11
|
+
@suite()
|
|
12
|
+
export default class ${pascal}Test extends AbstractSpruceTest {
|
|
13
|
+
@test()
|
|
14
|
+
protected async canCreate${pascal}() {
|
|
15
|
+
const ${camel} = new ${pascal}()
|
|
16
|
+
assert.isTruthy(${camel})
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
@test()
|
|
20
|
+
protected async yourNextTest() {
|
|
21
|
+
assert.isTrue(false)
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
class ${pascal} {}`
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export function generateExpectedStaticTestContents(name: string) {
|
|
29
|
+
const pascal = namesUtil.toPascal(name)
|
|
30
|
+
const camel = namesUtil.toCamel(name)
|
|
31
|
+
|
|
32
|
+
return `import { fake } from '@sprucelabs/spruce-test-fixtures'
|
|
33
|
+
import AbstractSpruceTest, { test, assert } from '@sprucelabs/test-utils'
|
|
34
|
+
|
|
35
|
+
@fake.login()
|
|
36
|
+
export default class ${pascal}Test extends AbstractSpruceTest {
|
|
37
|
+
@test()
|
|
38
|
+
protected static async canCreate${pascal}() {
|
|
39
|
+
const ${camel} = new ${pascal}()
|
|
40
|
+
assert.isTruthy(${camel})
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
@test()
|
|
44
|
+
protected static async yourNextTest() {
|
|
45
|
+
assert.isTrue(false)
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
class ${pascal} {}`
|
|
50
|
+
}
|
|
@@ -47,7 +47,6 @@ export default class ResolvingVersionsTest extends AbstractSkillTest {
|
|
|
47
47
|
|
|
48
48
|
@test()
|
|
49
49
|
protected static async addsVersionFromPackageJsonWhenChoosingDifferentVersion() {
|
|
50
|
-
debugger
|
|
51
50
|
await this.resolveAndAssertChoices([
|
|
52
51
|
this.newVersionChoice,
|
|
53
52
|
this.buildVersionChoice('v2023_09_16'),
|
|
@@ -56,9 +55,8 @@ export default class ResolvingVersionsTest extends AbstractSkillTest {
|
|
|
56
55
|
|
|
57
56
|
@test()
|
|
58
57
|
protected static async doesNotAddVersionToChoicesIfDirMatchesVersion() {
|
|
59
|
-
debugger
|
|
60
58
|
this.createVersionDir('v2023_09_16')
|
|
61
|
-
|
|
59
|
+
|
|
62
60
|
await this.resolveAndAssertChoices([
|
|
63
61
|
this.newVersionChoice,
|
|
64
62
|
this.buildVersionChoice('v2023_09_16'),
|
|
@@ -26,7 +26,9 @@ export default class OrganizationStoreTest extends AbstractCliTest {
|
|
|
26
26
|
assert.isFalse(isInstalled)
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
-
@test(
|
|
29
|
+
@test.skip(
|
|
30
|
+
'conflicting with "InstallingASkillAtAnOrg which is deleting orgs'
|
|
31
|
+
)
|
|
30
32
|
protected static async canDeleteOrg() {
|
|
31
33
|
await this.FeatureFixture().installCachedFeatures('organizations')
|
|
32
34
|
|
|
@@ -68,7 +70,9 @@ export default class OrganizationStoreTest extends AbstractCliTest {
|
|
|
68
70
|
assert.isTrue(isInstalled)
|
|
69
71
|
}
|
|
70
72
|
|
|
71
|
-
@test(
|
|
73
|
+
@test.skip(
|
|
74
|
+
'is conflicting with "InstallingASkillAtAnOrg" which is deleting orgs'
|
|
75
|
+
)
|
|
72
76
|
protected static async canGetMyOrgs() {
|
|
73
77
|
await this.FeatureFixture().installCachedFeatures('organizations')
|
|
74
78
|
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { fake } from '@sprucelabs/spruce-test-fixtures'
|
|
2
|
+
import AbstractSpruceTest, {
|
|
3
|
+
test,
|
|
4
|
+
assert,
|
|
5
|
+
errorAssert,
|
|
6
|
+
} from '@sprucelabs/test-utils'
|
|
7
|
+
|
|
8
|
+
@fake.login()
|
|
9
|
+
export default class StaticTestFinderTest extends AbstractSpruceTest {
|
|
10
|
+
@test()
|
|
11
|
+
protected static async throwsWithMissing() {
|
|
12
|
+
const finder = StaticTestFinder.Finder()
|
|
13
|
+
const err = await assert.doesThrowAsync(() => finder.find())
|
|
14
|
+
errorAssert.assertError(err, 'MISSING_PARAMETERS', {
|
|
15
|
+
parameters: ['lookupDir'],
|
|
16
|
+
})
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
@test()
|
|
20
|
+
protected static async yourNextTest() {
|
|
21
|
+
assert.isTrue(false)
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
class StaticTestFinder {
|
|
26
|
+
public static Finder() {
|
|
27
|
+
return new this()
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
public async find() {
|
|
31
|
+
// assertOptions({}, ['lookupDir'])
|
|
32
|
+
}
|
|
33
|
+
}
|
package/src/__tests__/testDirsAndFiles/static_test_migration_1/src/__tests__/ShouldBeIgnored.ts
ADDED
|
File without changes
|
package/src/__tests__/testDirsAndFiles/static_test_migration_1/src/__tests__/StaticTest1.test.ts
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { fake } from '@sprucelabs/spruce-test-fixtures'
|
|
2
|
+
import AbstractSpruceTest, {
|
|
3
|
+
test,
|
|
4
|
+
assert,
|
|
5
|
+
errorAssert,
|
|
6
|
+
} from '@sprucelabs/test-utils'
|
|
7
|
+
|
|
8
|
+
@fake.login()
|
|
9
|
+
export default class StaticTestFinderTest extends AbstractSpruceTest {
|
|
10
|
+
@test()
|
|
11
|
+
protected static async throwsWithMissing() {
|
|
12
|
+
const finder = StaticTestFinder.Finder()
|
|
13
|
+
const err = await assert.doesThrowAsync(() => finder.find())
|
|
14
|
+
errorAssert.assertError(err, 'MISSING_PARAMETERS', {
|
|
15
|
+
parameters: ['lookupDir'],
|
|
16
|
+
})
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
@test()
|
|
20
|
+
protected static async yourNextTest() {
|
|
21
|
+
assert.isTrue(false)
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
class StaticTestFinder {
|
|
26
|
+
public static Finder() {
|
|
27
|
+
return new this()
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
public async find() {
|
|
31
|
+
// assertOptions({}, ['lookupDir'])
|
|
32
|
+
}
|
|
33
|
+
}
|
|
File without changes
|