mirror of
https://github.com/ToolJet/ToolJet
synced 2026-04-27 00:17:18 +00:00
* addedspace in button spec * update manage sso * fixed onboarding spec * fixed license specs * - Fix private and public app * - Update spec by removing it only * Add timeout for loading fixes. * fix for first user onboarding. * User invite flow ✅ * Profile ✅ * homePageDashboard ✅ * homePageDashboard ✅ ✅ * Redirection limit ✅ * userInviteFlowEdgeCases ✅ * First user onboarding ✅ * fixed global inspector specs * - Fix multienv, and login * Update openid test cases --------- Co-authored-by: emidhun <[email protected]> Co-authored-by: ajith-k-v <[email protected]>
606 lines
19 KiB
JavaScript
606 lines
19 KiB
JavaScript
import { commonSelectors, cyParamName } from "Selectors/common";
|
|
import { ssoSelector } from "Selectors/manageSSO";
|
|
import * as common from "Support/utils/common";
|
|
import { commonText } from "Texts/common";
|
|
import { ssoText } from "Texts/manageSSO";
|
|
|
|
export const generalSettings = () => {
|
|
cy.get(ssoSelector.enableSignUpToggle).check();
|
|
cy.get(ssoSelector.cancelButton).click();
|
|
cy.get(ssoSelector.enableSignUpToggle).should("not.be.checked");
|
|
cy.get(ssoSelector.enableSignUpToggle).check();
|
|
cy.get(ssoSelector.saveButton).click();
|
|
cy.get(ssoSelector.enableSignUpToggle).should("be.checked");
|
|
|
|
cy.get(ssoSelector.enableSignUpToggle).uncheck();
|
|
cy.get(ssoSelector.saveButton).click();
|
|
cy.get(ssoSelector.enableSignUpToggle).should("not.be.checked");
|
|
|
|
cy.get(ssoSelector.workspaceLoginPage.defaultSSO).click();
|
|
cy.get(ssoSelector.defaultGoogle).verifyVisibleElement("have.text", "Google");
|
|
cy.get(ssoSelector.defaultGithub).verifyVisibleElement("have.text", "Git");
|
|
|
|
cy.clearAndType(ssoSelector.allowedDomainInput, ssoText.allowedDomain);
|
|
cy.get(ssoSelector.saveButton).click();
|
|
cy.verifyToastMessage(commonSelectors.toastMessage, ssoText.ssoToast);
|
|
|
|
cy.get(ssoSelector.passwordEnableToggle).uncheck();
|
|
cy.get(commonSelectors.modalComponent).should("be.visible");
|
|
cy.get(commonSelectors.modalMessage).verifyVisibleElement(
|
|
"have.text",
|
|
ssoText.passwordDisableWarning
|
|
);
|
|
cy.get(commonSelectors.cancelButton).eq(1).click();
|
|
cy.get(ssoSelector.passwordEnableToggle).uncheck();
|
|
cy.get(commonSelectors.confirmationButton).click();
|
|
cy.verifyToastMessage(
|
|
commonSelectors.toastMessage,
|
|
ssoText.passwordDisabledToast
|
|
);
|
|
|
|
cy.get(ssoSelector.passwordEnableToggle).check();
|
|
cy.get(commonSelectors.saveButton).click();
|
|
|
|
cy.get(ssoSelector.allowDefaultSSOToggle).click();
|
|
|
|
cy.get(ssoSelector.passwordEnableToggle).should("be.disabled");
|
|
|
|
common.verifyTooltipDisabled(
|
|
ssoSelector.passwordEnableToggle,
|
|
"Password login cannot be disabled unless SSO is configured"
|
|
);
|
|
|
|
cy.get(ssoSelector.allowDefaultSSOToggle).click();
|
|
};
|
|
|
|
export const googleSSOPageElements = () => {
|
|
cy.get(ssoSelector.googleEnableToggle).click();
|
|
cy.get(ssoSelector.saveButton).eq(1).click();
|
|
|
|
cy.get('[data-cy="modal-title"]').verifyVisibleElement(
|
|
"have.text",
|
|
"Enable Google"
|
|
);
|
|
cy.get('[data-cy="modal-close-button"]').should("be.visible");
|
|
cy.get('[data-cy="modal-message"]').verifyVisibleElement(
|
|
"have.text",
|
|
"Enabling Google at the workspace level will override any Google configurations set at the instance level."
|
|
);
|
|
cy.get('[data-cy="confirmation-text"]').verifyVisibleElement(
|
|
"have.text",
|
|
"Are you sure you want to continue?"
|
|
);
|
|
cy.get('[data-cy="cancel-button"]')
|
|
.eq(2)
|
|
.verifyVisibleElement("have.text", "Cancel");
|
|
cy.get('[data-cy="enable-button"]').verifyVisibleElement(
|
|
"have.text",
|
|
"Enable"
|
|
);
|
|
|
|
cy.get('[data-cy="cancel-button"]').eq(2).click();
|
|
cy.get(ssoSelector.googleEnableToggle).click();
|
|
cy.get(ssoSelector.saveButton).eq(1).click();
|
|
cy.get('[data-cy="enable-button"]').click();
|
|
cy.verifyToastMessage(commonSelectors.toastMessage, ssoText.googleSSOToast);
|
|
|
|
cy.get(ssoSelector.statusLabel).verifyVisibleElement(
|
|
"have.text",
|
|
ssoText.enabledLabel
|
|
);
|
|
cy.get('[data-cy="redirect-url-label"]').verifyVisibleElement(
|
|
"have.text",
|
|
ssoText.redirectUrlLabel
|
|
);
|
|
cy.get('[data-cy="redirect-url"]').should("be.visible");
|
|
cy.get('[data-cy="copy-icon"]').should("be.visible");
|
|
|
|
cy.get(ssoSelector.googleEnableToggle).click();
|
|
cy.get(ssoSelector.saveButton).eq(1).click();
|
|
cy.verifyToastMessage(commonSelectors.toastMessage, ssoText.googleSSOToast);
|
|
cy.get(ssoSelector.statusLabel).verifyVisibleElement(
|
|
"have.text",
|
|
ssoText.disabledLabel
|
|
);
|
|
|
|
cy.clearAndType(ssoSelector.clientIdInput, ssoText.testClientId);
|
|
cy.get(ssoSelector.cancelButton).eq(1).click();
|
|
cy.get(ssoSelector.google).click();
|
|
cy.get(ssoSelector.clientIdInput).should("have.value", "");
|
|
cy.get(ssoSelector.googleEnableToggle).click();
|
|
cy.clearAndType(ssoSelector.clientIdInput, ssoText.clientId);
|
|
cy.get(ssoSelector.saveButton).eq(1).click();
|
|
cy.get('[data-cy="enable-button"]').click();
|
|
cy.verifyToastMessage(commonSelectors.toastMessage, ssoText.googleSSOToast);
|
|
cy.get(ssoSelector.clientIdInput).should("have.value", ssoText.clientId);
|
|
};
|
|
|
|
export const gitSSOPageElements = () => {
|
|
cy.get(ssoSelector.gitEnableToggle).click();
|
|
|
|
cy.get(ssoSelector.saveButton).eq(1).click();
|
|
|
|
cy.get('[data-cy="modal-title"]').verifyVisibleElement(
|
|
"have.text",
|
|
"Enable Git"
|
|
);
|
|
cy.get('[data-cy="modal-close-button"]').should("be.visible");
|
|
cy.get('[data-cy="modal-message"]').verifyVisibleElement(
|
|
"have.text",
|
|
"Enabling Git at the workspace level will override any Git configurations set at the instance level."
|
|
);
|
|
cy.get('[data-cy="confirmation-text"]').verifyVisibleElement(
|
|
"have.text",
|
|
"Are you sure you want to continue?"
|
|
);
|
|
cy.get('[data-cy="cancel-button"]')
|
|
.eq(2)
|
|
.verifyVisibleElement("have.text", "Cancel");
|
|
cy.get('[data-cy="enable-button"]').verifyVisibleElement(
|
|
"have.text",
|
|
"Enable"
|
|
);
|
|
|
|
cy.get('[data-cy="cancel-button"]').eq(2).click();
|
|
cy.get(ssoSelector.gitEnableToggle).click();
|
|
cy.get(ssoSelector.saveButton).eq(1).click();
|
|
cy.get('[data-cy="enable-button"]').click();
|
|
|
|
cy.verifyToastMessage(commonSelectors.toastMessage, ssoText.gitSSOToast);
|
|
|
|
cy.get(ssoSelector.statusLabel).verifyVisibleElement(
|
|
"have.text",
|
|
ssoText.enabledLabel
|
|
);
|
|
|
|
cy.get('[data-cy="redirect-url-label"]').verifyVisibleElement(
|
|
"have.text",
|
|
ssoText.redirectUrlLabel
|
|
);
|
|
cy.get('[data-cy="redirect-url"]').should("be.visible");
|
|
cy.get('[data-cy="copy-icon"]').should("be.visible");
|
|
|
|
cy.get(ssoSelector.gitEnableToggle).click();
|
|
cy.get(ssoSelector.saveButton).eq(1).click();
|
|
|
|
cy.verifyToastMessage(commonSelectors.toastMessage, ssoText.gitSSOToast);
|
|
cy.get(ssoSelector.statusLabel).verifyVisibleElement(
|
|
"have.text",
|
|
ssoText.disabledLabel
|
|
);
|
|
|
|
cy.get(ssoSelector.gitEnableToggle).click();
|
|
cy.clearAndType(ssoSelector.hostNameInput, ssoText.hostName);
|
|
cy.clearAndType(ssoSelector.clientIdInput, ssoText.clientId);
|
|
cy.clearAndType(ssoSelector.clientSecretInput, ssoText.testClientId);
|
|
cy.get(ssoSelector.saveButton).eq(1).click();
|
|
cy.get('[data-cy="enable-button"]').click();
|
|
cy.verifyToastMessage(commonSelectors.toastMessage, ssoText.gitSSOToast);
|
|
cy.get(ssoSelector.hostNameInput).should("have.value", ssoText.hostName);
|
|
cy.get(ssoSelector.clientIdInput).should("have.value", ssoText.clientId);
|
|
cy.get(ssoSelector.clientSecretInput).should(
|
|
"have.value",
|
|
ssoText.testClientId
|
|
);
|
|
};
|
|
|
|
export const visitWorkspaceLoginPage = () => {
|
|
cy.get(ssoSelector.workspaceLoginUrl).then(($temp) => {
|
|
const url = $temp.text();
|
|
common.logout();
|
|
cy.wait(1000);
|
|
cy.visit(url);
|
|
});
|
|
};
|
|
|
|
export const workspaceLoginPageElements = (workspaceName) => {
|
|
signInPageElements();
|
|
cy.get(ssoSelector.workspaceSubHeader).verifyVisibleElement(
|
|
"have.text",
|
|
ssoText.workspaceSubHeader(workspaceName)
|
|
);
|
|
};
|
|
|
|
export const signInPageElements = () => {
|
|
cy.get(ssoSelector.signInHeader).verifyVisibleElement(
|
|
"have.text",
|
|
ssoText.signInHeader
|
|
);
|
|
cy.get(commonSelectors.workEmailLabel).verifyVisibleElement(
|
|
"have.text",
|
|
commonText.workEmailLabel
|
|
);
|
|
cy.get(commonSelectors.passwordLabel).should(($el) => {
|
|
expect($el.contents().first().text().trim()).to.eq(
|
|
commonText.passwordLabel
|
|
);
|
|
});
|
|
cy.get(commonSelectors.forgotPasswordLink).verifyVisibleElement(
|
|
"have.text",
|
|
commonText.forgotPasswordLink
|
|
);
|
|
cy.get(onboardingSelectors.signInButton).verifyVisibleElement(
|
|
"have.text",
|
|
commonText.loginButton
|
|
);
|
|
|
|
cy.get(onboardingSelectors.loginEmailInput).should("be.visible");
|
|
cy.get(onboardingSelectors.loginPasswordInput).should("be.visible");
|
|
|
|
cy.get("body").then(($el) => {
|
|
if ($el.text().includes("Google")) {
|
|
cy.get(ssoSelector.googleSSOText).verifyVisibleElement(
|
|
"have.text",
|
|
ssoText.googleSSOText
|
|
);
|
|
cy.get(ssoSelector.gitSSOText).verifyVisibleElement(
|
|
"have.text",
|
|
ssoText.gitSignInText
|
|
);
|
|
}
|
|
});
|
|
};
|
|
|
|
export const enableSignUp = () => {
|
|
common.navigateToManageSSO();
|
|
cy.get("body").then(($el) => {
|
|
if (!$el.text().includes("Allowed domains")) {
|
|
cy.get(ssoSelector.generalSettingsElements.generalSettings).click();
|
|
}
|
|
});
|
|
cy.get(ssoSelector.enableSignUpToggle).then(($el) => {
|
|
if (!$el.is(":checked")) {
|
|
cy.get(ssoSelector.enableSignUpToggle).check();
|
|
cy.get(ssoSelector.saveButton).click();
|
|
cy.verifyToastMessage(commonSelectors.toastMessage, ssoText.ssoToast);
|
|
}
|
|
});
|
|
};
|
|
|
|
export const disableSignUp = () => {
|
|
common.navigateToManageSSO();
|
|
cy.get("body").then(($el) => {
|
|
if (!$el.text().includes("Allowed domains")) {
|
|
cy.get(ssoSelector.generalSettingsElements.generalSettings).click();
|
|
}
|
|
});
|
|
cy.get(ssoSelector.enableSignUpToggle).then(($el) => {
|
|
if ($el.is(":checked")) {
|
|
cy.get(ssoSelector.enableSignUpToggle).uncheck();
|
|
cy.get(ssoSelector.saveButton).click();
|
|
cy.verifyToastMessage(commonSelectors.toastMessage, ssoText.ssoToast);
|
|
}
|
|
});
|
|
};
|
|
|
|
export const invitePageElements = () => {
|
|
cy.get(commonSelectors.invitePageHeader).verifyVisibleElement(
|
|
"have.text",
|
|
commonText.invitePageHeader
|
|
);
|
|
cy.get(commonSelectors.invitePageSubHeader).verifyVisibleElement(
|
|
"have.text",
|
|
commonText.invitePageSubHeader
|
|
);
|
|
cy.get(commonSelectors.userNameInputLabel).verifyVisibleElement(
|
|
"have.text",
|
|
commonText.userNameInputLabel
|
|
);
|
|
cy.get(commonSelectors.invitedUserName).should("be.visible");
|
|
cy.get(commonSelectors.emailInputLabel).verifyVisibleElement(
|
|
"have.text",
|
|
commonText.emailInputLabel
|
|
);
|
|
cy.get(commonSelectors.invitedUserEmail).should("be.visible");
|
|
cy.get(commonSelectors.passwordLabel).verifyVisibleElement(
|
|
"have.text",
|
|
commonText.passwordLabel
|
|
);
|
|
cy.get(onboardingSelectors.loginPasswordInput).should("be.visible");
|
|
cy.get(commonSelectors.acceptInviteButton).verifyVisibleElement(
|
|
"have.text",
|
|
commonText.acceptInviteButton
|
|
);
|
|
|
|
cy.get(commonSelectors.signUpTermsHelperText).should(($el) => {
|
|
expect($el.contents().first().text().trim()).to.eq(
|
|
commonText.signUpTermsHelperText
|
|
);
|
|
});
|
|
cy.get(commonSelectors.termsOfServiceLink)
|
|
.verifyVisibleElement("have.text", commonText.termsOfServiceLink)
|
|
.and("have.attr", "href")
|
|
.and("equal", "https://www.tooljet.com/terms");
|
|
cy.get(commonSelectors.privacyPolicyLink)
|
|
.verifyVisibleElement("have.text", commonText.privacyPolicyLink)
|
|
.and("have.attr", "href")
|
|
.and("equal", "https://www.tooljet.com/privacy");
|
|
};
|
|
|
|
export const updateSsoId = (ssoId, sso, workspaceId) => {
|
|
cy.task("dbConnection", {
|
|
dbconfig: Cypress.env("app_db"),
|
|
sql: `UPDATE sso_configs SET id='${ssoId}' WHERE sso='${sso}' AND organization_id='${workspaceId}';`,
|
|
});
|
|
};
|
|
|
|
export const setSSOStatus = (workspaceName, ssoType, enabled) => {
|
|
let workspaceId;
|
|
|
|
cy.task("dbConnection", {
|
|
dbconfig: Cypress.env("app_db"),
|
|
sql: `SELECT id FROM organizations WHERE name = '${workspaceName}'`,
|
|
}).then((resp) => {
|
|
workspaceId = resp.rows[0].id;
|
|
|
|
cy.task("dbConnection", {
|
|
dbconfig: Cypress.env("app_db"),
|
|
sql: `SELECT * FROM sso_configs WHERE organization_id = '${workspaceId}' AND sso = '${ssoType}'`,
|
|
}).then((ssoConfigResp) => {
|
|
if (ssoConfigResp.rows.length > 0) {
|
|
cy.task("dbConnection", {
|
|
dbconfig: Cypress.env("app_db"),
|
|
sql: `UPDATE sso_configs SET enabled = ${
|
|
enabled ? "true" : "false"
|
|
} WHERE organization_id = '${workspaceId}' AND sso = '${ssoType}'`,
|
|
});
|
|
}
|
|
});
|
|
});
|
|
};
|
|
|
|
export const defaultSSO = (enable) => {
|
|
cy.getAuthHeaders().then((headers) => {
|
|
cy.request(
|
|
{
|
|
method: "PATCH",
|
|
url: `${Cypress.env("server_host")}/api/login-configs/organization-general/inherit-sso`,
|
|
headers: headers,
|
|
body: { inheritSSO: enable },
|
|
},
|
|
{ log: false }
|
|
).then((response) => {
|
|
expect(response.status).to.equal(200);
|
|
});
|
|
});
|
|
};
|
|
|
|
export const setSignupStatus = (enable, workspaceName = "My workspace") => {
|
|
cy.task("dbConnection", {
|
|
dbconfig: Cypress.env("app_db"),
|
|
sql: `SELECT id FROM organizations WHERE name = '${workspaceName}'`,
|
|
}).then((resp) => {
|
|
const workspaceId = resp.rows[0].id;
|
|
|
|
cy.getAuthHeaders().then((headers) => {
|
|
cy.request({
|
|
method: "PATCH",
|
|
url: `${Cypress.env("server_host")}/api/login-configs/organization-general`,
|
|
headers: headers,
|
|
body: { enableSignUp: enable },
|
|
}).then((response) => {
|
|
expect(response.status).to.equal(200);
|
|
});
|
|
});
|
|
});
|
|
};
|
|
|
|
export const deleteOrganisationSSO = (workspaceName, services) => {
|
|
let workspaceId;
|
|
cy.task("dbConnection", {
|
|
dbconfig: Cypress.env("app_db"),
|
|
sql: `select id from organizations where name='${workspaceName}';`,
|
|
}).then((resp) => {
|
|
workspaceId = resp.rows[0].id;
|
|
|
|
cy.task("dbConnection", {
|
|
dbconfig: Cypress.env("app_db"),
|
|
sql: `DELETE FROM sso_configs WHERE organization_id = '${workspaceId}' AND sso IN (${services
|
|
.map((service) => `'${service}'`)
|
|
.join(",")});`,
|
|
});
|
|
});
|
|
};
|
|
|
|
export const resetDomain = () => {
|
|
cy.getAuthHeaders().then((headers) => {
|
|
cy.request(
|
|
{
|
|
method: "PATCH",
|
|
url: `${Cypress.env("server_host")}/api/login-configs/organization-general`,
|
|
headers: headers,
|
|
body: { domain: "" },
|
|
},
|
|
{ log: false }
|
|
).then((response) => {
|
|
expect(response.status).to.equal(200);
|
|
});
|
|
});
|
|
};
|
|
|
|
export const enableInstanceSignup = (enable = true) => {
|
|
cy.getAuthHeaders().then((headers) => {
|
|
cy.request({
|
|
method: "PATCH",
|
|
url: `${Cypress.env("server_host")}/api/login-configs/instance-general`,
|
|
headers: headers,
|
|
body: { enableSignUp: enable },
|
|
}).then((response) => {
|
|
expect(response.status).to.equal(200);
|
|
});
|
|
});
|
|
};
|
|
|
|
export const updateOIDCConfig = (orgId) => {
|
|
const ssoConfigId = "22f22523-7bc2-4134-891d-88bdfec073cd";
|
|
const sso = "'openid'";
|
|
const configs = `'{
|
|
"name": "",
|
|
"clientId": "",
|
|
"clientSecret": "",
|
|
"wellKnownUrl": ""
|
|
}'`;
|
|
const configScope = "'organization'";
|
|
const syncId = "a6a2f665-f96e-4c82-91cb-6e0a99c32d21"; // Explicit id for second table
|
|
const claimName = "groups";
|
|
const groupMapping = "{}";
|
|
|
|
cy.task("dbConnection", {
|
|
dbconfig: Cypress.env("app_db"),
|
|
sql: `
|
|
INSERT INTO sso_configs (
|
|
id,
|
|
organization_id,
|
|
sso,
|
|
configs,
|
|
enabled,
|
|
config_scope
|
|
) VALUES (
|
|
'${ssoConfigId}',
|
|
'${orgId}',
|
|
${sso},
|
|
${configs},
|
|
true,
|
|
${configScope}
|
|
);
|
|
`,
|
|
});
|
|
|
|
cy.task("dbConnection", {
|
|
dbconfig: Cypress.env("app_db"),
|
|
sql: `
|
|
INSERT INTO sso_config_oidc_group_sync (
|
|
id,
|
|
sso_config_id,
|
|
organization_id,
|
|
claim_name,
|
|
group_mapping,
|
|
enable_group_sync
|
|
) VALUES (
|
|
'${syncId}',
|
|
'${ssoConfigId}',
|
|
'${orgId}',
|
|
'${claimName}',
|
|
'${groupMapping}',
|
|
true
|
|
);
|
|
`,
|
|
});
|
|
};
|
|
|
|
export const authResponse = (matcher) => {
|
|
cy.intercept("POST", "/api/authorize", (req) => {
|
|
req.continue((res) => {
|
|
matcher(res.body);
|
|
});
|
|
}).as("authorizeCheck");
|
|
};
|
|
|
|
export const addOIDCConfig = (
|
|
groupMapping,
|
|
level = "workspace",
|
|
extra = {}
|
|
) => {
|
|
const config = {
|
|
type: "openid",
|
|
configs: {
|
|
name: "",
|
|
clientId: Cypress.env("okta_client_id"),
|
|
clientSecret: Cypress.env("okta_client_secret"),
|
|
codeVerifier: "",
|
|
grantType: "authorization_code",
|
|
wellKnownUrl: `https://${Cypress.env("okta_domain")}/.well-known/openid-configuration`,
|
|
...(level === "instance" ? { enableGroupSync: true } : {}),
|
|
},
|
|
oidcGroupSyncs: [
|
|
{
|
|
claimName: "groups",
|
|
groupMapping: { ...groupMapping },
|
|
...(level === "instance"
|
|
? { organizationId: extra.organizationId, id: extra.id }
|
|
: {}),
|
|
},
|
|
],
|
|
enabled: true,
|
|
};
|
|
return cy.apiUpdateSSOConfig(config, level);
|
|
};
|
|
|
|
export const uiOktaLogin = (email, password) => {
|
|
cy.get('input[name="identifier"]').type(email);
|
|
cy.get(".button-primary").click();
|
|
cy.get('input[name="credentials.passcode"]').type(password);
|
|
cy.get(".button-primary").click();
|
|
};
|
|
|
|
export const toggleSsoViaUI = (
|
|
provider,
|
|
settingsUrl = "settings/instance-login"
|
|
) => {
|
|
cy.wait(1000);
|
|
const isInstance = settingsUrl === "settings/instance-login";
|
|
cy.intercept(
|
|
"PATCH",
|
|
`/api/login-configs/${isInstance ? "instance" : "organization"}-sso`
|
|
).as("patchInstanceSSO");
|
|
|
|
cy.visit(settingsUrl);
|
|
cy.wait(1000);
|
|
cy.get(`[data-cy="${cyParamName(provider)}-label"]`).click();
|
|
cy.wait(1000);
|
|
cy.get(`[data-cy="${cyParamName(provider)}-toggle-input"]`).click();
|
|
cy.get(`[data-cy="save-button"]`).eq(1).click();
|
|
|
|
cy.wait("@patchInstanceSSO").its("response.statusCode").should("eq", 200);
|
|
cy.wait(1000);
|
|
};
|
|
|
|
export const gitHubSignInWithAssertion = (
|
|
assertion = null,
|
|
githubUsername = Cypress.env("GITHUB_USERNAME"),
|
|
githubPassword = Cypress.env("GITHUB_PASSWORD")
|
|
) => {
|
|
cy.origin(
|
|
"https://github.com",
|
|
{ args: { githubUsername, githubPassword, assertion } },
|
|
({ githubUsername, githubPassword, assertion }) => {
|
|
cy.get('input[name="login"]', { timeout: 15000 }).type(githubUsername);
|
|
cy.get('input[name="password"]').type(githubPassword);
|
|
cy.get('input[name="commit"]').click();
|
|
cy.log("GitHub login submitted");
|
|
|
|
cy.get("body").then(($body) => {
|
|
if (
|
|
$body.find('[data-octo-click="oauth_application_authorization"]')
|
|
.length > 0
|
|
) {
|
|
cy.get('[data-octo-click="oauth_application_authorization"]').click();
|
|
cy.log("GitHub authorization button clicked");
|
|
}
|
|
});
|
|
|
|
if (assertion && assertion.type === "failure") {
|
|
cy.get(
|
|
'[alt="404 “This is not the web page you are looking for”"]'
|
|
).should("be.visible");
|
|
} else if (assertion && assertion.type === "selector") {
|
|
cy.get(assertion.selector).should(assertion.condition, assertion.value);
|
|
}
|
|
}
|
|
);
|
|
};
|
|
|
|
/**
|
|
* Deletes a single test user by email from the database
|
|
* @param {string} email - The email of the user to delete
|
|
*/
|
|
export const cleanupTestUser = (email) => {
|
|
cy.runSqlQuery(
|
|
`SELECT EXISTS(SELECT 1 FROM users WHERE email = '${email}');`
|
|
).then((result) => {
|
|
cy.log("User existence :", JSON.stringify(result?.rows?.[0]?.exists));
|
|
if (result?.rows?.[0]?.exists) {
|
|
cy.runSqlQuery(`CALL delete_users(ARRAY['${email}']::text[]);`);
|
|
}
|
|
});
|
|
};
|