Skip to content

Commit

Permalink
chore: Update action login as developer and flow e2e login happy path…
Browse files Browse the repository at this point in the history
… to include the cookie COOKIE_FIRST_TIME_LOGIN to prevent redirecting to routes developer welcome after login successfully (#261)
  • Loading branch information
NghiaPham authored Jan 14, 2020
1 parent c262cf8 commit 2cf6070
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
8 changes: 8 additions & 0 deletions cypress/integration/flow-login-happy-path.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import loginPage from '../pages/login-page'
import { COOKIE_FIRST_TIME_LOGIN } from '@/utils/cookie'
import clientAppsPage from '../pages/client-apps-page'
import developerPage from '../pages/developer-page'
import adminApprovalsPage from '../pages/admin-approvals-page'
Expand Down Expand Up @@ -55,6 +56,13 @@ describe('Login happy path', () => {
]
for (const { container, email, password, testCaseName, loginUrl } of testCases) {
it(testCaseName, done => {
if (testCaseName === 'Login successfully using DEVELOPER account') {
// This cookie prevents redirecting to routes.DEVELOPER_WELCOME page
// Redirecting to routes.DEVELOPER_WELCOME will be tested in the different e2e test case
const now = new Date()
cy.setCookie(COOKIE_FIRST_TIME_LOGIN, now.toString())
}

cy.visit(loginUrl)
cy.get(inputEmail).type(email)
cy.get(inputPassword).type(password)
Expand Down
6 changes: 6 additions & 0 deletions cypress/pages/login-page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import routes from '@/constants/routes'
import clientAppsPage from '../pages/client-apps-page'
import developerAppsPage from './developer-page'
import adminApprovalsPage from '../pages/admin-approvals-page'
import { COOKIE_FIRST_TIME_LOGIN } from '@/utils/cookie'

const loginPageMetadata = {
loginAsClientUrl: routes.CLIENT_LOGIN,
Expand All @@ -18,6 +19,11 @@ const loginPage = {
...loginPageMetadata,
actions: {
loginUsingDeveloperAccount(email?: string, password?: string) {
// This cookie prevents redirecting to routes.DEVELOPER_WELCOME page when login as a developer
// Redirecting to routes.DEVELOPER_WELCOME will be tested in the different e2e test case
const now = new Date()
cy.setCookie(COOKIE_FIRST_TIME_LOGIN, now.toString())

const {
loginAsDeveloperUrl,
selectors: { buttonLogin, inputPassword, inputEmail }
Expand Down

0 comments on commit 2cf6070

Please sign in to comment.