package org.lightadmin.page.fieldDisplay.quickView;

import org.junit.Before;
import org.junit.Test;
import org.lightadmin.SeleniumIntegrationTest;
import org.lightadmin.component.QuickViewComponent;
import org.lightadmin.config.OrderTestEntityWithoutQuickViewFields;
import org.lightadmin.data.Domain;
import org.lightadmin.data.User;
import org.lightadmin.page.ListViewPage;
import org.lightadmin.page.LoginPage;
import org.springframework.beans.factory.annotation.Autowired;

import static org.lightadmin.util.DomainAsserts.assertQuickViewFieldValues;
import static org.lightadmin.util.DomainAsserts.assertQuickViewFields;

public class DefaultFieldsTest extends SeleniumIntegrationTest {

	@Autowired
	private LoginPage loginPage;

	private ListViewPage testOrderListPage;

	@Before
	public void setup() {
		removeAllDomainTypeAdministrationConfigurations();

		registerDomainTypeAdministrationConfiguration( OrderTestEntityWithoutQuickViewFields.class );

		testOrderListPage = loginPage.get().loginAs( User.ADMINISTRATOR ).navigateToDomain( Domain.TEST_ORDERS );
	}

	@Test
	public void allEntityFieldsAreDisplayedWhenQuickViewIsNotConfigured() {
		final QuickViewComponent quickViewComponent = testOrderListPage.showQuickViewForItem( 3 );

		String[] quickViewFieldNames = quickViewComponent.getQuickViewFieldNames();
		String[] quickViewFieldValues = quickViewComponent.getQuickViewFieldValues();

		assertQuickViewFields( new String[] {"Id:", "Name:", "LineItems:"}, quickViewFieldNames );
		assertQuickViewFieldValues( new String[] {
			"3", "Order3: 3 line items", "TestLineItem #101\n" +
										 "TestLineItem #102\n" +
										 "TestLineItem #103"
		}, quickViewFieldValues );
	}
}

@@ -1089,22 +1089,26 @@
 void all
-Entity
+Persistent
 FieldsAr

Test name changed to correctly reflect the requirement