-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Signup fix #14
base: develop
Are you sure you want to change the base?
Signup fix #14
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ const config = require("config"); | |
const URLS = require("../../constants/urls"); | ||
|
||
const { HOME_PAGE, SIGN_UP_PAGE, MY_HOST } = URLS; | ||
const {signupPageTitle} = require("../../constants/pageTitles") | ||
const {signupPageTitle} = require("../../constants/pageTitles"); | ||
|
||
|
||
let browser, page; | ||
|
@@ -20,9 +20,9 @@ beforeAll(async () => { | |
headless: false, | ||
slowMo: 0, | ||
}); | ||
|
||
const context = await browser.createIncognitoBrowserContext(); | ||
|
||
page = await context.newPage(); | ||
return page; | ||
}); | ||
|
@@ -31,39 +31,92 @@ afterAll(async () => { | |
await browser.close(); | ||
}); | ||
|
||
describe("New user navigates in the page", () => { | ||
test("New user sees a sign up page", async () => { | ||
describe('New user navigates in the page', () => { | ||
// const response = { | ||
// id: "<>", | ||
// incompleteUserDetails: true, | ||
// github_display_name: "<>", | ||
// github_id: "<>" | ||
// } | ||
|
||
test('New user sees a sign up page', async () => { | ||
await page.goto(HOME_PAGE); | ||
|
||
await page.waitForResponse((res) => res.url().endsWith("/users/self")); | ||
await page.waitForSelector("button.login-btn-text"); | ||
await page.waitForResponse((res) => res.url().endsWith('/users/self')); | ||
await page.waitForSelector('button.login-btn-text'); | ||
|
||
await Promise.all([ | ||
page.waitForNavigation(), | ||
page.click("button.login-btn-text"), | ||
page.click('button.login-btn-text'), | ||
]); | ||
|
||
const ghUsernameInput = await page.waitForSelector("input#login_field"); | ||
const ghPasswordInput = await page.waitForSelector("input#password"); | ||
|
||
await ghUsernameInput.type(config.get("testUser.username")); | ||
await ghPasswordInput.type(config.get("testUser.password")); | ||
await Promise.all([page.waitForNavigation(), page.keyboard.press("Enter")]); | ||
await page.waitForSelector("button#js-oauth-authorize-btn"); | ||
const ghUsernameInput = await page.waitForSelector('input#login_field'); | ||
const ghPasswordInput = await page.waitForSelector('input#password'); | ||
|
||
await ghUsernameInput.type(config.get('testUser.username')); | ||
await ghPasswordInput.type(config.get('testUser.password')); | ||
await Promise.all([page.waitForNavigation(), page.keyboard.press('Enter')]); | ||
try { | ||
await page.waitForSelector('button#js-oauth-authorize-btn'); | ||
} catch (err) { | ||
console.log( | ||
'The test user credentials are wrong or your test account is already has RDS as an OAuth application.', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. remove console.log |
||
err | ||
); | ||
} | ||
await delay(2000); | ||
await page.click("button#js-oauth-authorize-btn"); | ||
await page.click('button#js-oauth-authorize-btn'); | ||
await page.waitForNavigation(); | ||
await page.waitForFunction( | ||
`window.location.href.includes("${SIGN_UP_PAGE}")` | ||
window.location.href.includes(`${SIGN_UP_PAGE}`) | ||
); | ||
await page.waitForSelector("button.submitButton"); | ||
await page.screenshot({ path: "tmp/sign-up-form.png" }); | ||
await page.waitForSelector('button.submitButton'); | ||
await page.screenshot({ path: 'tmp/sign-up-form.png' }); | ||
const pageTitle = await page.title(); | ||
expect(pageTitle).toMatch(signupPageTitle); | ||
}); | ||
//For mocking github api -->> | ||
// page.on('request', (request) => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. remove commented code |
||
// if(request.url().includes('github.com/login')){ | ||
// request.response({ | ||
// headers: { | ||
// "Content-Type": "application/json" | ||
// }, | ||
// body: JSON.stringify({ | ||
// access_token: "gho_16C7e42F292c6912E7710c838347Ae178B4a", | ||
// token_type: "bearer", | ||
// scope: "<>" | ||
// }) | ||
// }) | ||
// } | ||
// }); | ||
|
||
//for mocking /users/self api -->> | ||
// page.on('request', (request) => { | ||
// if(request.url().endsWith("/users/self")) { | ||
// console.log('inside self'); | ||
// request.respond({ | ||
// headers: { | ||
// "Accept": "application/json" | ||
// }, | ||
// body: JSON.stringify({ response }) | ||
// }) | ||
// } else { | ||
// console.log('entering else'); | ||
// } | ||
// }); | ||
test.skip('401 response if new user haven\'t sign-in with github', async () => { | ||
await page.goto(HOME_PAGE); | ||
await page.goto(SIGN_UP_PAGE); | ||
const cookies = page.cookies(); | ||
cookies.then(cookies => { | ||
const rdsSession = cookies.find(cookie => cookie["name"] === 'rds-session') | ||
expect(rdsSession).toBeUndefined(); | ||
}); | ||
}) | ||
}); | ||
|
||
describe("New user sign up page works correctly", () => { | ||
describe.skip("New user sign up page works correctly", () => { | ||
beforeEach(async () => { | ||
await page.setRequestInterception(true); | ||
}); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"testUser" : { | ||
"username" : "", | ||
"password" : "" | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
const signupPageTitle = /Sign Up/; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please follow the |
||
|
||
module.exports = signupPageTitle; | ||
module.exports = {signupPageTitle}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,6 +12,6 @@ | |
"jest": "^27.1.0" | ||
}, | ||
"scripts": { | ||
"test": "jest" | ||
"test": "jest sign-up" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The settings in the |
||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove commented code