|
| 1 | +import HomePagePo from '@/cypress/e2e/po/pages/home.po'; |
| 2 | +import GithubAppPo from '@/cypress/e2e/po/edit/auth/githubapp.po'; |
| 3 | +import { AuthProvider, AuthProviderPo } from '@/cypress/e2e/po/pages/users-and-auth/authProvider.po'; |
| 4 | + |
| 5 | +const authProviderPo = new AuthProviderPo('local'); |
| 6 | +const githubAppPo = new GithubAppPo('local'); |
| 7 | + |
| 8 | +const clientId = 'test-client-id'; |
| 9 | +const clientSecret = 'test-client-secret'; |
| 10 | +const appId = 'test-app-id'; |
| 11 | +const privateKey = 'test-private-key'; |
| 12 | + |
| 13 | +const mockStatusCode = 200; |
| 14 | +const mockBody = {}; |
| 15 | + |
| 16 | +describe('GitHub App', { tags: ['@adminUser', '@usersAndAuths'] }, () => { |
| 17 | + beforeEach(() => { |
| 18 | + cy.login(); |
| 19 | + HomePagePo.goToAndWaitForGet(); |
| 20 | + AuthProviderPo.navTo(); |
| 21 | + authProviderPo.waitForPage(); |
| 22 | + authProviderPo.selectProvider(AuthProvider.GITHUB_APP); |
| 23 | + githubAppPo.waitForPage(); |
| 24 | + }); |
| 25 | + |
| 26 | + it('can navigate to Auth Provider and Select GitHub App', () => { |
| 27 | + githubAppPo.mastheadTitle().should('include', `GitHub App`); |
| 28 | + |
| 29 | + githubAppPo.gitHubAppBanner().should('be.visible'); |
| 30 | + githubAppPo.permissionsWarningBanner().should('be.visible'); |
| 31 | + }); |
| 32 | + |
| 33 | + it('sends correct request to create GitHub App auth provider', () => { |
| 34 | + cy.intercept('POST', 'v3/githubAppConfigs/githubapp?action=configureTest', (req) => { |
| 35 | + expect(req.body.enabled).to.equal(false); |
| 36 | + expect(req.body.id).to.equal('githubapp'); |
| 37 | + expect(req.body.type).to.equal('githubAppConfig'); |
| 38 | + expect(req.body.clientId).to.equal(clientId); |
| 39 | + expect(req.body.clientSecret).to.equal(clientSecret); |
| 40 | + expect(req.body.appId).to.equal(appId); |
| 41 | + expect(req.body.privateKey).to.equal(privateKey); |
| 42 | + |
| 43 | + req.reply(mockStatusCode, mockBody); |
| 44 | + |
| 45 | + return true; |
| 46 | + }).as('configureTest'); |
| 47 | + |
| 48 | + // save should be disabled before values are filled |
| 49 | + githubAppPo.saveButton().expectToBeDisabled(); |
| 50 | + githubAppPo.enterClientId(clientId); |
| 51 | + githubAppPo.enterClientSecret(clientSecret); |
| 52 | + githubAppPo.enterGitHubAppId(appId); |
| 53 | + githubAppPo.enterPrivateKey(privateKey); |
| 54 | + |
| 55 | + // save should be enabled after values are filled |
| 56 | + githubAppPo.saveButton().expectToBeEnabled(); |
| 57 | + githubAppPo.save(); |
| 58 | + cy.wait('@configureTest'); |
| 59 | + }); |
| 60 | +}); |
0 commit comments