Skip to content

User report · E2E tests

0 modules · 0 exports · 1 repository · 3 e2e tests · 1 route

  • SSendou
  • Users a test creates itself are coloured per test
  • Arrange data setup
  • Act what the user does
  • Assert what is expected

User report

reports a user from the card and shows it on the admin page

Renders/lfg/u/:identifier/u/:identifier/admin

Setup
Arrange
  1. Create 3 × user → [reporter, ...earlierReporters]
    const [reporter, ...earlierReporters] =
    	await factories.UserFactory.createMany(3);
  2. For each earlierReporter of earlierReporters
    for (const earlierReporter of earlierReporters) {
    	await factories.UserReportFactory.create(
    		{
    			reporterUserId: earlierReporter.id,
    			reportedUserId: NZAP_TEST_ID,
    		},
    		{ createdAt: subDays(new Date(), 1) },
    	);
    }
    1. Create user report reporter user id earlierReporter.id reported N-ZAP created at subDays(new Date(), 1)
      await factories.UserReportFactory.create(
      	{
      		reporterUserId: earlierReporter.id,
      		reportedUserId: NZAP_TEST_ID,
      	},
      	{ createdAt: subDays(new Date(), 1) },
      );
  3. Create LFG post author N-ZAP
    await factories.LFGPostFactory.create({ authorId: NZAP_TEST_ID });
Rreporter
LFG page
Act
  1. Open the LFG page
    await lfg.goto();
  2. Open user card “N-ZAP” → card
    const card = await lfg.openUserCard("N-ZAP");
  3. Open report dialog → reportDialog
    const reportDialog = await card.openReportDialog();
  4. description = "Called my team mean names in the match chat"
    const description = "Called my team mean names in the match chat";
  5. Select “HARASSMENT” for category
    await reportDialog.form.select("category", "HARASSMENT");
  6. Fill description with description
    await reportDialog.form.fill("description", description);
  7. Send
    await reportDialog.send();
Assert
  1. reportDialog.locators.sentToast is in the page
    await expect(reportDialog.locators.sentToast).toBeAttached();
SSendou
User admin page
Act
  1. Open the user admin page N-ZAP
    await adminPage.goto(NZAP_TEST_ID);
Assert
  1. total reports text 3 is visible
    await expect(adminPage.totalReportsText(3)).toBeVisible();
  2. report details count is 3
    await expect(adminPage.locators.reportDetails).toHaveCount(3);
  3. text description is not visible
    await expect(adminPage.text(description)).not.toBeVisible();
Act
  1. Open first report
    await adminPage.openFirstReport();
Assert
  1. text description is visible
    await expect(adminPage.text(description)).toBeVisible();
Source
test("reports a user from the card and shows it on the admin page", async ({
	page,
	factories,
}) => {
	const [reporter, ...earlierReporters] =
		await factories.UserFactory.createMany(3);
	for (const earlierReporter of earlierReporters) {
		await factories.UserReportFactory.create(
			{
				reporterUserId: earlierReporter.id,
				reportedUserId: NZAP_TEST_ID,
			},
			{ createdAt: subDays(new Date(), 1) },
		);
	}
	await factories.LFGPostFactory.create({ authorId: NZAP_TEST_ID });

	await impersonate(page, reporter.id);

	const lfg = new LFGPage(page);
	await lfg.goto();
	const card = await lfg.openUserCard("N-ZAP");
	const reportDialog = await card.openReportDialog();

	const description = "Called my team mean names in the match chat";
	await reportDialog.form.select("category", "HARASSMENT");
	await reportDialog.form.fill("description", description);
	await reportDialog.send();

	await expect(reportDialog.locators.sentToast).toBeAttached();

	await impersonate(page);

	const adminPage = new UserAdminPage(page);
	await adminPage.goto(NZAP_TEST_ID);

	await expect(adminPage.totalReportsText(3)).toBeVisible();
	await expect(adminPage.locators.reportDetails).toHaveCount(3);

	await expect(adminPage.text(description)).not.toBeVisible();
	await adminPage.openFirstReport();
	await expect(adminPage.text(description)).toBeVisible();
})

