Add failing test.

This commit is contained in:
Sam Rose 2025-02-05 15:24:54 +00:00
parent 5982ca739f
commit 6ad9ebe63c
No known key found for this signature in database
2 changed files with 38 additions and 9 deletions

View File

@ -31,7 +31,7 @@ describe("cron trigger", () => {
}) })
.save() .save()
await config.publish() await config.api.application.publish(config.getAppId())
expect(await queue.getCompletedCount()).toEqual(1) expect(await queue.getCompletedCount()).toEqual(1)
@ -42,4 +42,21 @@ describe("cron trigger", () => {
} }
expect(repeat.cron).toEqual("* * * * *") expect(repeat.cron).toEqual("* * * * *")
}) })
it("should fail if the cron expression is invalid", async () => {
await createAutomationBuilder({ config })
.cron({ cron: "* * * * * *" })
.serverLog({
text: "Hello, world!",
})
.save()
await config.api.application.publish(config.getAppId(), {
status: 500,
body: {
message:
'Deployment Failed: Invalid automation CRON "* * * * * *" - Expected 5 values, but got 6.',
},
})
})
}) })

View File

@ -33,7 +33,10 @@ export class ApplicationAPI extends TestAPI {
await this._delete(`/api/applications/${appId}`, { expectations }) await this._delete(`/api/applications/${appId}`, { expectations })
} }
publish = async (appId: string): Promise<PublishResponse> => { publish = async (
appId: string,
expectations?: Expectations
): Promise<PublishResponse> => {
return await this._post<PublishResponse>( return await this._post<PublishResponse>(
`/api/applications/${appId}/publish`, `/api/applications/${appId}/publish`,
{ {
@ -42,14 +45,16 @@ export class ApplicationAPI extends TestAPI {
headers: { headers: {
[constants.Header.APP_ID]: appId, [constants.Header.APP_ID]: appId,
}, },
expectations,
} }
) )
} }
unpublish = async (appId: string): Promise<void> => { unpublish = async (
await this._post(`/api/applications/${appId}/unpublish`, { appId: string,
expectations: { status: 200 }, expectations?: Expectations
}) ): Promise<void> => {
await this._post(`/api/applications/${appId}/unpublish`, { expectations })
} }
sync = async ( sync = async (
@ -144,13 +149,20 @@ export class ApplicationAPI extends TestAPI {
}) })
} }
fetch = async ({ status }: { status?: AppStatus } = {}): Promise<App[]> => { fetch = async (
{ status }: { status?: AppStatus } = {},
expectations?: Expectations
): Promise<App[]> => {
return await this._get<App[]>("/api/applications", { return await this._get<App[]>("/api/applications", {
query: { status }, query: { status },
expectations,
}) })
} }
addSampleData = async (appId: string): Promise<void> => { addSampleData = async (
await this._post(`/api/applications/${appId}/sample`) appId: string,
expectations?: Expectations
): Promise<void> => {
await this._post(`/api/applications/${appId}/sample`, { expectations })
} }
} }