Skip to content

Commit

Permalink
chore: Update E2E
Browse files Browse the repository at this point in the history
  • Loading branch information
DafyddLlyr committed Oct 17, 2023
1 parent 37a6da3 commit e8ebf6e
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 50 deletions.
2 changes: 1 addition & 1 deletion e2e/tests/api-driven/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
},
"dependencies": {
"@cucumber/cucumber": "^9.3.0",
"@opensystemslab/planx-core": "git+https://github.com/theopensystemslab/planx-core#3a85966",
"@opensystemslab/planx-core": "git+https://github.com/theopensystemslab/planx-core#2fcb488",
"axios": "^1.4.0",
"dotenv": "^16.3.1",
"dotenv-expand": "^10.0.0",
Expand Down
29 changes: 9 additions & 20 deletions e2e/tests/api-driven/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion e2e/tests/api-driven/src/permissions/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ export const setup = async () => {
return world;
};

export type GQLQueryResult = unknown[] | Record<"returning", unknown[]> | null;

export const performGQLQuery = async ({
world,
action,
Expand All @@ -66,7 +68,7 @@ export const performGQLQuery = async ({
const query = queries[table][action];
const variables = buildVariables(query, world);
const client = (await getClient(world.activeUserEmail)).client;
const { result } = await client.request<Record<"result", any>>(
const { result } = await client.request<Record<"result", GQLQueryResult>>(
query,
variables,
);
Expand Down
3 changes: 2 additions & 1 deletion e2e/tests/api-driven/src/permissions/steps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { strict as assert } from "node:assert";
import { getUser } from "../globalHelpers";
import {
Action,
GQLQueryResult,
Table,
addUserToTeam,
cleanup,
Expand All @@ -28,7 +29,7 @@ export class CustomWorld extends World {
activeUserEmail!: string;

error?: Error = undefined;
result: unknown[] | Record<"returning", unknown[]> | null = null;
result: GQLQueryResult = null;
}

Before<CustomWorld>("@team-admin-permissions", async function () {
Expand Down
2 changes: 1 addition & 1 deletion e2e/tests/ui-driven/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"postinstall": "./install-dependencies.sh"
},
"dependencies": {
"@opensystemslab/planx-core": "git+https://github.com/theopensystemslab/planx-core#3a85966",
"@opensystemslab/planx-core": "git+https://github.com/theopensystemslab/planx-core#2fcb488",
"axios": "^1.4.0",
"dotenv": "^16.3.1",
"eslint": "^8.44.0",
Expand Down
29 changes: 9 additions & 20 deletions e2e/tests/ui-driven/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 6 additions & 6 deletions e2e/tests/ui-driven/src/context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export interface Context {
team: {
id?: number;
name: string;
slug?: string;
slug: string;
logo: string;
primaryColor: string;
homepage: string;
Expand Down Expand Up @@ -50,13 +50,13 @@ export const contextDefaults: Context = {
export async function setUpTestContext(
initialContext: Context,
): Promise<Context> {
const core = getCoreDomainClient();
const $admin = getCoreDomainClient();
const context: Context = { ...initialContext };
if (context.user) {
context.user.id = await core.createUser(context.user);
context.user.id = await $admin.user.create(context.user);
}
if (context.team) {
context.team.id = await core.createTeam({
context.team.id = await $admin.team.create({
slug: context.team.slug,
name: context.team.name,
logo: context.team.logo,
Expand All @@ -71,12 +71,12 @@ export async function setUpTestContext(
context.team?.id &&
context.user?.id
) {
context.flow.id = await core.createFlow({
context.flow.id = await $admin.flow.create({
slug: context.flow.slug,
teamId: context.team.id,
data: context.flow!.data!,
});
context.flow.publishedId = await core.publishFlow({
context.flow.publishedId = await $admin.flow.publish({
flow: {
id: context.flow.id,
data: context.flow!.data!,
Expand Down

0 comments on commit e8ebf6e

Please sign in to comment.