mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-05-15 07:34:42 -04:00
changed calls to cy.route to cy.intercept (#806)
Signed-off-by: Philip Molares <philip.molares@udo.edu>
This commit is contained in:
parent
bc7ff07256
commit
e0dbb05572
5 changed files with 87 additions and 49 deletions
|
@ -1,6 +1,5 @@
|
||||||
{
|
{
|
||||||
"baseUrl": "http://127.0.0.1:3001/",
|
"baseUrl": "http://127.0.0.1:3001/",
|
||||||
"defaultCommandTimeout": 15000,
|
"defaultCommandTimeout": 15000,
|
||||||
"experimentalFetchPolyfill": true,
|
|
||||||
"video": false
|
"video": false
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,12 +24,44 @@ describe('History', () => {
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('Pinning', () => {
|
describe('Pinning', () => {
|
||||||
|
describe('working', () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
cy.route({
|
cy.intercept('PUT', '/api/v2/history/features', (req) => {
|
||||||
method: 'PUT',
|
req.reply(200, req.body)
|
||||||
url: '/api/v2/history/**',
|
})
|
||||||
status: 401,
|
})
|
||||||
response: {}
|
|
||||||
|
it('Cards', () => {
|
||||||
|
cy.get('div.card')
|
||||||
|
.should('be.visible')
|
||||||
|
cy.get('.history-pin.btn')
|
||||||
|
.first()
|
||||||
|
.as('pin-button')
|
||||||
|
cy.get('@pin-button')
|
||||||
|
.should('not.have.class', 'pinned')
|
||||||
|
.click()
|
||||||
|
cy.get('@pin-button')
|
||||||
|
.should('have.class', 'pinned')
|
||||||
|
})
|
||||||
|
|
||||||
|
it('Table', () => {
|
||||||
|
cy.get('i.fa-table')
|
||||||
|
.click()
|
||||||
|
cy.get('.history-pin.btn')
|
||||||
|
.first()
|
||||||
|
.as('pin-button')
|
||||||
|
cy.get('@pin-button')
|
||||||
|
.should('not.have.class', 'pinned')
|
||||||
|
.click()
|
||||||
|
cy.get('@pin-button')
|
||||||
|
.should('have.class', 'pinned')
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
describe('failing', () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
cy.intercept('PUT', '/api/v2/history/features', {
|
||||||
|
statusCode: 401
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -54,3 +86,4 @@ describe('History', () => {
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
})
|
||||||
|
|
|
@ -6,29 +6,32 @@
|
||||||
|
|
||||||
describe('profile page', () => {
|
describe('profile page', () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
cy.route({
|
cy.intercept({
|
||||||
url: '/api/v2/tokens',
|
url: '/api/v2/tokens',
|
||||||
method: 'GET',
|
method: 'GET'
|
||||||
response: [
|
}, {
|
||||||
|
body: [
|
||||||
{
|
{
|
||||||
label: "cypress-App",
|
label: "cypress-App",
|
||||||
created: 1601991518
|
created: 1601991518
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
})
|
})
|
||||||
cy.route({
|
cy.intercept({
|
||||||
url: '/api/v2/tokens',
|
url: '/api/v2/tokens',
|
||||||
method: 'POST',
|
method: 'POST'
|
||||||
response: {
|
}, {
|
||||||
|
body: {
|
||||||
label: 'cypress',
|
label: 'cypress',
|
||||||
secret: 'c-y-p-r-e-s-s',
|
secret: 'c-y-p-r-e-s-s',
|
||||||
created: Date.now()
|
created: Date.now()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
cy.route({
|
cy.intercept({
|
||||||
url: '/api/v2/tokens/1601991518',
|
url: '/api/v2/tokens/1601991518',
|
||||||
method: 'DELETE',
|
method: 'DELETE'
|
||||||
response: []
|
}, {
|
||||||
|
body: []
|
||||||
})
|
})
|
||||||
cy.visit('/profile')
|
cy.visit('/profile')
|
||||||
})
|
})
|
||||||
|
|
|
@ -15,10 +15,9 @@ export const branding = {
|
||||||
}
|
}
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
cy.server()
|
cy.intercept('/api/v2/config', {
|
||||||
cy.route({
|
statusCode: 200,
|
||||||
url: '/api/v2/config',
|
body: {
|
||||||
response: {
|
|
||||||
allowAnonymous: true,
|
allowAnonymous: true,
|
||||||
authProviders: {
|
authProviders: {
|
||||||
facebook: true,
|
facebook: true,
|
||||||
|
|
|
@ -153,21 +153,25 @@ export const HistoryPage: React.FC = () => {
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
} else if (location === HistoryEntryOrigin.REMOTE) {
|
} else if (location === HistoryEntryOrigin.REMOTE) {
|
||||||
const entry = remoteHistoryEntries.find(entry => entry.id === entryId)
|
const foundEntry = remoteHistoryEntries.find(entry => entry.id === entryId)
|
||||||
if (!entry) {
|
if (!foundEntry) {
|
||||||
setError('notFoundEntry')
|
setError('notFoundEntry')
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
entry.pinned = !entry.pinned
|
const changedEntry = {
|
||||||
updateHistoryEntry(entryId, entry)
|
...foundEntry,
|
||||||
.then(() => setRemoteHistoryEntries((entries) => {
|
pinned: !foundEntry.pinned
|
||||||
return entries.map((entry) => {
|
}
|
||||||
|
updateHistoryEntry(entryId, changedEntry)
|
||||||
|
.then(() => setRemoteHistoryEntries((entries) => (
|
||||||
|
entries.map((entry) => {
|
||||||
if (entry.id === entryId) {
|
if (entry.id === entryId) {
|
||||||
entry.pinned = !entry.pinned
|
entry.pinned = !entry.pinned
|
||||||
}
|
}
|
||||||
return entry
|
return entry
|
||||||
})
|
})
|
||||||
}))
|
)
|
||||||
|
))
|
||||||
.catch(() => setError('updateEntry'))
|
.catch(() => setError('updateEntry'))
|
||||||
}
|
}
|
||||||
}, [remoteHistoryEntries])
|
}, [remoteHistoryEntries])
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue