opnform/tests/Feature/TemplateTest.php

31 lines
1.0 KiB
PHP
Raw Permalink Normal View History

<?php
it('can create template', function () {
2022-11-16 14:57:10 +00:00
$user = $this->createUser([
2024-02-23 10:54:12 +00:00
'email' => 'admin@opnform.com',
2022-11-16 14:57:10 +00:00
]);
$this->actingAsUser($user);
// Create Form
$workspace = $this->createUserWorkspace($user);
$form = $this->makeForm($user, $workspace);
2022-11-16 14:57:10 +00:00
// Create Template
$templateData = [
'name' => 'Demo Template',
'slug' => 'demo_template',
'short_description' => 'Short description here...',
'description' => 'Some long description here...',
'image_url' => 'https://d3ietpyl4f2d18.cloudfront.net/6c35a864-ee3a-4039-80a4-040b6c20ac60/img/pages/welcome/product_cover.jpg',
'publicly_listed' => true,
'form' => $form->getAttributes(),
2024-02-23 10:54:12 +00:00
'questions' => [['question' => 'Question 1', 'answer' => 'Answer 1 will be here...']],
];
$this->postJson(route('templates.create', $templateData))
->assertSuccessful()
->assertJson([
'type' => 'success',
2024-02-23 10:54:12 +00:00
'message' => 'Template was created.',
]);
2022-11-16 14:57:10 +00:00
});