Skip to content

Commit

Permalink
test(extension): e2e - fix text comparison for Edge (#272)
Browse files Browse the repository at this point in the history
* test(extension): e2e - fix workflow when running multiple tags

* test(extension): e2e - fix text comparision for Edge
  • Loading branch information
ljagiela authored Jul 17, 2023
1 parent 3e62376 commit 9715247
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 12 deletions.
21 changes: 18 additions & 3 deletions packages/e2e-tests/src/assert/settings/CookiePolicyDrawerAssert.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import CookiePolicyDrawer from '../../elements/settings/CookiePolicyDrawer';
import { expect } from 'chai';
import { readFromFile } from '../../utils/fileUtils';
import { t } from '../../utils/translationService';
import { browser } from '@wdio/globals';
import { removeWhitespacesFromText } from '../../utils/textUtils';

class CookiePolicyDrawerAssert {
assertSeeDrawerNavigationTitle = async () => {
Expand All @@ -28,9 +30,22 @@ class CookiePolicyDrawerAssert {

assertSeeCookiePolicyContent = async () => {
await CookiePolicyDrawer.cookiePolicyContent.waitForDisplayed();
const actualCookiePolicyText = await CookiePolicyDrawer.cookiePolicyContent.getText();
const expectedCookiePolicyText = readFromFile(__dirname, './cookiePolicy.txt');
await expect(actualCookiePolicyText).to.equal(expectedCookiePolicyText);

const expectedCookiePolicyText = await removeWhitespacesFromText(readFromFile(__dirname, './cookiePolicy.txt'));

await browser.waitUntil(
async () =>
(await removeWhitespacesFromText(await CookiePolicyDrawer.cookiePolicyContent.getText())) ===
expectedCookiePolicyText,
{
timeout: 3000,
interval: 1000,
timeoutMsg: `failed while waiting for expected cookie policy text
expected: ${expectedCookiePolicyText}
current: ${await removeWhitespacesFromText(await CookiePolicyDrawer.cookiePolicyContent.getText())}
`
}
);
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { t } from '../../utils/translationService';
import { expect } from 'chai';
import { readFromFile } from '../../utils/fileUtils';
import { removeWhitespacesFromText } from '../../utils/textUtils';
import { browser } from '@wdio/globals';

class PrivacyPolicyDrawerAssert {
assertSeeDrawerNavigationTitle = async () => {
Expand All @@ -28,11 +29,20 @@ class PrivacyPolicyDrawerAssert {
}

async assertSeePrivacyPolicyContent() {
const expectedPolicy = readFromFile(__dirname, '../settings/privacyPolicy.txt');
const expectedPolicy = await removeWhitespacesFromText(readFromFile(__dirname, '../settings/privacyPolicy.txt'));
await PrivacyPolicyDrawer.privacyPolicyContent.waitForDisplayed();
const currentPolicy = await PrivacyPolicyDrawer.privacyPolicyContent.getText();
await expect(await removeWhitespacesFromText(currentPolicy)).to.equal(
await removeWhitespacesFromText(expectedPolicy)

await browser.waitUntil(
async () =>
(await removeWhitespacesFromText(await PrivacyPolicyDrawer.privacyPolicyContent.getText())) === expectedPolicy,
{
timeout: 3000,
interval: 1000,
timeoutMsg: `failed while waiting for expected privacy policy text
expected: ${expectedPolicy}
current: ${await removeWhitespacesFromText(await PrivacyPolicyDrawer.privacyPolicyContent.getText())}
`
}
);
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,31 @@
import TermsAndConditionsDrawer from '../../elements/settings/TermsAndConditionsDrawer';
import { expect } from 'chai';
import { removeWhitespacesFromText } from '../../utils/textUtils';
import { readFromFile } from '../../utils/fileUtils';
import { isPopupMode } from '../../utils/pageUtils';
import { browser } from '@wdio/globals';

class TermsAndConditionsSettingsDrawerAssert {
assertTermsAndConditionsContent = async () => {
(await isPopupMode())
? await TermsAndConditionsDrawer.drawerHeaderBackButton.waitForClickable()
: await TermsAndConditionsDrawer.drawerHeaderCloseButton.waitForClickable();
await TermsAndConditionsDrawer.termsAndConditionsContent.waitForDisplayed();
const actualContent = await removeWhitespacesFromText(
await TermsAndConditionsDrawer.termsAndConditionsContent.getText()

const expectedPolicy = await removeWhitespacesFromText(readFromFile(__dirname, './termsAndConditions.txt'));

await browser.waitUntil(
async () =>
(await removeWhitespacesFromText(await TermsAndConditionsDrawer.termsAndConditionsContent.getText())) ===
expectedPolicy,
{
timeout: 3000,
interval: 1000,
timeoutMsg: `failed while waiting for expected T&C policy text
expected: ${expectedPolicy}
current: ${await removeWhitespacesFromText(await TermsAndConditionsDrawer.termsAndConditionsContent.getText())}
`
}
);
const expectedContent = await removeWhitespacesFromText(readFromFile(__dirname, './termsAndConditions.txt'));
await expect(actualContent).to.equal(expectedContent);
};
}

Expand Down

0 comments on commit 9715247

Please sign in to comment.