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

Add tests for requesting to join project #1410

Open
wants to merge 11 commits into
base: develop
Choose a base branch
from

Conversation

rmunn
Copy link
Contributor

@rmunn rmunn commented Jan 23, 2025

Fixes #1014

This adds two tests: one that exercises the create-project page workflow, and one that exercises the workflow that goes through the project page's "Ask to Join" button visible to org members.

@rmunn rmunn self-assigned this Jan 23, 2025
@rmunn rmunn linked an issue Jan 23, 2025 that may be closed by this pull request
@rmunn
Copy link
Contributor Author

rmunn commented Jan 23, 2025

This also contains a fix for #1409.

Copy link

github-actions bot commented Jan 23, 2025

UI unit Tests

12 tests  ±0   12 ✅ ±0   0s ⏱️ ±0s
 4 suites ±0    0 💤 ±0 
 1 files   ±0    0 ❌ ±0 

Results for commit 84430e3. ± Comparison against base commit 9355ee2.

♻️ This comment has been updated with latest results.

Copy link

github-actions bot commented Jan 23, 2025

C# Unit Tests

104 tests  ±0   104 ✅ ±0   5s ⏱️ ±0s
 16 suites ±0     0 💤 ±0 
  1 files   ±0     0 ❌ ±0 

Results for commit 84430e3. ± Comparison against base commit 9355ee2.

This pull request removes 2 and adds 2 tests. Note that renamed tests count towards both.
Testing.LexCore.Services.FwLiteReleaseServiceTests ‑ CanGetLatestRelease(platform: Linux)
Testing.LexCore.Services.FwLiteReleaseServiceTests ‑ CanGetLatestRelease(platform: Windows)
Testing.LexCore.Services.FwLiteReleaseServiceTests ‑ CanGetLatestRelease(edition: Linux)
Testing.LexCore.Services.FwLiteReleaseServiceTests ‑ CanGetLatestRelease(edition: Windows)

♻️ This comment has been updated with latest results.

rmunn added 2 commits January 24, 2025 10:47
This one exercises the create-project page workflow. The next one will
exercise the workflow that goes through the project page visible to
org members.
This one exercises the project page workflow.
@rmunn rmunn force-pushed the chore/e2e-test-for-project-join-requests branch from e92abd6 to f00b9d6 Compare January 24, 2025 15:53
@rmunn rmunn marked this pull request as ready for review January 24, 2025 15:54
@rmunn rmunn requested a review from myieye January 24, 2025 15:54

// Get to Sena-3 project page via org page, then ask to join
const testOrgPage = await new OrgPage(page, 'Test Org', testOrgId).goto();
await testOrgPage.membersTab.click();
Copy link
Collaborator

Choose a reason for hiding this comment

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

why click the members tab?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Leftover code from making sure I got locators right. Removed in commit 003d20a.

Copy link
Collaborator

Choose a reason for hiding this comment

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

that didn't actually make it into that commit

Copy link
Collaborator

@hahn-kev hahn-kev left a comment

Choose a reason for hiding this comment

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

left some feedback.

I tried running the tests and join via project page failed because it couldn't click the project link on the org page. I ran it multiple times and it never passed on other ff or chrome.

Running the join via create project test failed with this error:

Error: Timed out 5000ms waiting for expect(locator).toBeVisible()

Locator: locator('#group-extra-projects')
Expected: visible
Received: <element(s) not found>
Call log:
  - expect.toBeVisible with timeout 5000ms
  - waiting for locator('#group-extra-projects')


    at C:\dev\LexBox\frontend\tests\emailWorkflow.test.ts:178:51

@rmunn
Copy link
Contributor Author

rmunn commented Jan 28, 2025

Forgot to mention, when I ran this I had to mark the Sena-3 project as NON-confidential in order for the "Ask to join" button to show up. So I might need to create a whole separate, non-confidential, test project in order for this to work properly. Either that, or change our seeding data to make Sena-3 non-confidential, which I bet would require adjusting the expectations of a few other tests. I'll check what would be involved in that; it does make sense, from a "realism" point of view for Sena-3 (the project that's distributed with FieldWorks as example data) to be considered non-confidential rather than "confidentiality unknown".

rmunn added 5 commits January 28, 2025 16:18
Elawa is marked as non-confidential in our seeding data, so it's going
to show up by default for org members. Sena-3 has confidentiality
unknown so org members can't see it by default and thus can't ask to
join it, so it won't work for this set of tests.
Not working yet, will continue working on this later.
@rmunn
Copy link
Contributor Author

rmunn commented Jan 28, 2025

Commit a8d9a37 is an attempt to fix the test by using Elawa (non-confidential in seeding data) instead of Sena-3 (confidentiality unknown in seeding data) so that the newly-added org member will be able to see the "Ask to Join" button. I haven't gotten it working, but I ran out of time for today. I'll continue working on this tomorrow.

@rmunn
Copy link
Contributor Author

rmunn commented Jan 29, 2025

On my local machine, the tests are now passing in Firefox but failing on Chromium. But when I run them in Chromium alone, they pass. That would seem to indicate an issue with running them in parallel, but I've double-checked all the obvious issues (such as #1409) and don't see anything. I'm going to push this and see what it does on GHA; it's possible that the tests are fine and I have a setup issue on my dev machine.

@rmunn
Copy link
Contributor Author

rmunn commented Jan 29, 2025

... But it doesn't always fail on Chromium? I ran the full test suite this time, and got one out of four tests (2 each on Firefox and Chromium) passing: "ask to join project via project page" on Chromium passed, the other three failed.

I'm going to throw up my hands at this point, say "If it passes on GHA, I'll call it good," and move on to a different PR.

@rmunn rmunn requested a review from hahn-kev January 29, 2025 20:16
@rmunn
Copy link
Contributor Author

rmunn commented Jan 29, 2025

@hahn-kev - GHA tests were failing because the $lib alias wasn't available. I decided in commit 84430e3 to replace the OrgRole.User enum with a hardcoded string to work around this problem. Obviously the better solution is to make the $lib alias available to Playwright in GHA so that if we ever change the value of OrgRole.User then the tests will automatically update accordingly. But I didn't want to spend even more time figuring out why the GHA tests aren't being run via Vite (which would make the $lib alias available), so I'm punting on that one.

That aside, these tests are now passing and I believe I've addressed all review concerns so far. Want to re-review this, and decide whether the $lib alias is important enough to hold off on merging the PR while we address it?

return pagePromise;
}

export async function addUserToOrg(api: APIRequestContext, userId: string, orgId: string, role: string): Promise<unknown> {
Copy link
Collaborator

@hahn-kev hahn-kev Jan 30, 2025

Choose a reason for hiding this comment

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

I don't love doing the role this way, but I'm fine with it as a workaround. But could we restrict the role to valid values?

`);
}

export async function addUserToProject(api: APIRequestContext, userId: string, projectId: string, role: string): Promise<unknown> {
Copy link
Collaborator

Choose a reason for hiding this comment

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

same for roles here

await newProjectPage.fillForm({name: 'Elaw', code: 'xyz', purpose: 'Testing', organization: 'Test Org'});
await expect(newProjectPage.extraProjectsDiv).toBeVisible();
await expect(newProjectPage.askToJoinBtn).toBeDisabled();
await newProjectPage.extraProjectsDiv.locator('#extra-projects-elawa-dev-flex').check();
Copy link
Collaborator

Choose a reason for hiding this comment

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

can we make this a helper function on CreateProjectPage? something like relatedProjectItem(projectCode: string): Locator just because we've got a bit of magic strings here with the current locator.

await dashboardPage.emailVerificationAlert.assertPleaseVerify();
let emailPage = await tempUserInTestOrg.mailbox.openEmail(page, EmailSubjects.VerifyEmail);
let pagePromise = emailPage.page.context().waitForEvent('page');
await emailPage.clickVerifyEmail();
Copy link
Collaborator

Choose a reason for hiding this comment

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

should be using verifyTempUserEmail helper here

let dashboardPage = await new UserDashboardPage(page).goto();

// Must verify email before being made manager of a project
await dashboardPage.emailVerificationAlert.assertPleaseVerify();
Copy link
Collaborator

Choose a reason for hiding this comment

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

just a thought, since we're not actually testing the verification we could skip this. And since email verification does not require login we could actually skip logging in, going to the dashboard and checking for verification. The same can be done for the user and in the other test as well

Copy link
Collaborator

@hahn-kev hahn-kev left a comment

Choose a reason for hiding this comment

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

looks good, tests are passing for me now. There's a few minor things to change and I left a suggestion about streamlining email verification, but feel free to ignore it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants