diff --git a/cypress/e2e/auth.cy.ts b/cypress/e2e/auth.cy.ts
index ff73c87..0f426f2 100644
--- a/cypress/e2e/auth.cy.ts
+++ b/cypress/e2e/auth.cy.ts
@@ -1,6 +1,12 @@
import { ROUTES } from './constant'
describe('Auth', () => {
+ beforeEach(() => {
+ cy.intercept('GET', /users/, { fixture: 'user.json' }).as('getUser')
+ cy.intercept('GET', /tags/, { fixture: 'tags.json' }).as('getTags')
+ cy.intercept('GET', /articles/, { fixture: 'articles.json' }).as('getArticles')
+ })
+
describe('Login and logout', () => {
it('should login success when submit a valid login form', () => {
cy.login()
@@ -51,10 +57,22 @@ describe('Auth', () => {
it('should not allow visiting login page when the user is logged in', () => {
cy.login()
- cy.visit('/#/login')
+ cy.visit(ROUTES.LOGIN)
cy.url().should('match', /\/#\/$/)
})
+
+ it('should has credential header after login success', () => {
+ cy.login()
+
+ cy.visit(ROUTES.SETTINGS)
+ cy.intercept('PUT', /user/).as('updateSettingsRequest')
+
+ cy.findByRole('textbox', { name: 'Username' }).type('foo')
+ cy.findByRole('button', { name: 'Update Settings' }).click()
+
+ cy.wait('@updateSettingsRequest').its('request.headers').should('have.property', 'authorization')
+ })
})
describe('Register', () => {
diff --git a/src/pages/Settings.vue b/src/pages/Settings.vue
index aea6371..3a55459 100644
--- a/src/pages/Settings.vue
+++ b/src/pages/Settings.vue
@@ -54,7 +54,7 @@