Skip to content

Commit

Permalink
setup cucumber demo tests
Browse files Browse the repository at this point in the history
add new scenarios to feature file

revert ui-driven test changes

update feature with new tests

add step structure and helper
  • Loading branch information
RODO94 committed Nov 5, 2024
1 parent c40c979 commit df3acc9
Show file tree
Hide file tree
Showing 8 changed files with 190 additions and 123 deletions.
95 changes: 95 additions & 0 deletions e2e/tests/api-driven/src/demo-workspace/demoUser.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
Feature: Demo user access

Background:
Given I am a user with a demoUser role
And I have two users in the database:
| id | first_name | last_name | email |
| 1 | Demo | User | demo.user@email.com |
| 2 | Nota | Demo | nota.demo@email.com |

And I have the following teams in the database:
| id | name | slug |
| 1 | Open Systems Lab | open-systems-lab |
| 29 | Templates | templates |
| 30 | Open Digital Planning | open-digital-planning |
| 32 | Demo | demo |
| 45 | Other Team | other-team |

And I have the following flows in the database:
| id | creator_id | name | team_id |
| 1 | 1 | Test Flow 1 | 32 |
| 2 | 1 | Test Flow 2 | 32 |
| 3 | 2 | Other Flow | 45 |

@demo-user-permissions
Scenario: I can only view my own flows
When I am in the Demo team
Then I should only see flows with ids "1, 2"
And I should not see flow with id "3"

@demo-user-permissions
Scenario Outline: I can only view specific teams
When I am on the Teams page
Then I can only see team with id: "<ID>"

Examples:
| ID |
| 1 |
| 29 |
| 30 |
| 32 |

@demo-user-permissions
Scenario: Creating a new flow in the Demo team
When I am in the Demo team
Then I should be able to create a flow

@demo-user-permissions
Scenario Outline: Creating a new flow in other teams
When I am in the "<TEAM>" team
Then I should not be able to create a flow

Examples:
| TEAM |
| templates |
| open-systems-lab |
| open-digital-planning |

@demo-user-permissions
Scenario Outline: Actioning my own flows
When I am in the Demo team
And I am on my own flow
Then I should be able to "<ACTION>" the flow

Examples:
| ACTION |
| update |
| delete |

@demo-user-permissions
Scenario Outline: Actioning flows in other teams
When I am in the "<TEAM>" team
And I want to edit a flow that I did not create
Then I should not have access to modify the flow

Examples:
| TEAM |
| templates |
| open-systems-lab |
| open-digital-planning |

@demo-user-permissions
Scenario: Accessing flow settings
When I am on my own flow
Then I should have access to flow settings

@demo-user-permissions
Scenario Outline: Editing team settings
When I am in the "<TEAM>" team
Then I should not have access to team settings

Examples:
| TEAM |
| templates |
| open-systems-lab |
| open-digital-planning |
Empty file.
22 changes: 22 additions & 0 deletions e2e/tests/api-driven/src/demo-workspace/steps/background_steps.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { Given } from "@cucumber/cucumber";

Given('I am a user with a demoUser role', async function () {
// Write code here that turns the phrase above into concrete actions
return 'pending';
});

Given('I have two users in the database:', async function (dataTable) {

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

View workflow job for this annotation

GitHub Actions / E2E tests

'dataTable' is defined but never used. Allowed unused args must match /^_/u
// Write code here that turns the phrase above into concrete actions
return 'pending';
});

Given('I have the following teams in the database:', async function (dataTable) {

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

View workflow job for this annotation

GitHub Actions / E2E tests

'dataTable' is defined but never used. Allowed unused args must match /^_/u
// Write code here that turns the phrase above into concrete actions
return 'pending';
});


Given('I have the following flows in the database:', async function (dataTable) {

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

View workflow job for this annotation

GitHub Actions / E2E tests

'dataTable' is defined but never used. Allowed unused args must match /^_/u
// Write code here that turns the phrase above into concrete actions
return 'pending';
});
26 changes: 26 additions & 0 deletions e2e/tests/api-driven/src/demo-workspace/steps/navigation_steps.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { When } from "@cucumber/cucumber";

