Complete git flow

This commit is contained in:
emidhun 2025-10-06 14:17:00 +05:30
parent 2b90ef841d
commit 4e25650077

View file

@ -0,0 +1,149 @@
import { commonSelectors } from "Selectors/common";
import { toggleSsoViaUI, updateSsoId, gitHubSignInWithAssertion } from "Support/utils/manageSSO";
import { fillInputField } from "Support/utils/common";
import { fetchAndVisitInviteLink } from "Support/utils/manageUsers";
describe('GitHub SSO Tests', () => {
const TEST_USER_EMAIL = 'qatooljet@gmail.com';
const TEST_USER_NAME = 'The QA';
const WORKSPACE_URL = '/my-workspace';
const WORKSPACE_SETTINGS_URL = '/my-workspace/workspace-settings/workspace-login';
const GIT_SSO_BUTTON_SELECTOR = '[data-cy="git-sso-button"]';
const emptyGitConfig = {
"type": "git",
"configs": {
"clientId": "",
"clientSecret": "",
"hostName": ""
},
"enabled": false
};
const instanceGitHubConfig = Cypress.env("instanceGitHubConfig");
const workspaceGitHubConfig = Cypress.env("workspaceGitHubConfig");
const ERROR_MESSAGES = {
USER_NOT_EXIST_SIGNUP: "GitHub login failed - User does not exist, please sign up",
USER_NOT_IN_WORKSPACE: "GitHub login failed - User does not exist in the workspace"
};
const TEST_SSO_ID = 'dbe8cc6f-8300-403a-9691-3ba304f2a744';
beforeEach(() => {
cy.apiLogin();
cy.getAuthHeaders().as('adminHeaders');
});
const cleanupTestUser = () => {
cy.runSqlQuery(`CALL delete_user('${TEST_USER_EMAIL}');`);
};
it('should verify sso without configuration on instance', () => {
cy.get('@adminHeaders').then((adminHeaders) => {
cy.apiUpdateSSOConfig(
emptyGitConfig, 'instance', adminHeaders);
});
toggleSsoViaUI('GitHub')
cy.apiLogout();
cy.visit('/');
cy.get(GIT_SSO_BUTTON_SELECTOR).click();
gitHubSignInWithAssertion({ type: 'failure' });
});
it('should verify sso without configuration on workspace', () => {
cy.get('@adminHeaders').then((adminHeaders) => {
cy.apiUpdateSSOConfig(
emptyGitConfig, 'instance', adminHeaders);
cy.apiUpdateSSOConfig(
emptyGitConfig, 'workspace', adminHeaders);
});
toggleSsoViaUI('GitHub', WORKSPACE_SETTINGS_URL)
cy.apiLogout();
cy.visit(WORKSPACE_URL);
cy.get(GIT_SSO_BUTTON_SELECTOR).click();
gitHubSignInWithAssertion({ type: 'failure' });
});
it('should verify signup via sso to instance', () => {
cy.get('@adminHeaders').then((adminHeaders) => {
cy.apiUpdateSSOConfig(
emptyGitConfig, 'instance', adminHeaders);
cy.apiUpdateAllowSignUp(false, 'instance', adminHeaders);
cy.apiUpdateSSOConfig(emptyGitConfig, 'workspace', adminHeaders);
});
toggleSsoViaUI('GitHub');
fillInputField(instanceGitHubConfig);
cy.get(commonSelectors.saveButton).eq(1).click();
cy.wait(1000);
cy.apiLogout();
cy.visit('/');
cy.get(GIT_SSO_BUTTON_SELECTOR).click();
gitHubSignInWithAssertion();
cy.verifyToastMessage(commonSelectors.toastMessage, ERROR_MESSAGES.USER_NOT_EXIST_SIGNUP);
cy.apiLogin();
cy.getAuthHeaders().then((freshAdminHeaders) => {
cy.apiUpdateAllowSignUp(true, 'instance', freshAdminHeaders);
cy.apiLogout();
cy.visit('/');
cy.get(GIT_SSO_BUTTON_SELECTOR).click();
cy.get(commonSelectors.breadcrumbPageTitle).should('have.text', 'All apps');
cleanupTestUser();
});
});
it('should verify signup via sso to workspace', () => {
const orgId = Cypress.env("workspaceId");
cy.get('@adminHeaders').then((adminHeaders) => {
updateSsoId(TEST_SSO_ID, 'git', `'${orgId}'`);
cy.apiUpdateSSOConfig(emptyGitConfig, 'instance', adminHeaders);
cy.apiUpdateAllowSignUp(false, 'organization', adminHeaders);
cy.apiUpdateAllowSignUp(false, 'instance', adminHeaders);
cy.apiUpdateSSOConfig(emptyGitConfig, 'workspace', adminHeaders);
});
toggleSsoViaUI('GitHub', WORKSPACE_SETTINGS_URL);
fillInputField(workspaceGitHubConfig);
cy.get(commonSelectors.saveButton).eq(1).click();
cy.wait(1000);
cy.apiLogout();
cy.visit(WORKSPACE_URL);
cy.get(GIT_SSO_BUTTON_SELECTOR).click();
gitHubSignInWithAssertion();
cy.verifyToastMessage(commonSelectors.toastMessage, ERROR_MESSAGES.USER_NOT_IN_WORKSPACE);
cy.apiLogin();
cy.getAuthHeaders().then((freshAdminHeaders) => {
cy.apiUpdateAllowSignUp(true, 'organization', freshAdminHeaders);
cy.apiLogout();
cy.visit(WORKSPACE_URL);
cy.get(GIT_SSO_BUTTON_SELECTOR).click();
cy.get(commonSelectors.breadcrumbPageTitle).should('have.text', 'All apps');
cleanupTestUser();
});
});
it('should verify signup and login via sso to workspace', () => {
cy.apiUserInvite(TEST_USER_NAME, TEST_USER_EMAIL);
fetchAndVisitInviteLink(TEST_USER_EMAIL);
cy.get(GIT_SSO_BUTTON_SELECTOR).click();
gitHubSignInWithAssertion();
cy.get(commonSelectors.acceptInviteButton).click()
cy.get(commonSelectors.breadcrumbPageTitle).should('have.text', 'All apps');
cleanupTestUser();
});
});