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

Test/repo privatisation #1342

Merged
merged 3 commits into from
Mar 21, 2024
Merged

Test/repo privatisation #1342

merged 3 commits into from
Mar 21, 2024

Conversation

alexanderleegs
Copy link
Contributor

@alexanderleegs alexanderleegs commented Jul 14, 2023

This PR adds tests for privatisation into our existing settings cypress tests. To facilitate this, the repo being used for the settings tests has been changed to the email login version, and the helper methods have been changed to fit the new changes.

Resolves IS-278

@alexanderleegs alexanderleegs temporarily deployed to staging July 14, 2023 02:06 — with GitHub Actions Inactive
@alexanderleegs alexanderleegs temporarily deployed to staging July 14, 2023 02:09 — with GitHub Actions Inactive
@alexanderleegs alexanderleegs requested a review from a team July 14, 2023 02:58
.next()
.find("input")
.as("passwordInput")
cy.wait(1000)
Copy link
Contributor

Choose a reason for hiding this comment

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

what is this wait for ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I was getting wonky results when attempting to inspect the contents of the password field immediately for some reason - I think it might have been because of the auto generation + population of the field taking some time. I've opted to add in a wait time here as this made the test less flaky, but open to suggestions on making this better!

Copy link
Contributor

Choose a reason for hiding this comment

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

got it

Copy link
Contributor

Choose a reason for hiding this comment

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

i can work with you on this - this shouldn't block the PR cos it works fine as-is but it is an issue because static wait times, if propagated, either waits for no reason (when wait time is insufficient) or causes extra delay (resolve early prior to wait).

the trick to solve this is to know what signals completion and either assert on that or wait on the request

@alexanderleegs alexanderleegs temporarily deployed to staging July 19, 2023 04:55 — with GitHub Actions Inactive
Copy link
Contributor

@seaerchin seaerchin left a comment

Choose a reason for hiding this comment

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

non-blockers but good to haves that will help us in future.

.parent()
.find("input")
.as("privatiseStaging")
cy.get("@privatiseStaging").should("be.checked")
Copy link
Contributor

Choose a reason for hiding this comment

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

this has implicit dep on prev test so if the prev one fail, this will fail too ._.

.find("input")
.as("passwordInput")
cy.wait(1000)
cy.get("@passwordInput").should("have.length.gt", 0)
Copy link
Contributor

Choose a reason for hiding this comment

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

we should aim to make some simple assertions about the nature of this pw - eg, that it is random (might be hard) or that it is regenerated per toggle (easy + impt).

given that this is regarding security, i'm of the mind to make our invariants super clear

Comment on lines 139 to 147
let passwordSettings
const isLaunchDarklyImplemented = false
if (shouldGetPrivacyDetails && isLaunchDarklyImplemented) {
// TODO: LaunchDarkly to allow specific groups to access this feature first
passwordSettings = await SettingsService.getPassword({ siteName })
} else {
passwordSettings = {
isAmplifySite: false,
password: "",
}
Copy link
Contributor

Choose a reason for hiding this comment

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

why's this here ._. also, we should remove the toggle as a whole rather than simply changing the request (+ enforce on BE also)

we should also use an env var for this because having it in code requires a full deploy, which defeats the purpose

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Accidental merge into the wrong branch - will put this in the main branch!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@@ -34,11 +36,13 @@ import { SocialMediaSettings } from "./SocialMediaSettings"

export const Settings = (): JSX.Element => {
const { siteName } = useParams<{ siteName: string }>()
const { userId } = useLoginContext()
const isGithubUser = userId !== "Unknown user" && !!userId
Copy link
Contributor

Choose a reason for hiding this comment

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

could we add a note explaining hwy this means that it is a github user?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@alexanderleegs alexanderleegs force-pushed the feat/repo-privatisation branch from 7cbfee3 to 10866c2 Compare July 19, 2023 05:29
@alexanderleegs alexanderleegs force-pushed the test/repo-privatisation branch from b43612b to 54c6f7b Compare July 19, 2023 05:32
@alexanderleegs alexanderleegs temporarily deployed to staging July 19, 2023 05:43 — with GitHub Actions Inactive
@QiluXie
Copy link
Contributor

QiluXie commented Jul 26, 2023

@alexanderleegs is this ready to be merged?

@alexanderleegs
Copy link
Contributor Author

@alexanderleegs is this ready to be merged?

Will need to address chin's comments first - but currently merging these tests are not particularly useful, because they always result in failure since the privatisation feature is hidden!

@mergify mergify bot requested a review from a team August 27, 2023 02:12
@mergify
Copy link

mergify bot commented Aug 27, 2023

This pull request has been stale for more than 30 days! Could someone please take a look at it @isomerpages/iso-engineers

1 similar comment
@mergify
Copy link

mergify bot commented Sep 26, 2023

This pull request has been stale for more than 30 days! Could someone please take a look at it @isomerpages/iso-engineers

@alexanderleegs
Copy link
Contributor Author

alexanderleegs commented Mar 20, 2024

Tests are erroring because of the settings being a conditional field for email login repos only - going to close this for now, we can reference later on when creating tests for playwright for settings

Edit: merging it in but skipping privatisation related tests instead

@alexanderleegs alexanderleegs force-pushed the test/repo-privatisation branch from 54c6f7b to 8ae1775 Compare March 21, 2024 04:55
@alexanderleegs alexanderleegs changed the base branch from feat/repo-privatisation to develop March 21, 2024 04:56
@alexanderleegs alexanderleegs merged commit 3b12a98 into develop Mar 21, 2024
8 checks passed
@mergify mergify bot deleted the test/repo-privatisation branch March 21, 2024 06:10
@seaerchin seaerchin mentioned this pull request Mar 21, 2024
7 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants