Skip to content

Art · E2E tests

0 modules · 0 exports · 1 repository · 2 e2e tests · 2 routes

  • NN-ZAP
  • SSendou
  • Arrange data setup
  • Act what the user does
  • Assert what is expected

Art

uploads art as NZAP, admin approves, art displays on user page

N-ZAPSendouart.spec.ts:15

Renders/art/new/u/:identifier/u/:identifier/art/upload/admin

Setup
Arrange
  1. Grant user N-ZAP roles “ARTIST”
    await factories.UserFactory.grant(NZAP_TEST_ID, { roles: ["ARTIST"] });
NN-ZAP
New art page
Act
  1. Open the new art page
    await newArt.goto();
  2. Select image TEST_IMAGE_PATH
    await newArt.selectImage(TEST_IMAGE_PATH);
Assert
  1. preview is visible
    await expect(newArt.locators.preview).toBeVisible();
Act
  1. Save → userArt
    const userArt = await newArt.save();
Assert
  1. the page URL is /\/u\/.*\/art/
    await expect(page).toHaveURL(/\/u\/.*\/art/);
User art page
Assert
  1. pending approval text is visible
    await expect(userArt.locators.pendingApprovalText).toBeVisible();
SSendou
Image validation page
Act
  1. Open the image validation page
    await imageValidation.goto();
Assert
  1. first images is visible
    await expect(imageValidation.locators.images.first()).toBeVisible();
Act
  1. Approve all
    await imageValidation.approveAll();
Assert
  1. all validated text is visible
    await expect(imageValidation.locators.allValidatedText).toBeVisible();
User art page
Act
  1. Open the user art page N-ZAP
    await userArt.goto(NZAP_TEST_ID);
  2. Image 0 → artImage
    const artImage = userArt.image(0);
Assert
  1. artImage is visible
    await expect(artImage).toBeVisible();
Act
  1. Bounding box → box
    const box = await artImage.boundingBox();
Assert
  1. box is not null
    expect(box).not.toBeNull();
  2. box!.width is more than 0
    expect(box!.width).toBeGreaterThan(0);
  3. box!.height is more than 0
    expect(box!.height).toBeGreaterThan(0);
Source
test("uploads art as NZAP, admin approves, art displays on user page", async ({
	page,
	factories,
}) => {
	await factories.UserFactory.grant(NZAP_TEST_ID, { roles: ["ARTIST"] });

	await impersonate(page, NZAP_TEST_ID);

	const newArt = new NewArtPage(page);
	await newArt.goto();
	await newArt.selectImage(TEST_IMAGE_PATH);

	await expect(newArt.locators.preview).toBeVisible();

	const userArt = await newArt.save();

	await expect(page).toHaveURL(/\/u\/.*\/art/);
	await expect(userArt.locators.pendingApprovalText).toBeVisible();

	await impersonate(page);

	const imageValidation = new ImageValidationPage(page);
	await imageValidation.goto();

	await expect(imageValidation.locators.images.first()).toBeVisible();

	await imageValidation.approveAll();

	await expect(imageValidation.locators.allValidatedText).toBeVisible();

	await userArt.goto(NZAP_TEST_ID);

	const artImage = userArt.image(0);
	await expect(artImage).toBeVisible();

	const box = await artImage.boundingBox();
	expect(box).not.toBeNull();
	expect(box!.width).toBeGreaterThan(0);
	expect(box!.height).toBeGreaterThan(0);
})

Renders/art/new/u/:identifier/u/:identifier/art

Setup
Arrange
  1. Grant user N-ZAP roles “ARTIST”
    await factories.UserFactory.grant(NZAP_TEST_ID, { roles: ["ARTIST"] });
  2. Create art author N-ZAP → art
    const art = await factories.ArtFactory.create({ authorId: NZAP_TEST_ID });
  3. Create art author Sendou linked users N-ZAP
    await factories.ArtFactory.create({
    	authorId: ADMIN_ID,
    	linkedUsers: [NZAP_TEST_ID],
    });
NN-ZAP
User art page
Act
  1. Open the user art page N-ZAP
    await userArt.goto(NZAP_TEST_ID);
  2. Click edit link art.id
    await userArt.editLink(art.id).click();
New art page
Assert
  1. the already uploaded image is shown but can't be swapped only rendering is asserted as the factory made art has no image file

    existing image is in the page
    await expect(newArt.locators.existingImage).toBeAttached();
  2. file input count is 0
    await expect(newArt.locators.fileInput).toHaveCount(0);
Act
  1. Fill description with “Squid drawing”
    await newArt.form.fill("description", "Squid drawing");
  2. Save
    await newArt.save();
Assert
  1. the page URL is /\/u\/.*\/art/
    await expect(page).toHaveURL(/\/u\/.*\/art/);
Act
  1. the saved description is loaded back into the form for editing

    Open the new art page art.id
    await newArt.goto(art.id);
Assert
  1. description input has value “Squid drawing”
    await expect(newArt.locators.descriptionInput).toHaveValue("Squid drawing");
User art page
Act
  1. both their own art and the art they are tagged in show on their page

    Open the user art page N-ZAP
    await userArt.goto(NZAP_TEST_ID);
Assert
  1. images count is 2
    await expect(userArt.locators.images).toHaveCount(2);
Act
  1. Unlink from art
    await userArt.unlinkFromArt();
Assert
  1. images count is 1
    await expect(userArt.locators.images).toHaveCount(1);
  2. unlink button is not visible
    await isNotVisible(userArt.locators.unlinkButton);
Act
  1. Delete art
    await userArt.deleteArt();
Assert
  1. images count is 0
    await expect(userArt.locators.images).toHaveCount(0);
Source
test("edits own art, unlinks from art made of them and deletes own art", async ({
	page,
	factories,
}) => {
	await factories.UserFactory.grant(NZAP_TEST_ID, { roles: ["ARTIST"] });
	const art = await factories.ArtFactory.create({ authorId: NZAP_TEST_ID });
	await factories.ArtFactory.create({
		authorId: ADMIN_ID,
		linkedUsers: [NZAP_TEST_ID],
	});

	await impersonate(page, NZAP_TEST_ID);

	const userArt = new UserArtPage(page);
	await userArt.goto(NZAP_TEST_ID);
	await userArt.editLink(art.id).click();

	const newArt = new NewArtPage(page);

	// the already uploaded image is shown but can't be swapped
	// only rendering is asserted as the factory made art has no image file
	await expect(newArt.locators.existingImage).toBeAttached();
	await expect(newArt.locators.fileInput).toHaveCount(0);

	await newArt.form.fill("description", "Squid drawing");
	await newArt.save();

	await expect(page).toHaveURL(/\/u\/.*\/art/);

	// the saved description is loaded back into the form for editing
	await newArt.goto(art.id);
	await expect(newArt.locators.descriptionInput).toHaveValue("Squid drawing");

	// both their own art and the art they are tagged in show on their page
	await userArt.goto(NZAP_TEST_ID);
	await expect(userArt.locators.images).toHaveCount(2);

	await userArt.unlinkFromArt();

	await expect(userArt.locators.images).toHaveCount(1);
	await isNotVisible(userArt.locators.unlinkButton);

	await userArt.deleteArt();

	await expect(userArt.locators.images).toHaveCount(0);
})