Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions resources/lang/en/exment.php
Original file line number Diff line number Diff line change
Expand Up @@ -1150,6 +1150,7 @@
'get_by_userinfo_and_action_select' => 'In the same pre-execution status, "Get from execution user information" and "Select by execution user of previous action" cannot be set at the same time.',
'action_execute' => 'Perform the following actions:',
'nextuser_not_found' => 'The following working user does not exist. Please contact the administrator.',
'status_changed' => 'This action cannot be performed. Another user may have executed the workflow.',
],

'comment_options' => [
Expand Down
1 change: 1 addition & 0 deletions resources/lang/ja/exment.php
Original file line number Diff line number Diff line change
Expand Up @@ -1151,6 +1151,7 @@
'ignore_work_and_action_select' => '実行可能ユーザーが「前アクションの実行ユーザーが選択」の場合、「特殊なアクション」を設定できません。',
'action_execute' => '以下のアクションを実行します。',
'nextuser_not_found' => '次の作業ユーザーが存在しません。管理者に問い合わせください。',
'status_changed' => 'このアクションは実行できません。他のユーザーがワークフローを実行した可能性があります。',
],

'comment_options' => [
Expand Down
11 changes: 10 additions & 1 deletion src/Controllers/CustomValueController.php
Original file line number Diff line number Diff line change
Expand Up @@ -717,7 +717,16 @@ public function actionClick(Request $request, $tableKey, $id)

$custom_value = $this->custom_table->getValueModel($id);

//TODO:validation
//validation
$workflow_actions = $custom_value->getWorkflowActions(true);
if (!$workflow_actions->contains(function($workflow_action) use($action){
return $workflow_action->id == $action->id;
})) {
return ([
'result' => false,
'toastr' => sprintf(exmtrans('workflow.message.status_changed')),
]);
}

$action->executeAction($custom_value, [
'comment' => $request->get('comment'),
Expand Down
4 changes: 2 additions & 2 deletions tests/Browser/ExmentKitPrepareTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ protected function createCustomRelation($parent_table, $child_table, $relation_t
// Create custom relation
$this->visit(admin_url("relation/$parent_table/create"))
->submitForm('admin-submit', $data)
->seePageIs('/admin/relation/' . $parent_table)
->seePageIs(admin_url('relation/' . $parent_table))
->seeInElement('td', array_get($row, 'table_view_name'));
}

Expand Down Expand Up @@ -246,7 +246,7 @@ protected function createCustomColumns($table_name, $targets = null)
// Create custom column
$this->post(admin_url("column/$table_name"), $data);
$this->visit(admin_url("column/$table_name"))
->seePageIs("/admin/column/$table_name")
->seePageIs(admin_url("column/$table_name"))
->seeInElement('td', array_get($data, 'column_view_name'));
}
}
Expand Down
47 changes: 46 additions & 1 deletion tests/Browser/ExmentKitTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,30 @@ protected function setUpTraits()
*/
protected function login($id = null)
{
$this->be(LoginUser::find($id?? 1));
$targetId = $id ?? 1;
$user = LoginUser::find($targetId);

if (!$user) {
// Try to create a minimal test user if it doesn't exist
try {
$this->createTestUserIfNeeded($targetId);
$user = LoginUser::find($targetId);
} catch (\Exception $e) {
// If we still can't find or create the user, throw an informative error
throw new \RuntimeException(
"Test user with ID " . $targetId . " not found and could not be created. " .
"Please ensure test data is properly seeded. Error: " . $e->getMessage()
);
}
}

if (!$user) {
throw new \RuntimeException(
"Test user with ID " . $targetId . " not found. Please ensure test data is properly seeded."
);
}

$this->be($user);
}


Expand Down Expand Up @@ -114,4 +137,26 @@ public function containsSelectOptions($element, array $options, $negate = false)
{
return $this->assertInPage(new Constraints\ContainsSelectOption($element, $options), $negate);
}
/**
* Create a minimal test user if needed
* @param int $id
* @return void
*/
private function createTestUserIfNeeded($id)
{
// Check if we have basic custom tables
$userTable = \Exceedone\Exment\Model\CustomTable::getEloquent('user');
if (!$userTable) {
// Try to seed again
\Artisan::call('db:seed', [
'--class' => 'Exceedone\\Exment\\Database\\Seeder\\InstallSeeder',
'--force' => true
]);
\Artisan::call('db:seed', [
'--class' => 'Exceedone\\Exment\\Database\\Seeder\\TestDataSeeder',
'--force' => true
]);
}
}

}
Loading