|
10 | 10 |
|
11 | 11 |
|
12 | 12 | @pytest.mark.parametrize("no_package_lock", [True, False])
|
13 |
| -def test_tailwind_install_and_build(no_package_lock, settings): |
| 13 | +def test_tailwind_install_and_build_v3(no_package_lock, settings): |
14 | 14 | app_name = f'test_theme_{str(uuid.uuid1()).replace("-", "_")}'
|
15 | 15 |
|
16 |
| - call_command("tailwind", "init", "--app-name", app_name, "--no-input") |
| 16 | + call_command("tailwind", "init", "--app-name", app_name, "--no-input", "--tailwind-version", "3") |
17 | 17 |
|
18 | 18 | settings.INSTALLED_APPS += [app_name]
|
19 | 19 | settings.TAILWIND_APP_NAME = app_name
|
@@ -47,3 +47,43 @@ def test_tailwind_install_and_build(no_package_lock, settings):
|
47 | 47 | ), "Tailwind has built a css/styles.css file"
|
48 | 48 |
|
49 | 49 | cleanup_theme_app_dir(app_name)
|
| 50 | + |
| 51 | + |
| 52 | +@pytest.mark.parametrize("no_package_lock", [True, False]) |
| 53 | +def test_tailwind_install_and_build_v4(no_package_lock, settings): |
| 54 | + app_name = f'test_theme_{str(uuid.uuid1()).replace("-", "_")}' |
| 55 | + |
| 56 | + call_command("tailwind", "init", "--app-name", app_name, "--no-input") |
| 57 | + |
| 58 | + settings.INSTALLED_APPS += [app_name] |
| 59 | + settings.TAILWIND_APP_NAME = app_name |
| 60 | + |
| 61 | + assert os.path.isfile(os.path.join(get_app_path(app_name), "apps.py")), 'The "theme" app has been generated' |
| 62 | + |
| 63 | + tailwind_config_path = os.path.join(get_app_path(app_name), "static_src", "tailwind.config.js") |
| 64 | + assert not os.path.isfile(tailwind_config_path), "tailwind.config.js is absent from tailwind v4" |
| 65 | + |
| 66 | + if no_package_lock: |
| 67 | + call_command("tailwind", "install", "--no-package-lock") |
| 68 | + else: |
| 69 | + call_command("tailwind", "install") |
| 70 | + |
| 71 | + package_json_path = os.path.join(get_app_path(app_name), "static_src", "package.json") |
| 72 | + assert os.path.isfile(package_json_path), "Tailwind has created package.json file" |
| 73 | + |
| 74 | + package_lock_json_path = os.path.join(get_app_path(app_name), "static_src", "package-lock.json") |
| 75 | + if no_package_lock: |
| 76 | + assert not os.path.isfile(package_lock_json_path), "Tailwind has not created package-lock.json file" |
| 77 | + else: |
| 78 | + assert os.path.isfile(package_lock_json_path), "Tailwind has created package-lock.json file" |
| 79 | + |
| 80 | + assert os.path.isdir( |
| 81 | + os.path.join(get_app_path(app_name), "static_src", "node_modules") |
| 82 | + ), "Tailwind has been installed from npm" |
| 83 | + |
| 84 | + call_command("tailwind", "build") |
| 85 | + assert os.path.isfile( |
| 86 | + os.path.join(get_app_path(app_name), "static", "css", "dist", "styles.css") |
| 87 | + ), "Tailwind has built a css/styles.css file" |
| 88 | + |
| 89 | + cleanup_theme_app_dir(app_name) |
0 commit comments