test element update route
This commit is contained in:
parent
299ccc4f58
commit
9cb968afd8
3 changed files with 33 additions and 21 deletions
|
|
@ -122,7 +122,8 @@ class ElementsEndpointTest extends TestCase
|
||||||
parentElement: null,
|
parentElement: null,
|
||||||
));
|
));
|
||||||
|
|
||||||
$response = $this->postJson("/api/elements/{$element->getId()}", [
|
$response = $this->postJson('/api/element/update', [
|
||||||
|
'elementId' => $element->getId(),
|
||||||
'title' => 'Updated title',
|
'title' => 'Updated title',
|
||||||
'description' => 'Updated description',
|
'description' => 'Updated description',
|
||||||
'iconImageUrl' => '/assets/updated-icon.png',
|
'iconImageUrl' => '/assets/updated-icon.png',
|
||||||
|
|
@ -162,7 +163,8 @@ class ElementsEndpointTest extends TestCase
|
||||||
|
|
||||||
$response = $this->withCredentials()
|
$response = $this->withCredentials()
|
||||||
->withUnencryptedCookie('auth_token', 'valid-token')
|
->withUnencryptedCookie('auth_token', 'valid-token')
|
||||||
->postJson("/api/elements/{$element->getId()}", [
|
->postJson('/api/element/update', [
|
||||||
|
'elementId' => $element->getId(),
|
||||||
'title' => 'Updated title',
|
'title' => 'Updated title',
|
||||||
'description' => 'Updated description',
|
'description' => 'Updated description',
|
||||||
'iconImageUrl' => '/assets/updated-icon.png',
|
'iconImageUrl' => '/assets/updated-icon.png',
|
||||||
|
|
@ -212,8 +214,11 @@ class ElementsEndpointTest extends TestCase
|
||||||
));
|
));
|
||||||
|
|
||||||
$response = $this->post(
|
$response = $this->post(
|
||||||
"/api/elements/{$element->getId()}",
|
'/api/element/update',
|
||||||
['iconImage' => $this->iconImageUpload()],
|
[
|
||||||
|
'elementId' => (string) $element->getId(),
|
||||||
|
'iconImage' => $this->iconImageUpload(),
|
||||||
|
],
|
||||||
);
|
);
|
||||||
|
|
||||||
$response->assertUnauthorized();
|
$response->assertUnauthorized();
|
||||||
|
|
@ -247,8 +252,11 @@ class ElementsEndpointTest extends TestCase
|
||||||
$response = $this->withCredentials()
|
$response = $this->withCredentials()
|
||||||
->withUnencryptedCookie('auth_token', 'valid-token')
|
->withUnencryptedCookie('auth_token', 'valid-token')
|
||||||
->post(
|
->post(
|
||||||
"/api/elements/{$element->getId()}",
|
'/api/element/update',
|
||||||
['iconImage' => $this->iconImageUpload()],
|
[
|
||||||
|
'elementId' => (string) $element->getId(),
|
||||||
|
'iconImage' => $this->iconImageUpload(),
|
||||||
|
],
|
||||||
);
|
);
|
||||||
|
|
||||||
$response->assertOk();
|
$response->assertOk();
|
||||||
|
|
@ -290,8 +298,11 @@ class ElementsEndpointTest extends TestCase
|
||||||
));
|
));
|
||||||
|
|
||||||
$response = $this->post(
|
$response = $this->post(
|
||||||
"/api/elements/{$element->getId()}",
|
'/api/element/update',
|
||||||
['pdf' => $this->pdfUpload()],
|
[
|
||||||
|
'elementId' => (string) $element->getId(),
|
||||||
|
'pdf' => $this->pdfUpload(),
|
||||||
|
],
|
||||||
);
|
);
|
||||||
|
|
||||||
$response->assertUnauthorized();
|
$response->assertUnauthorized();
|
||||||
|
|
@ -325,8 +336,11 @@ class ElementsEndpointTest extends TestCase
|
||||||
$response = $this->withCredentials()
|
$response = $this->withCredentials()
|
||||||
->withUnencryptedCookie('auth_token', 'valid-token')
|
->withUnencryptedCookie('auth_token', 'valid-token')
|
||||||
->post(
|
->post(
|
||||||
"/api/elements/{$element->getId()}",
|
'/api/element/update',
|
||||||
['pdf' => $this->pdfUpload()],
|
[
|
||||||
|
'elementId' => (string) $element->getId(),
|
||||||
|
'pdf' => $this->pdfUpload(),
|
||||||
|
],
|
||||||
);
|
);
|
||||||
|
|
||||||
$response->assertOk();
|
$response->assertOk();
|
||||||
|
|
|
||||||
|
|
@ -169,7 +169,9 @@ class ElementControllerTest extends TestCase
|
||||||
null,
|
null,
|
||||||
);
|
);
|
||||||
$fixturePath = __DIR__ . '/../../fixtures/icon.png';
|
$fixturePath = __DIR__ . '/../../fixtures/icon.png';
|
||||||
$request = new Request([], [], [], [], [
|
$request = new Request([], [
|
||||||
|
'elementId' => (string) $element->getId(),
|
||||||
|
], [], [], [
|
||||||
'iconImage' => new UploadedFile(
|
'iconImage' => new UploadedFile(
|
||||||
$fixturePath,
|
$fixturePath,
|
||||||
'icon.png',
|
'icon.png',
|
||||||
|
|
@ -179,10 +181,7 @@ class ElementControllerTest extends TestCase
|
||||||
),
|
),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$response = $this->controller->update(
|
$response = $this->controller->update($request);
|
||||||
$element->getId(),
|
|
||||||
$request,
|
|
||||||
);
|
|
||||||
|
|
||||||
$this->assertEquals(200, $response->getStatusCode());
|
$this->assertEquals(200, $response->getStatusCode());
|
||||||
$body = json_decode($response->getContent(), true);
|
$body = json_decode($response->getContent(), true);
|
||||||
|
|
@ -211,7 +210,9 @@ class ElementControllerTest extends TestCase
|
||||||
null,
|
null,
|
||||||
);
|
);
|
||||||
$fixturePath = __DIR__ . '/../../fixtures/baderech.pdf';
|
$fixturePath = __DIR__ . '/../../fixtures/baderech.pdf';
|
||||||
$request = new Request([], [], [], [], [
|
$request = new Request([], [
|
||||||
|
'elementId' => (string) $element->getId(),
|
||||||
|
], [], [], [
|
||||||
'pdf' => new UploadedFile(
|
'pdf' => new UploadedFile(
|
||||||
$fixturePath,
|
$fixturePath,
|
||||||
'baderech.pdf',
|
'baderech.pdf',
|
||||||
|
|
@ -221,10 +222,7 @@ class ElementControllerTest extends TestCase
|
||||||
),
|
),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$response = $this->controller->update(
|
$response = $this->controller->update($request);
|
||||||
$element->getId(),
|
|
||||||
$request,
|
|
||||||
);
|
|
||||||
|
|
||||||
$this->assertEquals(200, $response->getStatusCode());
|
$this->assertEquals(200, $response->getStatusCode());
|
||||||
$body = json_decode($response->getContent(), true);
|
$body = json_decode($response->getContent(), true);
|
||||||
|
|
|
||||||
|
|
@ -111,7 +111,7 @@ describe('admin element editing', () => {
|
||||||
cy.resetDb()
|
cy.resetDb()
|
||||||
loginAsAdmin()
|
loginAsAdmin()
|
||||||
cy.visit('/admin/element/1')
|
cy.visit('/admin/element/1')
|
||||||
cy.intercept('POST', /\/api\/elements\/1$/).as('updateElement')
|
cy.intercept('POST', /\/api\/element\/update$/).as('updateElement')
|
||||||
|
|
||||||
cy.get('[data-cy="admin-element-icon-image-input"]').selectFile(
|
cy.get('[data-cy="admin-element-icon-image-input"]').selectFile(
|
||||||
'public/assets/baderech-haavodah-icon.png',
|
'public/assets/baderech-haavodah-icon.png',
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue