Compare commits
No commits in common. "ca328724b37edfd2a5cfdf55199ec701e7756aa4" and "03a33e1ef6e5c8ed98ea80850304cf44db0e6dde" have entirely different histories.
ca328724b3
...
03a33e1ef6
2 changed files with 2 additions and 37 deletions
|
|
@ -55,23 +55,4 @@ describe('The user text detail page', () => {
|
||||||
expect(response.status).to.eq(403)
|
expect(response.status).to.eq(403)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
it('non-owner sees forbidden message when viewing another user text', () => {
|
|
||||||
cy.loginAsSecondUser()
|
|
||||||
cy.intercept('GET', '/api/texts/0').as('getText')
|
|
||||||
cy.visit('/texts/0')
|
|
||||||
cy.wait('@getText')
|
|
||||||
cy.get('#text-detail').should(
|
|
||||||
'contain',
|
|
||||||
"You don't have permission to view this text"
|
|
||||||
)
|
|
||||||
})
|
|
||||||
|
|
||||||
it('user sees not found for non-existent text', () => {
|
|
||||||
cy.loginAsUser()
|
|
||||||
cy.intercept('GET', '/api/texts/999').as('getText')
|
|
||||||
cy.visit('/texts/999')
|
|
||||||
cy.wait('@getText')
|
|
||||||
cy.get('#text-detail').should('contain', 'Text not found')
|
|
||||||
})
|
|
||||||
})
|
})
|
||||||
|
|
|
||||||
|
|
@ -4,24 +4,8 @@ document.addEventListener('DOMContentLoaded', () => {
|
||||||
const textId = window.location.pathname.split('/').pop();
|
const textId = window.location.pathname.split('/').pop();
|
||||||
|
|
||||||
fetch('/api/texts/' + textId, { credentials: 'same-origin' })
|
fetch('/api/texts/' + textId, { credentials: 'same-origin' })
|
||||||
.then(function (res) {
|
.then(res => res.json())
|
||||||
if (!res.ok) {
|
.then(text => {
|
||||||
if (res.status === 403) {
|
|
||||||
const message = document.createElement('p');
|
|
||||||
message.textContent =
|
|
||||||
"You don't have permission to view this text";
|
|
||||||
document.getElementById('text-detail').appendChild(message);
|
|
||||||
} else if (res.status === 404) {
|
|
||||||
const message = document.createElement('p');
|
|
||||||
message.textContent = 'Text not found';
|
|
||||||
document.getElementById('text-detail').appendChild(message);
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
return res.json();
|
|
||||||
})
|
|
||||||
.then(function (text) {
|
|
||||||
if (!text) return;
|
|
||||||
const h1 = document.createElement('h1');
|
const h1 = document.createElement('h1');
|
||||||
h1.textContent = text.name;
|
h1.textContent = text.name;
|
||||||
document.getElementById('text-detail').appendChild(h1);
|
document.getElementById('text-detail').appendChild(h1);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue