Skip to content

Conversation

@artaleks9
Copy link
Contributor

@artaleks9 artaleks9 commented Nov 19, 2025

What does this PR do?

  • Fixed up SmokeTest E2E test by replacing policies.create=perclick on new query parameter according new behavior
  • Fixed up getProjectNameFromGitUrl method in StringUtils to avoid an error of getting project name:
11:07:29            ▼ Function.getProjectNameFromGitUrl - Original URL: https://gitlab-gitlab-system.apps.git.crw-qe.com/test-user/private-gitlab-repo.git/-/tree/refreshToken?new
11:07:29            ▼ Function.getProjectNameFromGitUrl - Extracted project name: -
.....
11:07:33      1) Check if a project folder has been created
11:07:33    [ERROR] CheReporter runner.on.fail: Create a workspace via launching a factory from the gitlab repository  Check if a project folder has been created failed after 3681ms

Screenshot/screencast of this PR

What issues does this PR fix or reference?

How to test this PR?

  • Run SmokeTest as usually
  • To check getProjectNameFromGitUrl:
    -- create test-string-util.js temporary file in e2e folder:
// Temporary test to check the getProjectNameFromGitUrl method
class MockLogger {
    static debug(msg) {
        console.log(`[DEBUG] ${msg}`);
    }
}

// Copy a logic
function getProjectNameFromGitUrl(url) {
    MockLogger.debug(`Original URL: ${url}`);

    // remove query and hash fragments
    url = url.split('?')[0].split('#')[0];

    // remove branch/tree fragments for GitHub, GitLab, Bitbucket
    if (url.includes('/-/tree/')) {
        // GitLab specific pattern: remove everything from /-/tree/ onwards
        url = url.substring(0, url.indexOf('/-/tree/'));
    } else if (url.includes('/tree/')) {
        // GitHub pattern: remove /tree/ and everything after it
        url = url.substring(0, url.indexOf('/tree/'));
    } else if (url.includes('/src/')) {
        // Bitbucket pattern: remove /src/ and everything after it
        url = url.substring(0, url.indexOf('/src/'));
    }

    const projectName = url
        .split(/[\/.]/)
        .filter((e) => !['git', ''].includes(e))
        .reverse()[0];

    MockLogger.debug(`Extracted project name: ${projectName}`);
    return projectName;
}

// Test cases
const testCases = [
    {
        url: 'https://gitlab-gitlab-system.apps.git.crw-qe.com/test-user/private-gitlab-repo.git/-/tree/refreshToken?new',
        expected: 'private-gitlab-repo',
        description: 'GitLab URL with branch and query parameters'
    },
    {
        url: 'https://github.com/crw-qe/ubi9-based-sample-public/tree/ubi9',
        expected: 'ubi9-based-sample-public',
        description: 'GitHub URL with branch'
    },
    {
        url: 'https://github.com/che-incubator/quarkus-api-example.git?new',
        expected: 'quarkus-api-example',
        description: 'GitHub URL with query parameters'
    },
    {
        url: 'https://gitlab.com/user/repo.git/-/tree/branch',
        expected: 'repo',
        description: 'GitLab URL with branch'
    },
    {
        url: 'https://github.com/user/repo.git',
        expected: 'repo',
        description: 'Simple GitHub URL'
    },
    {
        url: 'https://github.com/user/repo.git/tree/main',
        expected: 'repo',
        description: 'GitHub URL with branch'
    },
    {
        url: 'https://[email protected]/username/repo.git',
        expected: 'repo',
        description: 'Bitbucket URL with username'
    },
    {
        url: 'https://bitbucket.org/user/repo.git/src/main',
        expected: 'repo',
        description: 'Bitbucket URL with branch'
    },
    {
        url: 'ssh://[email protected]/~admin/repo.git',
        expected: 'repo',
        description: 'Bitbucket SSH URL'
    }
];

console.log('=== Тesting method getProjectNameFromGitUrl ===\n');

let passed = 0;
let failed = 0;

testCases.forEach((testCase, index) => {
    console.log(`\nТест ${index + 1}: ${testCase.description}`);
    console.log(`URL: ${testCase.url}`);
    
    const result = getProjectNameFromGitUrl(testCase.url);
    
    console.log(`Expected: '${testCase.expected}'`);
    console.log(`Got: '${result}'`);
    
    if (result === testCase.expected) {
        console.log(`✅ PASSED`);
        passed++;
    } else {
        console.log(`❌ FAILED`);
        failed++;
    }
    console.log('---');
});

