-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
18 changed files
with
108 additions
and
109 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,33 +4,12 @@ import { sign } from "jsonwebtoken"; | |
import assert from "node:assert"; | ||
import { log } from "./globalHelpers"; | ||
import { $admin } from "../../../api-driven/src/client"; | ||
import { Flow, TestContext } from "./types"; | ||
|
||
type NewTeam = Parameters<CoreDomainClient["team"]["create"]>[0]; | ||
|
||
export interface Flow { | ||
id?: string; | ||
publishedId?: number; | ||
slug: string; | ||
name: string; | ||
data?: object; | ||
} | ||
|
||
export interface Context { | ||
user: { | ||
id?: number; | ||
firstName: string; | ||
lastName: string; | ||
email: string; | ||
isPlatformAdmin: boolean; | ||
}; | ||
team: { id?: number } & NewTeam; | ||
flow?: Flow; | ||
externalPortalFlow?:Flow; | ||
sessionIds?: string[]; | ||
} | ||
|
||
export const contextDefaults: Context = { | ||
export const contextDefaults: TestContext = { | ||
user: { | ||
id: 0, | ||
firstName: "Test", | ||
lastName: "Test", | ||
email: "[email protected]", | ||
|
@@ -51,10 +30,10 @@ export const contextDefaults: Context = { | |
}; | ||
|
||
export async function setUpTestContext( | ||
initialContext: Context, | ||
): Promise<Context> { | ||
initialContext: TestContext, | ||
): Promise<TestContext> { | ||
const $admin = getCoreDomainClient(); | ||
const context: Context = { ...initialContext }; | ||
const context: TestContext = { ...initialContext }; | ||
if (context.user) { | ||
context.user.id = await $admin.user.create(context.user); | ||
} | ||
|
@@ -96,17 +75,7 @@ export async function setUpTestContext( | |
return context; | ||
} | ||
|
||
export const externalPortalServiceProps = { | ||
name: "An External Portal Service", | ||
slug: "an-external-portal-service", | ||
}; | ||
|
||
export const externalPortalFlowData = { | ||
title: "Is this an External Portal?", | ||
answers: ["It is an external portal", "No it is not an External Portal"], | ||
}; | ||
|
||
export async function tearDownTestContext(context: Context) { | ||
export async function tearDownTestContext(context: TestContext) { | ||
const adminGQLClient = getGraphQLClient(); | ||
if (context.flow || context.externalPortalFlow) { | ||
await $admin.flow._destroyAll() | ||
|
@@ -268,7 +237,7 @@ async function deleteFlow(adminGQLClient: GraphQLClient, flow: Flow) { | |
} | ||
} | ||
|
||
async function deleteUser(adminGQLClient: GraphQLClient, context: Context) { | ||
async function deleteUser(adminGQLClient: GraphQLClient, context: TestContext) { | ||
if (context.user?.id) { | ||
log(`deleting user ${context.user?.id}`); | ||
await adminGQLClient.request( | ||
|
@@ -305,7 +274,7 @@ async function deleteUser(adminGQLClient: GraphQLClient, context: Context) { | |
} | ||
} | ||
|
||
async function deleteTeam(adminGQLClient: GraphQLClient, context: Context) { | ||
async function deleteTeam(adminGQLClient: GraphQLClient, context: TestContext) { | ||
if (context.team?.id) { | ||
log(`deleting team ${context.team?.id}`); | ||
await adminGQLClient.request( | ||
|
@@ -342,7 +311,7 @@ async function deleteTeam(adminGQLClient: GraphQLClient, context: Context) { | |
} | ||
} | ||
|
||
async function setupGovPaySecret($admin: CoreDomainClient, context: Context) { | ||
async function setupGovPaySecret($admin: CoreDomainClient, context: TestContext) { | ||
try { | ||
await $admin.client.request( | ||
gql` | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
|
||
export const serviceProps = { | ||
name: "A Test Service", | ||
slug: "a-test-service", | ||
}; | ||
|
||
export const externalPortalServiceProps = { | ||
name: "An External Portal Service", | ||
slug: "an-external-portal-service", | ||
}; | ||
|
||
export const externalPortalFlowData = { | ||
title: "Is this an External Portal?", | ||
answers: ["It is an external portal", "No it is not an External Portal"], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { CoreDomainClient } from "@opensystemslab/planx-core"; | ||
import { User } from "@opensystemslab/planx-core/dist/types"; | ||
|
||
|
||
type NewTeam = Parameters<CoreDomainClient["team"]["create"]>[0]; | ||
|
||
export interface Flow { | ||
id?: string; | ||
publishedId?: number; | ||
slug: string; | ||
name: string; | ||
data?: object; | ||
} | ||
|
||
|
||
export interface TestContext { | ||
user: Omit<User, "teams">; | ||
team: { id?: number } & NewTeam; | ||
flow?: Flow; | ||
externalPortalFlow?:Flow; | ||
sessionIds?: string[]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.