Skip to content

Commit

Permalink
Merge pull request #23 from dansysanalyst/master
Browse files Browse the repository at this point in the history
Friendly messages
  • Loading branch information
mateusjatenee committed Apr 22, 2021
2 parents 622a571 + 5928cb8 commit b1d9d22
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 17 deletions.
18 changes: 9 additions & 9 deletions dist/magic_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ function enableKeyboardShortcuts() {
text: text
}
});
alert("Generated an assertion for \"" + selectedText() + "\". Type `ok` in the debugger console to add it to your test file.");
alert("Assertion generated for \"" + selectedText() + "\". \nType `ok` in the Magic Test console to add it to your test file.");
}
}

Expand Down Expand Up @@ -11281,7 +11281,7 @@ return jQuery;
/************************************************************************/
/******/ // The module cache
/******/ var __webpack_module_cache__ = {};
/******/
/******/
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/ // Check if module is in cache
Expand All @@ -11294,14 +11294,14 @@ return jQuery;
/******/ // no module.loaded needed
/******/ exports: {}
/******/ };
/******/
/******/
/******/ // Execute the module function
/******/ __webpack_modules__[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/
/******/
/******/ // Return the exports of the module
/******/ return module.exports;
/******/ }
/******/
/******/
/************************************************************************/
/******/ /* webpack/runtime/define property getters */
/******/ (() => {
Expand All @@ -11314,12 +11314,12 @@ return jQuery;
/******/ }
/******/ };
/******/ })();
/******/
/******/
/******/ /* webpack/runtime/hasOwnProperty shorthand */
/******/ (() => {
/******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
/******/ })();
/******/
/******/
/******/ /* webpack/runtime/make namespace object */
/******/ (() => {
/******/ // define __esModule on exports
Expand All @@ -11330,7 +11330,7 @@ return jQuery;
/******/ Object.defineProperty(exports, '__esModule', { value: true });
/******/ };
/******/ })();
/******/
/******/
/************************************************************************/
var __webpack_exports__ = {};
// This entry need to be wrapped in an IIFE because it need to be in strict mode.
Expand Down Expand Up @@ -11417,4 +11417,4 @@ ready(function () {
})();

/******/ })()
;
;
6 changes: 3 additions & 3 deletions js/Context.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export function enableKeyboardShortcuts() {
}

document.addEventListener('keydown', keydown, false);

function generateAssertion() {
let text = selectedText();
if (text.trim().length > 0) {
Expand All @@ -20,7 +20,7 @@ export function enableKeyboardShortcuts() {
text: text
}
});
alert("Generated an assertion for \"" + selectedText() + "\". Type `ok` in the debugger console to add it to your test file.");
alert("Assertion generated for \"" + selectedText() + "\". \nType `ok` in the Magic Test console to add it to your test file.");
}
}

Expand All @@ -33,4 +33,4 @@ export function enableKeyboardShortcuts() {
}
return text;
}
}
}
2 changes: 1 addition & 1 deletion src/Commands/MagicTestCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class MagicTestCommand extends Command

public function handle()
{
$this->comment('Your Magic Test session is starting...');
$this->line('<info>***</info> Starting a 🧙 <fg=yellow>Magic Test</> session...');

$filter = $this->option('filter') ? (' --filter ' . $this->option('filter')) : '';
shell_exec('php artisan dusk --browse' . $filter);
Expand Down
18 changes: 14 additions & 4 deletions src/MagicTestManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,17 @@ public static function run(Browser $browser)
$browser->script('MagicTest.run()');

$shell = new Shell(new Configuration([
'startupMessage' => '<info>Your Magic Test session has started!</info>',
'startupMessage' =>
"\n"
. '<info>***</info> Welcome to your 🧙 <fg=yellow>Magic Test</> session! <info>***</info>'
. "\n"
. "\n<fg=yellow>*</> To make a assertion press <info>Ctrl + Shift + A</info> on your browser."
. "\n<fg=yellow>*</> Type <info>ok</info> to magically write it to your test file."
. "\n (make as many assertions as you wish)"
. "\n<fg=yellow>*</> Type <info>finish</info> to finalize and save your test file."
. "\n<fg=yellow>*</> Type <info>exit</info> to leave."
. "\n"
. "\n<fg=yellow>💡 Tip:</> Do not close your browser window before finalizing this session here.",
]));

$shell->addCommands([
Expand All @@ -60,7 +70,7 @@ public function runScripts(): string

$browser->script('MagicTest.clear()');

return $grammar->count() . " new " . Str::plural('action', $grammar->count()) . ($grammar->count() > 1 ? ' were' : ' was') . " added to ". MagicTest::$file . "::" . MagicTest::$method;
return '🧙 <fg=yellow>' . $grammar->count() . '</> new ' . Str::plural('action', $grammar->count()) . ($grammar->count() > 1 ? ' were' : ' was') . ' added to <fg=yellow>' . MagicTest::$file . '</><fg=white>::' . MagicTest::$method . '</>';
}

public function finish(): string
Expand All @@ -73,14 +83,14 @@ public function finish(): string
(new FileEditor)->finish($content, $method)
);

return 'Your Magic Test session has finished. See you later!';
return 'Your 🧙 <fg=yellow>Magic Test</> session has finished. See you later! 👋 ';
}

public function buildTest(Collection $grammar): void
{
$content = file_get_contents(MagicTest::$file);
$method = MagicTest::$method;

file_put_contents(
MagicTest::$file,
(new FileEditor)->process($content, $grammar, $method)
Expand Down

0 comments on commit b1d9d22

Please sign in to comment.