Skip to content

Commit

Permalink
fix: isolate cleanup to related tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kielllll committed Nov 26, 2024
1 parent d8553a6 commit 1f45f88
Showing 1 changed file with 4 additions and 36 deletions.
40 changes: 4 additions & 36 deletions tests/e2e/advanced-checks/pdf-restriction.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ test("should redirect to WP login page if 'Restrict Owner' is enabled", async (t

// Visit the page as anon user
pdfId = await getQueryParam('post');

//
await t
.useRole(Role.anonymous())
.navigateTo(`${baseURL}/?page_id=${pdfId}`)
Expand Down Expand Up @@ -94,40 +94,8 @@ test("should redirect to WP login page if 'Restrict Owner' is enabled", async (t
.notOk()
.expect(advancedCheck.wpLoginForm.exists)
.ok();
});

test('reset/clean previous tests saved data and ensure PDF can be viewed by default', async (t) => {
// Actions & Assertions
await advancedCheck.toggleRestrictOwnerCheckbox(
'gf_edit_forms&view=settings&subview=PDF&id=4'
);

await t
.useRole(Role.anonymous())
.navigateTo(`${baseURL}/?page_id=${pdfId}`);
await advancedCheck.submitNewPdfEntry();

await t.useRole(admin);
await pdf.navigate('gf_entries&id=4');

downloadUrl = await advancedCheck.viewEntryLink.getAttribute('href');
await page.deleteTestPage();
await t.useRole(Role.anonymous());

downloadLogger.clear();

await t
.addRequestHooks(downloadLogger)
.navigateTo(downloadUrl)
.wait(500)
.removeRequestHooks(downloadLogger);

// Assertions
await t
.expect(
downloadLogger.contains(
(r) => r.response.headers['content-type'] === 'application/pdf'
)
)
.ok();
// Cleanup
await t.navigateTo(baseURL);
await pageModel.delete();
});

0 comments on commit 1f45f88

Please sign in to comment.