Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add External Portals to E2E ui-driven tests #4005

Merged
merged 17 commits into from
Dec 2, 2024
Merged
4 changes: 2 additions & 2 deletions e2e/tests/ui-driven/src/create-flow-with-geospatial.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,15 +77,15 @@ test.describe("Flow creation, publish and preview", () => {
userId: context.user!.id!,
});
// publish flow
await navigateToService(page, serviceProps.slug)
await navigateToService(page, serviceProps.slug);
await publishService(page);

let previewLink = page.getByRole("link", {
name: "Open published service",
});
await expect(previewLink).toBeVisible();

await navigateToService(page, serviceProps.slug)
await navigateToService(page, serviceProps.slug);
await turnServiceOnline(page);

// Exit back to main Editor page
Expand Down
17 changes: 11 additions & 6 deletions e2e/tests/ui-driven/src/helpers/context.ts
RODO94 marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

export const contextDefaults: TestContext = {
user: {
id:0,
id: 0,
firstName: "Test",
lastName: "Test",
email: "[email protected]",
Expand All @@ -34,8 +34,13 @@
): Promise<TestContext> {
const context: TestContext = { ...initialContext };
if (context.user) {
const {firstName, lastName, email, isPlatformAdmin} = context.user
context.user.id = await $admin.user.create({firstName, lastName, email, isPlatformAdmin});
const { firstName, lastName, email, isPlatformAdmin } = context.user;
context.user.id = await $admin.user.create({
firstName,
lastName,
email,
isPlatformAdmin,
});
}
if (context.team) {
context.team.id = await $admin.team.create({
Expand Down Expand Up @@ -76,9 +81,9 @@
}

export async function tearDownTestContext() {
await $admin.flow._destroyAll();
await $admin.user._destroyAll()
await $admin.team._destroyAll()
await $admin.flow._destroyAll();
await $admin.user._destroyAll();
await $admin.team._destroyAll();
}

export function generateAuthenticationToken(userId: string) {
Expand Down Expand Up @@ -154,7 +159,7 @@
}
}

async function deleteSession(adminGQLClient: GraphQLClient, context) {

Check warning on line 162 in e2e/tests/ui-driven/src/helpers/context.ts

View workflow job for this annotation

GitHub Actions / E2E tests

'deleteSession' is defined but never used. Allowed unused vars must match /^_/u
if (context.sessionIds) {
for (const sessionId of context.sessionIds) {
await adminGQLClient.request(
Expand All @@ -181,7 +186,7 @@
}
}

async function deletePublishedFlow(adminGQLClient: GraphQLClient, flow: Flow) {

Check warning on line 189 in e2e/tests/ui-driven/src/helpers/context.ts

View workflow job for this annotation

GitHub Actions / E2E tests

'deletePublishedFlow' is defined but never used. Allowed unused vars must match /^_/u
if (flow?.publishedId) {
log(`deleting published flow ${flow?.publishedId}`);
await adminGQLClient.request(
Expand All @@ -195,7 +200,7 @@
}
}

async function deleteFlow(adminGQLClient: GraphQLClient, flow: Flow) {

Check warning on line 203 in e2e/tests/ui-driven/src/helpers/context.ts

View workflow job for this annotation

GitHub Actions / E2E tests

'deleteFlow' is defined but never used. Allowed unused vars must match /^_/u
if (flow?.id) {
log(`deleting flow ${flow?.id}`);
await adminGQLClient.request(
Expand Down Expand Up @@ -230,7 +235,7 @@
}
}

async function deleteUser(adminGQLClient: GraphQLClient, context: TestContext) {

Check warning on line 238 in e2e/tests/ui-driven/src/helpers/context.ts

View workflow job for this annotation

GitHub Actions / E2E tests

'deleteUser' is defined but never used. Allowed unused vars must match /^_/u
if (context.user?.id) {
log(`deleting user ${context.user?.id}`);
await adminGQLClient.request(
Expand Down Expand Up @@ -267,7 +272,7 @@
}
}

async function deleteTeam(adminGQLClient: GraphQLClient, context: TestContext) {

Check warning on line 275 in e2e/tests/ui-driven/src/helpers/context.ts

View workflow job for this annotation

GitHub Actions / E2E tests

'deleteTeam' is defined but never used. Allowed unused vars must match /^_/u
if (context.team?.id) {
log(`deleting team ${context.team?.id}`);
await adminGQLClient.request(
Expand Down
5 changes: 4 additions & 1 deletion e2e/tests/ui-driven/src/helpers/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@ export interface Flow {
}

export interface TestContext {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: I'm not sure if TestContext is really much clearer or better than Context here when we're entirely within Playwright tests.

Not a strongly held opinion - was there a motivation for this change? Classes with BrowserContext maybe?

Copy link
Contributor Author

@RODO94 RODO94 Dec 2, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't fully remember why, but it did come out of some frustration with the generalised context. Might have been to help express that as a Type it was generated within the Test so it is test specific, rather than bringing it in from external Types. If that makes sense?

user: Pick<User, "firstName" | "lastName" | "email" | "isPlatformAdmin" | "id">
user: Pick<
User,
"firstName" | "lastName" | "email" | "isPlatformAdmin" | "id"
>;
team: { id?: number } & NewTeam;
flow?: Flow;
externalPortalFlow?: Flow;
Expand Down
Loading