From 4a2a39c13376db44e3116994e975d8218efcdcd6 Mon Sep 17 00:00:00 2001 From: Dima May Date: Wed, 19 Jun 2024 14:23:44 +0000 Subject: [PATCH] #2490: fixing oauth tests --- .github/workflows/build-and-test.yml | 11 ++++---- .../e2e/approver/approver_conf_users_spec.js | 26 ++++++++++++------- .../e2e/projects_admin_management_spec.js | 6 ++++- .../skills/storage/repos/UserAttrsRepo.groovy | 2 +- 4 files changed, 28 insertions(+), 17 deletions(-) diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index 70fdc35b1d..3c59f7e06d 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -18,12 +18,11 @@ on: schedule: - cron: '0 5 * * *' workflow_dispatch: -# push: -# paths-ignore: -# - 'README.md' -# - '.github/workflows/build-and-test-postgres.yml' -# - '.github/workflows/publish-image-snapshot.yml' -# - '.gitlab-ci.yml' + push: + paths-ignore: + - 'README.md' + - '.github/workflows/build-and-test-postgres.yml' + - '.github/workflows/publish-image-snapshot.yml' jobs: build-skills-service-for-ui-tests: diff --git a/e2e-tests/cypress/e2e/approver/approver_conf_users_spec.js b/e2e-tests/cypress/e2e/approver/approver_conf_users_spec.js index 4b5df53070..04ac7780d2 100644 --- a/e2e-tests/cypress/e2e/approver/approver_conf_users_spec.js +++ b/e2e-tests/cypress/e2e/approver/approver_conf_users_spec.js @@ -200,15 +200,23 @@ describe('Approver Config Users Tests', () => { const headerSelector = `${tableSelector} thead tr th`; cy.get(headerSelector).contains('User').click(); - cy.selectItem(`[data-cy="expandedChild_${user1}"] [data-cy="userIdInput"] #existingUserInput`, 'userE', true, true); - cy.get(`[data-cy="expandedChild_${user1}"] [data-cy="addUserConfBtn"]`).click() - cy.validateTable(tableSelector, [ - [{ colIndex: 0, value: 'userA' }], - [{ colIndex: 0, value: 'userB' }], - [{ colIndex: 0, value: 'userC' }], - [{ colIndex: 0, value: 'userD' }], - [{ colIndex: 0, value: 'userE' }], - ], 4); + cy.fixture('vars.json').then((vars) => { + const defaultUser = Cypress.env('oauthMode') ? 'foo' : vars.defaultUser + cy.selectItem(`[data-cy="expandedChild_${user1}"] [data-cy="userIdInput"] #existingUserInput`, defaultUser, true, true); + cy.get(`[data-cy="expandedChild_${user1}"] [data-cy="addUserConfBtn"]`).click() + + const compare = (a, b) => { + return a[0].value?.localeCompare(b[0].value) + } + const expected = [ + [{ colIndex: 0, value: 'userA' }], + [{ colIndex: 0, value: 'userB' }], + [{ colIndex: 0, value: 'userC' }], + [{ colIndex: 0, value: 'userD' }], + [{ colIndex: 0, value: defaultUser }], + ].sort(compare) + cy.validateTable(tableSelector, expected, 4); + }) }) }); diff --git a/e2e-tests/cypress/e2e/projects_admin_management_spec.js b/e2e-tests/cypress/e2e/projects_admin_management_spec.js index cdb0f77282..12f611378b 100644 --- a/e2e-tests/cypress/e2e/projects_admin_management_spec.js +++ b/e2e-tests/cypress/e2e/projects_admin_management_spec.js @@ -335,10 +335,14 @@ describe('Projects Admin Management Tests', () => { cy.get('[data-pc-section="panel"] [data-pc-section="itemlabel"]').contains('Administrator').click(); cy.wait('@addAdmin') cy.get(`${tableSelector} thead th`).contains('User').click(); + + const compare = (a, b) => { + return a[0].value?.localeCompare(b[0].value) + } cy.validateTable(tableSelector, [ [{ colIndex: 0, value: 'root@' }, { colIndex: 1, value: 'Administrator' }], [{ colIndex: 0, value: expectedUserName }, { colIndex: 1, value: 'Administrator' }], - ], 5, true, null, false); + ].sort(compare), 5, true, null, false); }); it('Existing users are not suggested', () => { diff --git a/service/src/main/java/skills/storage/repos/UserAttrsRepo.groovy b/service/src/main/java/skills/storage/repos/UserAttrsRepo.groovy index ac84d22f34..bc20b2d07b 100644 --- a/service/src/main/java/skills/storage/repos/UserAttrsRepo.groovy +++ b/service/src/main/java/skills/storage/repos/UserAttrsRepo.groovy @@ -43,7 +43,7 @@ interface UserAttrsRepo extends CrudRepository { @Query(value='''select attrs.email from user_attrs attrs where attrs.user_id = ?1''', nativeQuery = true) String findEmailByUserId(String userId) - @Query("SELECT DISTINCT(ua.userIdForDisplay) from UserAttrs ua where lower(ua.userIdForDisplay) LIKE %?1% order by ua.userIdForDisplay asc" ) + @Query("SELECT DISTINCT(ua.userId) from UserAttrs ua where lower(ua.userId) LIKE %?1% order by ua.userId asc" ) List findDistinctUserIdForDisplay(String userUserIdForDisplayQuery, Pageable pageable) }