diff --git a/e2e/tests/api-driven/src/demo-workspace/demoUser.feature b/e2e/tests/api-driven/src/demo-workspace/demoUser.feature index faff9ff96e..fc59e23b9b 100644 --- a/e2e/tests/api-driven/src/demo-workspace/demoUser.feature +++ b/e2e/tests/api-driven/src/demo-workspace/demoUser.feature @@ -26,7 +26,7 @@ And I am a demoUser @demo-user-permissions - Scenario: I can only view my own flows + Scenario Outline: I can only view my own flows When I am in the "" team Then I should only see my own flows But I should not see flows that I have not created @@ -39,7 +39,7 @@ Scenario Outline: I can only view specific teams When I query the teams table Then I can access the teams with slug: "" - But I should not access the Other Team + But I should not be able to access the Other Team Examples: | SLUG | @@ -51,8 +51,8 @@ @demo-user-permissions Scenario Outline: Creating a new flow When I insert a flow into the team: "" - Then I should not succeed - But I should succeed in the Demo team + Then I should not be able to create a flow + But I should be able to create a flow in the Demo team Examples: | TEAM | diff --git a/e2e/tests/api-driven/src/demo-workspace/helper.ts b/e2e/tests/api-driven/src/demo-workspace/helper.ts index 94b0e57cb3..e3a203e035 100644 --- a/e2e/tests/api-driven/src/demo-workspace/helper.ts +++ b/e2e/tests/api-driven/src/demo-workspace/helper.ts @@ -28,12 +28,11 @@ export const cleanup = async () => { export const checkTeamsExist = async ( teamArray: DataTableArray, ): Promise => { - const existenceArray = await Promise.all( - teamArray.map(async (team: DataTableRecord) => { - const teamObj = await $admin.team.getBySlug(team.slug); - return teamObj; - }), - ); + const existenceArray: Team[] = []; + for (const team of teamArray) { + const teamObj = await $admin.team.getBySlug(team.slug); + existenceArray.push(teamObj); + } return existenceArray; }; diff --git a/e2e/tests/api-driven/src/demo-workspace/steps/navigation_steps.ts b/e2e/tests/api-driven/src/demo-workspace/steps/navigation_steps.ts index edc8fea0d0..dbc9248802 100644 --- a/e2e/tests/api-driven/src/demo-workspace/steps/navigation_steps.ts +++ b/e2e/tests/api-driven/src/demo-workspace/steps/navigation_steps.ts @@ -4,16 +4,16 @@ import { strict as assert } from "node:assert"; import { getFlowBySlug, getTeamAndFlowsBySlug, getTeams } from "../helper"; import { CustomWorld } from "./background_steps"; -When("I am in the {string} team", async function (this, string) { - const team = await getTeamAndFlowsBySlug(this.demoClient, string); +When("I am in the {string} team", async function (this, teamSlug) { + const team = await getTeamAndFlowsBySlug(this.demoClient, teamSlug); this.currentTeamId = team.id; this.teamFlows = team.flows; - if (string !== "demo") { + if (teamSlug !== "demo") { this.adminFlowSlug = team.flows[0].slug; } else { this.demoFlowSlug = team.flows[0].slug; } - assert.equal(string, team.slug, "Error retrieving the correct team"); + assert.equal(teamSlug, team.slug, "Error retrieving the correct team"); }); When("I query the teams table", async function (this) { @@ -24,8 +24,8 @@ When("I query the teams table", async function (this) { When( "I insert a flow into the team: {string}", - async function (this, string) { - const team = await $admin.team.getBySlug(string); + async function (this, teamSlug) { + const team = await $admin.team.getBySlug(teamSlug); this.insertFlowTeamId = team.id; }, ); diff --git a/e2e/tests/api-driven/src/demo-workspace/steps/verification_steps.ts b/e2e/tests/api-driven/src/demo-workspace/steps/verification_steps.ts index dbdd10709c..d24f727f46 100644 --- a/e2e/tests/api-driven/src/demo-workspace/steps/verification_steps.ts +++ b/e2e/tests/api-driven/src/demo-workspace/steps/verification_steps.ts @@ -30,36 +30,42 @@ Then( Then( "I can access the teams with slug: {string}", - async function (this, string) { + async function (this, teamSlug) { const canAccessTeam = this.demoTeamsArray.find( - (team) => team.slug === string, + (team) => team.slug === teamSlug, ); assert.ok(canAccessTeam, "Team is not in the array"); }, ); -Then("I should not access the Other Team", async function (this) { - const cannotAccessOtherTeam = this.demoTeamsArray.find( - (team) => team.slug !== this.otherTeam?.slug, - ); - assert.ok(cannotAccessOtherTeam, "Other Team is in the array"); -}); +Then( + "I should not be able to access the Other Team", + async function (this) { + const cannotAccessOtherTeam = this.demoTeamsArray.find( + (team) => team.slug !== this.otherTeam?.slug, + ); + assert.ok(cannotAccessOtherTeam, "Other Team is in the array"); + }, +); -Then("I should not succeed", async function (this) { - let hasSucceeded: Flow | false; - try { - hasSucceeded = await createFlow(this.demoClient, { - name: "Bad flow", - slug: "bad-flow", - teamId: this.insertFlowTeamId, - }); - } catch (error) { - hasSucceeded = false; - } - assert.ok(!hasSucceeded, "Flow was able to be created on this team"); -}); +Then( + "I should not be able to create a flow", + async function (this) { + let hasSucceeded: Flow | false; + try { + hasSucceeded = await createFlow(this.demoClient, { + name: "Bad flow", + slug: "bad-flow", + teamId: this.insertFlowTeamId, + }); + } catch (error) { + hasSucceeded = false; + } + assert.ok(!hasSucceeded, "Flow was able to be created on this team"); + }, +); -Then("I should succeed in the Demo team", async function () { +Then("I should be able to create a flow in the Demo team", async function () { const hasSucceeded = await createFlow(this.demoClient, { name: "Good flow", slug: "good-flow", @@ -79,14 +85,14 @@ Then("I should be able to see a flow", async function (this) { Then( "I should be able to {string} the flow", - async function (this, string) { + async function (this, action) { const demoFlow = await getFlowBySlug(this.demoClient, this.demoFlowSlug); const hasSucceeded = - (await string) === "update" + (await action) === "update" ? updateFlow(this.demoClient, demoFlow.id) : deleteFlow(this.demoClient, demoFlow.id); - assert.ok(hasSucceeded, `Cannot ${string} the flow `); + assert.ok(hasSucceeded, `Cannot ${action} the flow `); }, ); diff --git a/e2e/tests/api-driven/src/jwt.ts b/e2e/tests/api-driven/src/jwt.ts index 02c1e49f72..3b80d47860 100644 --- a/e2e/tests/api-driven/src/jwt.ts +++ b/e2e/tests/api-driven/src/jwt.ts @@ -31,7 +31,7 @@ const getAllowedRolesForUser = (user: User): Role[] => { const teamRoles = user.teams.map((teamRole) => teamRole.role); const allowedRoles: Role[] = [ "public", // Allow public access - ...teamRoles, // User specif ic roles + ...teamRoles, // User specific roles ]; if (user.isPlatformAdmin) allowedRoles.push("platformAdmin");