| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221 |
- import { expect } from "../setup";
- import { generateDescription } from "../utils/faker";
- export async function enableGDPR(adminPage) {
- /**
- * Navigating to the gdpr configuration page.
- */
- await adminPage.goto("admin/configuration/general/gdpr");
- const isEnabled = adminPage.locator("label > div").first().check();
- /**
- * If not enabled, then we enable it.
- */
- if (!isEnabled) {
- const gdprsettingToggle = adminPage.locator("label > div").first();
- await gdprsettingToggle.waitFor({ state: "visible", timeout: 5000 });
- await adminPage.locator("label > div").first().click();
- }
- /**
- * Verifying enable state.
- */
- const toggleInput = adminPage.locator("label > div").first();
- await expect(toggleInput).toBeChecked();
- /**
- * Click the 'Save Configuration' button.
- */
- await adminPage.getByRole("button", { name: "Save Configuration" }).click();
- }
- export async function disableGDPR(adminPage) {
- /**
- * Navigating to the gdpr configuration page.
- */
- await adminPage.goto("admin/configuration/general/gdpr");
- const isDisabled = adminPage.locator("label > div").first().uncheck();
- /**
- * If not disabled, then we disable it.
- */
- if (!isDisabled) {
- const gdprsettingToggle = adminPage.locator("label > div").first();
- await gdprsettingToggle.waitFor({ state: "visible", timeout: 5000 });
- await adminPage.locator("label > div").first().click();
- }
- /**
- * Verifying disable state.
- */
- const toggleInput = adminPage.locator("label > div").first();
- await expect(toggleInput).not.toBeChecked();
- /**
- * Click the 'Save Configuration' button.
- */
- await adminPage.getByRole("button", { name: "Save Configuration" }).click();
- }
- export async function enableGDPRAgreement(adminPage) {
- const agreement = {
- checkboxLabel: "I agree with this statement.",
- content: generateDescription(),
- };
- /**
- * Navigating to the gdpr configuration page.
- */
- await adminPage.goto("admin/configuration/general/gdpr");
- const isEnabled = adminPage
- .locator("div:nth-child(4) > div > .mb-4 > .relative > div")
- .first()
- .check();
- /**
- * If not enabled, then we enable it.
- */
- if (!isEnabled) {
- const gdprsettingToggle = adminPage
- .locator("div:nth-child(4) > div > .mb-4 > .relative > div")
- .first();
- await gdprsettingToggle.waitFor({ state: "visible", timeout: 5000 });
- await adminPage
- .locator("div:nth-child(4) > div > .mb-4 > .relative > div")
- .first()
- .click();
- }
- /**
- * Verifying enable state.
- */
- const toggleInput = adminPage
- .locator("div:nth-child(4) > div > .mb-4 > .relative > div")
- .first();
- await expect(toggleInput).toBeChecked();
- /**
- * Fill the agreement checkbox label.
- */
- await adminPage
- .getByRole("textbox", { name: "Agreement Checkbox Label" })
- .click();
- await adminPage
- .getByRole("textbox", {
- name: "Agreement Checkbox Label",
- })
- .fill(agreement.checkboxLabel);
- await adminPage.click('button[type="submit"].primary-button:visible');
- /**
- * Fill the agreement content.
- */
- await adminPage.waitForSelector('#general_gdpr__agreement__agreement_content__ifr', { state: 'visible' });
- await adminPage.frameLocator('#general_gdpr__agreement__agreement_content__ifr').locator('body').clear();
- await adminPage.fillInTinymce(
- "#general_gdpr__agreement__agreement_content__ifr",
- agreement.content
- );
- /**
- * Save the configuration.
- */
- await adminPage.click('button[type="submit"].primary-button:visible');
- return agreement;
- }
- export async function disableGDPRAgreement(adminPage) {
- /**
- * Navigating to the gdpr configuration page.
- */
- await adminPage.goto("admin/configuration/general/gdpr");
- const isDisabled = adminPage
- .locator("div:nth-child(4) > div > .mb-4 > .relative > div")
- .first()
- .uncheck();
- /**
- * If not disabled, then we disable it.
- */
- if (!isDisabled) {
- const gdprsettingToggle = adminPage
- .locator("div:nth-child(4) > div > .mb-4 > .relative > div")
- .first();
- await gdprsettingToggle.waitFor({ state: "visible", timeout: 5000 });
- await adminPage
- .locator("div:nth-child(4) > div > .mb-4 > .relative > div")
- .first()
- .click();
- }
- /**
- * Verifying disable state.
- */
- const toggleInput = adminPage
- .locator("div:nth-child(4) > div > .mb-4 > .relative > div")
- .first();
- await expect(toggleInput).not.toBeChecked();
- /**
- * Click the 'Save Configuration' button.
- */
- await adminPage.getByRole("button", { name: "Save Configuration" }).click();
- }
- export async function enableCookiesNotice(adminPage, position = "bottom-left") {
- /**
- * Navigating to the gdpr configuration page.
- */
- await adminPage.goto("admin/configuration/general/gdpr");
- const isEnabled = adminPage
- .locator("div:nth-child(6) > div > .mb-4 > .relative > div")
- .check();
- /**
- * If not enabled, then we enable it.
- */
- if (!isEnabled) {
- const gdprsettingToggle = adminPage.locator(
- "div:nth-child(6) > div > .mb-4 > .relative > div"
- );
- await gdprsettingToggle.waitFor({ state: "visible", timeout: 5000 });
- await adminPage
- .locator("div:nth-child(6) > div > .mb-4 > .relative > div")
- .click();
- }
- /**
- * Verifying enable state.
- */
- const toggleInput = adminPage.locator(
- "div:nth-child(6) > div > .mb-4 > .relative > div"
- );
- await expect(toggleInput).toBeChecked();
- await adminPage
- .locator('select[name="general[gdpr][cookie][position]"]')
- .selectOption(position);
- await adminPage
- .getByRole("textbox", {
- name: "Static Block Identifier",
- })
- .fill("cookie block");
- await adminPage
- .getByRole("textbox", {
- name: "Description",
- })
- .fill("this website uses cookies to ensure you");
- /**
- * Save the configuration.
- */
- await adminPage.click('button[type="submit"].primary-button:visible');
- }
|