forked from rancher/dashboard
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Yonas Berhe
authored and
Yonas Berhe
committed
Nov 28, 2024
1 parent
907875f
commit 5c20bdd
Showing
20 changed files
with
1,124 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
import PagePo from '@/cypress/e2e/po/pages/page.po'; | ||
import RadioGroupInputPo from '@/cypress/e2e/po/components/radio-group-input.po'; | ||
import LabeledInputPo from '@/cypress/e2e/po/components/labeled-input.po'; | ||
import AsyncButtonPo from '@/cypress/e2e/po/components/async-button.po'; | ||
import ProductNavPo from '@/cypress/e2e/po/side-bars/product-side-nav.po'; | ||
import BurgerMenuPo from '@/cypress/e2e/po/side-bars/burger-side-menu.po'; | ||
import BannersPo from '@/cypress/e2e/po/components/banners.po'; | ||
import LabeledSelectPo from '@/cypress/e2e/po/components/labeled-select.po'; | ||
|
||
export default class GitHubPo extends PagePo { | ||
private static createPath(clusterId: string) { | ||
return `/c/${ clusterId }/auth/config/github?mode=edit`; | ||
} | ||
|
||
static goTo(clusterId: string): Cypress.Chainable<Cypress.AUTWindow> { | ||
return super.goTo(GitHubPo.createPath(clusterId)); | ||
} | ||
|
||
constructor(clusterId: string) { | ||
super(GitHubPo.createPath(clusterId)); | ||
} | ||
|
||
static navTo() { | ||
const sideNav = new ProductNavPo(); | ||
|
||
BurgerMenuPo.burgerMenuNavToMenubyLabel('Users & Authentication'); | ||
sideNav.navToSideMenuEntryByLabel('Auth Provider'); | ||
} | ||
|
||
githubAppLink() { | ||
return this.self().get('ul.step-list [href="https://github.com/settings/developers"]').then((el) => { | ||
expect(el).to.have.attr('target'); | ||
}) | ||
.invoke('removeAttr', 'target'); | ||
} | ||
|
||
authConfigRadioBtn(): RadioGroupInputPo { | ||
return new RadioGroupInputPo('[data-testid="access-mode-options"]'); | ||
} | ||
|
||
selectLoginCofigOption(index: number): Cypress.Chainable { | ||
return this.authConfigRadioBtn().set(index); | ||
} | ||
|
||
bannerContent(element:string) { | ||
return new BannersPo('[data-testid="banner-content"]', this.self()).bannerElement(element); | ||
} | ||
|
||
clientId() { | ||
return new LabeledInputPo('[data-testid="input-github-clientId"]'); | ||
} | ||
|
||
clientSecret() { | ||
return new LabeledInputPo('[data-testid="input-github-clientSecret"]'); | ||
} | ||
|
||
disable() { | ||
return this.bannerContent('button').contains('Disable').click(); | ||
} | ||
|
||
usersAndGroupsArrayListItem(index: number) { | ||
return this.self().find(`[data-testid="array-list-box${ index }"]`); | ||
} | ||
|
||
addMemberSearch() { | ||
return new LabeledSelectPo('.labeled-select.select-principal', this.self()); | ||
} | ||
|
||
cancelButton(): AsyncButtonPo { | ||
return new AsyncButtonPo('[data-testid="form-cancel"]', this.self()); | ||
} | ||
|
||
saveButton(): AsyncButtonPo { | ||
return new AsyncButtonPo('[data-testid="form-save"]', this.self()); | ||
} | ||
|
||
save() { | ||
return new AsyncButtonPo('[data-testid="form-save"]').click(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/* eslint-disable cypress/no-unnecessary-waiting */ | ||
export default class GitHubThirdPartyPo { | ||
usernameField(text: string) { | ||
return cy.get('#login_field').should('be.visible').clear().type(text, { force: true, delay: 100 }); | ||
} | ||
|
||
passwordField(text: string) { | ||
return cy.get('#password').should('be.visible').clear().type(text, { force: true, delay: 100 }); | ||
} | ||
|
||
signInButton() { | ||
return cy.get('input').contains('Sign in'); | ||
} | ||
|
||
appNameField(text: string) { | ||
return cy.get('#oauth_application_name').type(text); | ||
} | ||
|
||
oauthApplicationUrl(text: string) { | ||
return cy.get('#oauth_application_url').type(text); | ||
} | ||
|
||
oauthApplicationCallbackUrl(text: string) { | ||
return cy.get('#oauth_application_callback_url').type(text); | ||
} | ||
|
||
registerAppButton() { | ||
return cy.get('button.btn').contains('Register application'); | ||
} | ||
|
||
generateClientSecret() { | ||
return cy.get('input.btn').contains('Generate a new client secret'); | ||
} | ||
|
||
newOauthToken() { | ||
return cy.get('#new-oauth-token'); | ||
} | ||
|
||
authorizeButton(options: any) { | ||
return cy.get('button[name="authorize"][value="1"]', options).should('be.enabled').click(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
|
||
describe('Email Code Extraction', () => { | ||
it('should extract code from the Gmail email body', () => { | ||
const emailSearchQuery = 'subject:[GitHub] Please verify your device'; | ||
|
||
// Call the fetchGmailMessages custom command to get the email messages | ||
cy.fetchGmailMessage(emailSearchQuery).then((resp: Cypress.Response<any>) => { | ||
const emailBody = resp.body.payload.body.data; | ||
|
||
// Decode the base64 content (Gmail API returns email body in base64url encoding) | ||
const decodedBody = Cypress.Buffer.from(emailBody, 'base64').toString('utf-8'); | ||
|
||
// Regex to extract the 6-digit code | ||
const match = decodedBody.match(/(\d{6})/); | ||
|
||
if (match) { | ||
const code = match[1]; // Extracted code | ||
|
||
cy.log('Extracted Code:', code); | ||
} else { | ||
cy.log('No code found'); | ||
} | ||
}); | ||
}); | ||
}); |
Oops, something went wrong.