Upload 5.23

This commit is contained in:
Andrew Trieu
2023-06-22 16:11:10 +03:00
parent 24a4e4cc2f
commit d73c3d8d48
15 changed files with 2545 additions and 33 deletions

View File

@@ -0,0 +1,102 @@
describe('blog app', function () {
beforeEach(function () {
cy.request('POST', 'http://localhost:3001/api/testing/reset')
cy.request('POST', 'http://localhost:3001/api/users/', {
name: 'Andrew',
username: 'andyyyyy',
password: '123456',
})
cy.request('POST', 'http://localhost:3001/api/users/', {
name: 'Matti Luukkainen',
username: 'mluukkai',
password: 'salainen',
})
cy.visit('http://localhost:3000')
})
it('front page can be opened', function () {
cy.contains('Bloglist')
cy.contains('Please log in')
cy.contains('Username')
cy.contains('Password')
cy.contains('Login')
})
describe('when logged in', function () {
beforeEach(function () {
it('login succeeds with correct credentials', function () {
cy.get('.username').type('andyyyyy')
cy.get('.password').type('123456')
cy.get('.loginButton').click()
})
cy.contains('Andrew logged in')
})
it('a new blog can be created', function () {
cy.contains('New blog').click()
cy.get('.title').type('a blog created')
cy.get('.author').type('cypress')
cy.get('.urlAddress').type('cypress.com')
cy.get('.createButton').click()
cy.contains('a blog created by cypress')
})
it('a blog can be liked', function () {
cy.contains('New blog').click()
cy.get('.title').type('a blog created')
cy.get('.author').type('cypress')
cy.get('.urlAddress').type('cypress.com')
cy.get('.createButton').click()
cy.contains('a blog created by cypress')
cy.contains('View').click()
cy.contains('+').click()
cy.contains('1')
})
it('a blog can be deleted', function () {
cy.contains('New blog').click()
cy.get('.title').type('a blog created')
cy.get('.author').type('cypress')
cy.get('.urlAddress').type('cypress.com')
cy.get('.createButton').click()
cy.contains('a blog created by cypress')
cy.contains('View').click()
cy.contains('Remove').click()
cy.get('html').should('not.contain', 'a blog created by cypress')
})
it('only the creator can delete a blog', function () {
cy.contains('New blog').click()
cy.get('.title').type('a blog created')
cy.get('.author').type('cypress')
cy.get('.urlAddress').type('cypress.com')
cy.get('.createButton').click()
cy.contains('a blog created by cypress')
cy.get('.logoutButton').click()
cy.get('.username').type('mluukkai')
cy.get('.password').type('salainen')
cy.get('.loginButton').click()
cy.contains('View').click()
cy.contains('Remove').click()
cy.contains('a blog created by cypress')
})
it('blogs are ordered according to likes', function () {
cy.contains('New blog').click()
cy.get('.title').type('another blog created')
cy.get('.author').type('cypress')
cy.get('.urlAddress').type('cypress.com')
cy.get('.createButton').click()
cy.contains('another blog created by cypress')
cy.contains('View').click()
cy.contains('+').click()
cy.wait(1000)
cy.contains('+').click()
cy.wait(1000)
cy.visit('http://localhost:3000')
cy.get('.blog').eq(0).should('contain', 'another blog created by cypress')
cy.get('.blog').eq(1).should('contain', 'a blog created by cypress')
})
})
})

View File

@@ -0,0 +1,5 @@
{
"name": "Using fixtures to represent data",
"email": "hello@cypress.io",
"body": "Fixtures are a great way to mock data for responses to routes"
}

View File

@@ -0,0 +1,25 @@
// ***********************************************
// This example commands.js shows you how to
// create various custom commands and overwrite
// existing commands.
//
// For more comprehensive examples of custom
// commands please read more here:
// https://on.cypress.io/custom-commands
// ***********************************************
//
//
// -- This is a parent command --
// Cypress.Commands.add('login', (email, password) => { ... })
//
//
// -- This is a child command --
// Cypress.Commands.add('drag', { prevSubject: 'element'}, (subject, options) => { ... })
//
//
// -- This is a dual command --
// Cypress.Commands.add('dismiss', { prevSubject: 'optional'}, (subject, options) => { ... })
//
//
// -- This will overwrite an existing command --
// Cypress.Commands.overwrite('visit', (originalFn, url, options) => { ... })

View File

@@ -0,0 +1,20 @@
// ***********************************************************
// This example support/e2e.js is processed and
// loaded automatically before your test files.
//
// This is a great place to put global configuration and
// behavior that modifies Cypress.
//
// You can change the location of this file or turn off
// automatically serving support files with the
// 'supportFile' configuration option.
//
// You can read more here:
// https://on.cypress.io/configuration
// ***********************************************************
// Import commands.js using ES2015 syntax:
import './commands'
// Alternatively you can use CommonJS syntax:
// require('./commands')