points elsewhere instead of reporting an inappropriate nickname

Renders/lfg

Setup
Arrange
  1. Create user → reporter
    const reporter = await factories.UserFactory.create();
  2. Create LFG post author N-ZAP
    await factories.LFGPostFactory.create({ authorId: NZAP_TEST_ID });
Rreporter
LFG page
Act
  1. Open the LFG page
    await lfg.goto();
  2. Open user card “N-ZAP” → card
    const card = await lfg.openUserCard("N-ZAP");
  3. Open report dialog → reportDialog
    const reportDialog = await card.openReportDialog();
Assert
  1. reportDialog.locators.submitButton is visible
    await expect(reportDialog.locators.submitButton).toBeVisible();
Act
  1. Select “INAPPROPRIATE_NICKNAME” for category
    await reportDialog.form.select("category", "INAPPROPRIATE_NICKNAME");
Assert
  1. reportDialog.locators.nicknameInstructions is visible
    await expect(reportDialog.locators.nicknameInstructions).toBeVisible();
  2. reportDialog.locators.submitButton is not visible
    await expect(reportDialog.locators.submitButton).not.toBeVisible();
Source
test("points elsewhere instead of reporting an inappropriate nickname", async ({
	page,
	factories,
}) => {
	const reporter = await factories.UserFactory.create();
	await factories.LFGPostFactory.create({ authorId: NZAP_TEST_ID });

	await impersonate(page, reporter.id);

	const lfg = new LFGPage(page);
	await lfg.goto();
	const card = await lfg.openUserCard("N-ZAP");
	const reportDialog = await card.openReportDialog();

	await expect(reportDialog.locators.submitButton).toBeVisible();

	await reportDialog.form.select("category", "INAPPROPRIATE_NICKNAME");

	await expect(reportDialog.locators.nicknameInstructions).toBeVisible();
	await expect(reportDialog.locators.submitButton).not.toBeVisible();
})

prefills the match id when reporting from a match page

Renders/q/match/:id

Setup
Arrange
  1. Create 3 × user → alphaMates
    const alphaMates = await factories.UserFactory.createMany(3);
  2. Create 3 × user → bravoMates
    const bravoMates = await factories.UserFactory.createMany(3);
  3. Create SQ match alpha user ids Sendou, ...alphaMates.map((user) => user.id) bravo user ids N-ZAP, ...bravoMates.map((user) => user.id) → match
    const match = await factories.SQMatchFactory.create({
    	alphaUserIds: [ADMIN_ID, ...alphaMates.map((user) => user.id)],
    	bravoUserIds: [NZAP_TEST_ID, ...bravoMates.map((user) => user.id)],
    });
SSendou
SendouQ match page
Act
  1. Open the SendouQ match page match.id, “rosters”
    await matchPage.goto(match.id, "rosters");
  2. Open user card /N-ZAP/ → card
    const card = await matchPage.openUserCard(/N-ZAP/);
  3. Open report dialog → reportDialog
    const reportDialog = await card.openReportDialog();
Assert
  1. reportDialog.locators.matchIdInput has value String(match.id)
    await expect(reportDialog.locators.matchIdInput).toHaveValue(
    	String(match.id),
    );
Source
test("prefills the match id when reporting from a match page", async ({
	page,
	factories,
}) => {
	const alphaMates = await factories.UserFactory.createMany(3);
	const bravoMates = await factories.UserFactory.createMany(3);
	const match = await factories.SQMatchFactory.create({
		alphaUserIds: [ADMIN_ID, ...alphaMates.map((user) => user.id)],
		bravoUserIds: [NZAP_TEST_ID, ...bravoMates.map((user) => user.id)],
	});

	await impersonate(page);

	const matchPage = new SendouQMatchPage(page);
	await matchPage.goto(match.id, "rosters");

	const card = await matchPage.openUserCard(/N-ZAP/);
	const reportDialog = await card.openReportDialog();

	await expect(reportDialog.locators.matchIdInput).toHaveValue(
		String(match.id),
	);
})