Skip to content

Commit

Permalink
lint:fix
Browse files Browse the repository at this point in the history
  • Loading branch information
RODO94 committed Nov 7, 2024
1 parent 69b14b4 commit dda6a26
Show file tree
Hide file tree
Showing 4 changed files with 79 additions and 54 deletions.
72 changes: 36 additions & 36 deletions e2e/tests/api-driven/src/demo-workspace/helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,7 @@ export const createFlow = async (client, args) => {
gql`
mutation InsertFlow($teamId: Int!, $slug: String!, $name: String!) {
flow: insert_flows_one(
object: {
team_id: $teamId
slug: $slug
name: $name
}
object: { team_id: $teamId, slug: $slug, name: $name }
) {
id
slug
Expand Down Expand Up @@ -258,7 +254,9 @@ export async function getTeamAndFlowsBySlug(client, slug) {
}

export async function getFlowBySlug(client, slug) {
const {flows:[flow]} = await client.request(
const {
flows: [flow],
} = await client.request(
gql`
query getFlowBySlug($slug: String) {
flows(where: { slug: { _eq: $slug } }) {
Expand All @@ -276,7 +274,7 @@ export async function getFlowBySlug(client, slug) {
}

export async function updateFlow(client, flowId: UUID) {
const {update_flows_by_pk: response} = await client.request(
const { update_flows_by_pk: response } = await client.request(
gql`
mutation updateFlow($flowId: uuid!) {
result: update_flows_by_pk(
Expand All @@ -294,13 +292,13 @@ export async function updateFlow(client, flowId: UUID) {
}

export async function deleteFlow(client, flowId: UUID) {
const {delete_flows_by_pk: response} = await client.request(
const { delete_flows_by_pk: response } = await client.request(
gql`
mutation MyMutation($flowId: uuid!) {
delete_flows_by_pk(id: $flowId) {
id
}
}
mutation MyMutation($flowId: uuid!) {
delete_flows_by_pk(id: $flowId) {
id
}
}
`,

{ flowId: flowId },
Expand All @@ -310,28 +308,30 @@ mutation MyMutation($flowId: uuid!) {

export async function updateTeamSettings(client, teamId: number) {
try {


const {update_team_settings: response} = await client.request(
gql`
mutation updateTeamSettings($teamId: Int!) {
update_team_settings(where: {team_id: {_eq: $teamId}}, _set: {homepage: "newpage.com", submission_email: "[email protected]"}) {
returning {
team_id
submission_email
homepage
}
const { update_team_settings: response } = await client.request(
gql`
mutation updateTeamSettings($teamId: Int!) {
update_team_settings(
where: { team_id: { _eq: $teamId } }
_set: {
homepage: "newpage.com"
submission_email: "[email protected]"
}
) {
returning {
team_id
submission_email
homepage
}
}
}
`,
{
teamId: teamId,
},
);
return response;
} catch (error) {
return false;
}
}
`, {
teamId: teamId
}
);
return response;
} catch (error) {
return false
}
}



Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export class CustomWorld extends World {
adminFlowSlug!: string;
demoTeamsArray!: Team[];
currentTeamId!: number;
teamFlows!: { creator_id: number, id: UUID }[];
teamFlows!: { creator_id: number; id: UUID }[];
}

Before("@demo-user-permissions", async function () {
Expand Down Expand Up @@ -111,15 +111,18 @@ Given<CustomWorld>(
});
return flowId;
}
return "no creator id"
})
return "no creator id";
}),
);

assert.ok(
Boolean(newFlowArray.length === 5),
"Flows have not been added correctly",
);
assert.ok(Boolean(!newFlowArray.includes(false)), `NewFlowArray is returning: ${newFlowArray}`);
assert.ok(
Boolean(!newFlowArray.includes(false)),
`NewFlowArray is returning: ${newFlowArray}`,
);
},
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { CustomWorld } from "./background_steps";
When<CustomWorld>("I am in the {string} team", async function (this, string) {
// Write code here that turns the phrase above into concrete actions
const team = await getTeamAndFlowsBySlug(this.demoClient, string);
this.currentTeamId = team.id
this.currentTeamId = team.id;
this.teamFlows = team.flows;
assert.equal(string, team.slug, "Error retrieving the correct team");
});
Expand Down
48 changes: 35 additions & 13 deletions e2e/tests/api-driven/src/demo-workspace/steps/verification_steps.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
import { Then } from "@cucumber/cucumber";
import { CustomWorld } from "./background_steps";
import { strict as assert } from "node:assert";
import { createFlow, deleteFlow, getFlowBySlug, getTeams, updateFlow, updateTeamSettings } from "../helper";
import {
createFlow,
deleteFlow,
getFlowBySlug,
getTeams,

Check warning on line 8 in e2e/tests/api-driven/src/demo-workspace/steps/verification_steps.ts

View workflow job for this annotation

GitHub Actions / E2E tests

'getTeams' is defined but never used. Allowed unused vars must match /^_/u
updateFlow,
updateTeamSettings,
} from "../helper";

Then<CustomWorld>("I should only see my own flows", async function (this) {
assert.equal(
Expand Down Expand Up @@ -60,19 +67,34 @@ Then<CustomWorld>(
"I should be able to {string} the flow",
async function (this, string) {
const demoFlow = await getFlowBySlug(this.demoClient, this.demoFlowSlug);
const hasSucceeded = await string === "update" ? updateFlow(this.demoClient, demoFlow.id) : deleteFlow(this.demoClient, demoFlow.id)

assert.ok(hasSucceeded, `Cannot ${string} the flow `)
const hasSucceeded =
(await string) === "update"
? updateFlow(this.demoClient, demoFlow.id)
: deleteFlow(this.demoClient, demoFlow.id);

assert.ok(hasSucceeded, `Cannot ${string} the flow `);
},
);

Then<CustomWorld>("I should not have access to modify the flow", async function (this) {
const canUpdate = await updateFlow(this.demoClient, this.teamFlows[0].id)
const canDelete = await deleteFlow(this.demoClient, this.teamFlows[0].id)
assert.ok(!canUpdate && !canDelete, "Flow can be modified by the demo user")
});
Then<CustomWorld>(
"I should not have access to modify the flow",
async function (this) {
const canUpdate = await updateFlow(this.demoClient, this.teamFlows[0].id);
const canDelete = await deleteFlow(this.demoClient, this.teamFlows[0].id);
assert.ok(
!canUpdate && !canDelete,
"Flow can be modified by the demo user",
);
},
);

Then<CustomWorld>("I should not have access to team settings", async function (this) {
const canUpdateSettings = await updateTeamSettings(this.demoClient, this.currentTeamId)
assert.ok(!canUpdateSettings, "Demo User can update the team settings")
});
Then<CustomWorld>(
"I should not have access to team settings",
async function (this) {
const canUpdateSettings = await updateTeamSettings(
this.demoClient,
this.currentTeamId,
);
assert.ok(!canUpdateSettings, "Demo User can update the team settings");
},
);

0 comments on commit dda6a26

Please sign in to comment.