From a9243077b4b5423dfb339cef07c89464545e0e3a Mon Sep 17 00:00:00 2001 From: Peter <53189696+PeterYinusa@users.noreply.github.com> Date: Fri, 28 Apr 2023 14:37:06 +0100 Subject: [PATCH] Terms of use e2e (#18861) * use substitution * add test --- test/e2e/fixture-builder.js | 3 +- test/e2e/tests/terms-of-use.spec.js | 45 +++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+), 1 deletion(-) create mode 100644 test/e2e/tests/terms-of-use.spec.js diff --git a/test/e2e/fixture-builder.js b/test/e2e/fixture-builder.js index aeecb1388..bb844ba4a 100644 --- a/test/e2e/fixture-builder.js +++ b/test/e2e/fixture-builder.js @@ -140,7 +140,8 @@ function defaultFixture() { browserEnvironment: {}, nftsDropdownState: {}, connectedStatusPopoverHasBeenShown: true, - termsOfUseLastAgreed: 86400000000000, + termsOfUseLastAgreed: + '__FIXTURE_SUBSTITUTION__currentDateInMilliseconds', defaultHomeActiveTabName: null, fullScreenGasPollTokens: [], notificationGasPollTokens: [], diff --git a/test/e2e/tests/terms-of-use.spec.js b/test/e2e/tests/terms-of-use.spec.js new file mode 100644 index 000000000..f224cb55a --- /dev/null +++ b/test/e2e/tests/terms-of-use.spec.js @@ -0,0 +1,45 @@ +const { strict: assert } = require('assert'); +const { convertToHexValue, withFixtures } = require('../helpers'); +const FixtureBuilder = require('../fixture-builder'); + +describe('Terms of use', function () { + const ganacheOptions = { + accounts: [ + { + secretKey: + '0x7C9529A67102755B7E6102D6D950AC5D5863C98713805CEC576B945B15B71EAC', + balance: convertToHexValue(25000000000000000000), + }, + ], + }; + it('accepts the updated terms of use', async function () { + const firstOfJan = 1672574400; + await withFixtures( + { + fixtures: new FixtureBuilder() + .withAppStateController({ + termsOfUseLastAgreed: firstOfJan, + }) + .build(), + ganacheOptions, + title: this.test.title, + }, + async ({ driver }) => { + await driver.navigate(); + await driver.fill('#password', 'correct horse battery staple'); + await driver.press('#password', driver.Key.ENTER); + + // accept updated terms of use + const acceptTerms = '[data-testid="terms-of-use-accept-button"]'; + await driver.clickElement('[data-testid="popover-scroll-button"]'); + await driver.clickElement('[data-testid="terms-of-use-checkbox"]'); + await driver.clickElement(acceptTerms); + + // check modal is no longer shown + await driver.waitForElementNotPresent(acceptTerms); + const termsExists = await driver.isElementPresent(acceptTerms); + assert.equal(termsExists, false, 'terms of use should not be shown'); + }, + ); + }); +});