console.log(`\n=== Results ===`);
console.log(`✅ PASSED tests: ${passed}`);
console.log(`❌ FAILED tests: ${failed}`);
console.log(`Total tests: ${passed + failed}`);

-- run it by command node test-string-util.js , see results:

[ashmaraiev@fedora e2e]$ node test-string-util.js 
=== Тesting method getProjectNameFromGitUrl ===


Тест 1: GitLab URL with branch and query parameters
URL: https://gitlab-gitlab-system.apps.git.crw-qe.com/test-user/private-gitlab-repo.git/-/tree/refreshToken?new
[DEBUG] Original URL: https://gitlab-gitlab-system.apps.git.crw-qe.com/test-user/private-gitlab-repo.git/-/tree/refreshToken?new
[DEBUG] Extracted project name: private-gitlab-repo
Expected: 'private-gitlab-repo'
Got: 'private-gitlab-repo'
✅ PASSED
---

Тест 2: GitHub URL with branch
URL: https://github.com/crw-qe/ubi9-based-sample-public/tree/ubi9
[DEBUG] Original URL: https://github.com/crw-qe/ubi9-based-sample-public/tree/ubi9
[DEBUG] Extracted project name: ubi9-based-sample-public
Expected: 'ubi9-based-sample-public'
Got: 'ubi9-based-sample-public'
✅ PASSED
---

Тест 3: GitHub URL with query parameters
URL: https://github.com/che-incubator/quarkus-api-example.git?new
[DEBUG] Original URL: https://github.com/che-incubator/quarkus-api-example.git?new
[DEBUG] Extracted project name: quarkus-api-example
Expected: 'quarkus-api-example'
Got: 'quarkus-api-example'
✅ PASSED
---

Тест 4: GitLab URL with branch
URL: https://gitlab.com/user/repo.git/-/tree/branch
[DEBUG] Original URL: https://gitlab.com/user/repo.git/-/tree/branch
[DEBUG] Extracted project name: repo
Expected: 'repo'
Got: 'repo'
✅ PASSED
---

Тест 5: Simple GitHub URL
URL: https://github.com/user/repo.git
[DEBUG] Original URL: https://github.com/user/repo.git
[DEBUG] Extracted project name: repo
Expected: 'repo'
Got: 'repo'
✅ PASSED
---

Тест 6: GitHub URL with branch
URL: https://github.com/user/repo.git/tree/main
[DEBUG] Original URL: https://github.com/user/repo.git/tree/main
[DEBUG] Extracted project name: repo
Expected: 'repo'
Got: 'repo'
✅ PASSED
---

Тест 7: Bitbucket URL with username
URL: https://[email protected]/username/repo.git
[DEBUG] Original URL: https://[email protected]/username/repo.git
[DEBUG] Extracted project name: repo
Expected: 'repo'
Got: 'repo'
✅ PASSED
---

Тест 8: Bitbucket URL with branch
URL: https://bitbucket.org/user/repo.git/src/main
[DEBUG] Original URL: https://bitbucket.org/user/repo.git/src/main
[DEBUG] Extracted project name: repo
Expected: 'repo'
Got: 'repo'
✅ PASSED
---

Тест 9: Bitbucket SSH URL
URL: ssh://[email protected]/~admin/repo.git
[DEBUG] Original URL: ssh://[email protected]/~admin/repo.git
[DEBUG] Extracted project name: repo
Expected: 'repo'
Got: 'repo'
✅ PASSED
---

=== Results ===
✅ PASSED tests: 9
❌ FAILED tests: 0
Total tests: 9

PR Checklist

As the author of this Pull Request I made sure that:

Reviewers

Reviewers, please comment how you tested the PR when approving it.

@artaleks9 artaleks9 self-assigned this Nov 19, 2025
@artaleks9 artaleks9 requested review from SkorikSergey and removed request for musienko-maxim November 19, 2025 09:07
Copy link
Contributor

@dmytro-ndp dmytro-ndp 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 to merge with non-critical comment.

@artaleks9 artaleks9 merged commit 5808533 into main Nov 19, 2025
6 checks passed
@artaleks9 artaleks9 deleted the fix-string-utils branch November 19, 2025 16:44
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