When('I am on the Teams page', async function () {
// Write code here that turns the phrase above into concrete actions
return 'pending';
});

When('I am in the Demo team', async function () {
// Write code here that turns the phrase above into concrete actions
return 'pending';
});

When('I am in the {string} team', async function (string) {

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

View workflow job for this annotation

GitHub Actions / E2E tests

'string' is defined but never used. Allowed unused args must match /^_/u
// Write code here that turns the phrase above into concrete actions
return 'pending';
});

When('I am on my own flow', async function () {
// Write code here that turns the phrase above into concrete actions
return 'pending';
});

When('I want to edit a flow that I did not create', async function () {
// Write code here that turns the phrase above into concrete actions
return 'pending';
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import { Then } from "@cucumber/cucumber";

Then('I should be able to create a flow', async function () {
// Write code here that turns the phrase above into concrete actions
return 'pending';
});

Then('I should not be able to create a flow', async function () {
// Write code here that turns the phrase above into concrete actions
return 'pending';
});

Then('I should have access to flow settings', async function () {
// Write code here that turns the phrase above into concrete actions
return 'pending';
});


Then('I should not have access to team settings', async function () {
// Write code here that turns the phrase above into concrete actions
return 'pending';
});

Then('I should not have access to modify the flow', async function () {
// Write code here that turns the phrase above into concrete actions
return 'pending'});

Then('I should be able to {string} the flow', async function (string) {

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

View workflow job for this annotation

GitHub Actions / E2E tests

'string' is defined but never used. Allowed unused args must match /^_/u
// Write code here that turns the phrase above into concrete actions
return 'pending';
});

Then('I can only see team with id: {string}', async function (string) {

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

View workflow job for this annotation

GitHub Actions / E2E tests

'string' is defined but never used. Allowed unused args must match /^_/u
// Write code here that turns the phrase above into concrete actions
return 'pending';
});

Then('I should only see flows with ids {string}', async function (string) {

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

View workflow job for this annotation

GitHub Actions / E2E tests

'string' is defined but never used. Allowed unused args must match /^_/u
// Write code here that turns the phrase above into concrete actions
return 'pending';
});


Then('I should not see flow with id {string}', async function (string) {

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

View workflow job for this annotation

GitHub Actions / E2E tests

'string' is defined but never used. Allowed unused args must match /^_/u
// Write code here that turns the phrase above into concrete actions
return 'pending';
});
74 changes: 0 additions & 74 deletions e2e/tests/ui-driven/src/demo-space/demo-login.spec.ts

This file was deleted.

22 changes: 0 additions & 22 deletions e2e/tests/ui-driven/src/helpers/context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,28 +46,6 @@ export const contextDefaults: Context = {
},
};

export const demoContext: Context = {
user: {
firstName: "Demo",
lastName: "demo",
email: "[email protected]",
isPlatformAdmin: false,
},
team: {
name: "E2E Test Team",
slug: "E2E",
theme: {
logo: "https://raw.githubusercontent.com/theopensystemslab/planx-team-logos/main/planx-testing.svg",
primaryColour: "#444444",
},
settings: {
homepage: "planx.uk",
submissionEmail: "[email protected]",
},
},
};


export async function setUpTestContext(
initialContext: Context,
): Promise<Context> {
Expand Down
27 changes: 0 additions & 27 deletions e2e/tests/ui-driven/src/helpers/globalHelpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,33 +69,6 @@ export async function createAuthenticatedSession({
return page;
}

export async function createAuthenticatedDemoSession({
browser,
userId,
}: {
browser: Browser;
userId: number;
}): Promise<Page> {
const browserContext = await browser.newContext();
const page = await browserContext.newPage();
const token = generateAuthenticationDemoToken(`${userId}`);
await browserContext.addCookies([
{
name: "jwt",
domain: "localhost",
path: "/",
value: token,
},
{
name: "auth",
domain: "localhost",
path: "/",
value: JSON.stringify({ loggedIn: true }),
},
]);
return page;
}

export async function setFeatureFlag(page: Page, featureFlag: string) {
await page.addInitScript(
(featureFlag: string) =>
Expand Down

0 comments on commit df3acc9

Please sign in to comment.