Home / File/ actions-blog.test.js — astro Source File

actions-blog.test.js — astro Source File

Architecture documentation for actions-blog.test.js, a javascript file in the astro codebase. 4 imports, 0 dependents.

Entity Profile

Dependency Diagram

graph LR
  752f9c5a_1c86_7360_d126_bcb34204a9d1["actions-blog.test.js"]
  2ca394f6_a63d_3921_1f12_c5a979ea0039["test-utils.js"]
  752f9c5a_1c86_7360_d126_bcb34204a9d1 --> 2ca394f6_a63d_3921_1f12_c5a979ea0039
  e27f6887_ea47_dd44_7933_5faa0f6bcf4d["testFactory"]
  752f9c5a_1c86_7360_d126_bcb34204a9d1 --> e27f6887_ea47_dd44_7933_5faa0f6bcf4d
  c373140e_7fdf_7fff_8884_991b85bc22b5["waitForHydrate"]
  752f9c5a_1c86_7360_d126_bcb34204a9d1 --> c373140e_7fdf_7fff_8884_991b85bc22b5
  f8fbe851_c5d6_c4ee_c044_67a751668c18["test"]
  752f9c5a_1c86_7360_d126_bcb34204a9d1 --> f8fbe851_c5d6_c4ee_c044_67a751668c18
  style 752f9c5a_1c86_7360_d126_bcb34204a9d1 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

import { expect } from '@playwright/test';
import { testFactory, waitForHydrate } from './test-utils.js';

const test = testFactory(import.meta.url, { root: './fixtures/actions-blog/' });

let devServer;

test.beforeAll(async ({ astro }) => {
	devServer = await astro.startDevServer();
});

test.afterAll(async () => {
	await devServer.stop();
});

test.afterEach(async ({ astro }) => {
	// Force database reset between tests
	await astro.editFile('./db/seed.ts', (original) => original, false);
});

test.describe('Astro Actions - Blog', () => {
	test('Like action', async ({ page, astro }) => {
		await page.goto(astro.resolveUrl('/blog/first-post/'));
		const likeButton = page.getByLabel('Like');
		await waitForHydrate(page, likeButton);
		await new Promise((resolve) => setTimeout(resolve, 500));
		await expect(likeButton, 'like button starts with 10 likes').toContainText('10');
		await likeButton.click();
		await expect(likeButton, 'like button should increment likes').toContainText('11');
	});

	test('Like action - server-side', async ({ page, astro }) => {
		await page.goto(astro.resolveUrl('/blog/first-post/'));

		const likeButton = page.getByLabel('get-request');
		const likeCount = page.getByLabel('Like');
		await expect(likeCount, 'like button starts with 10 likes').toContainText('10');
		await likeButton.click();
		await expect(likeCount, 'like button should increment likes').toContainText('11');
	});

	test('Comment action - validation error', async ({ page, astro }) => {
		await page.goto(astro.resolveUrl('/blog/first-post/'));

		const form = page.getByTestId('client');
		const authorInput = form.locator('input[name="author"]');
		const bodyInput = form.locator('textarea[name="body"]');

		await authorInput.fill('Ben');
		await bodyInput.fill('Too short');

		const submitButton = form.getByRole('button');
		await submitButton.click();

		await expect(form.locator('p[data-error="body"]')).toBeVisible();
	});

	test('Comment action - progressive fallback validation error', async ({ page, astro }) => {
		await page.goto(astro.resolveUrl('/blog/first-post/'));

// ... (130 more lines)

Domain

Frequently Asked Questions

What does actions-blog.test.js do?
actions-blog.test.js is a source file in the astro codebase, written in javascript. It belongs to the E2ETesting domain.
What does actions-blog.test.js depend on?
actions-blog.test.js imports 4 module(s): test, test-utils.js, testFactory, waitForHydrate.
Where is actions-blog.test.js in the architecture?
actions-blog.test.js is located at packages/astro/e2e/actions-blog.test.js (domain: E2ETesting, directory: packages/astro/e2e).

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free