36 lines
1.1 KiB
JavaScript
36 lines
1.1 KiB
JavaScript
'use strict';
|
|
|
|
const assert = require('assert');
|
|
const { _private: commonAuthPrivate } = require('../src/services/common_auth');
|
|
const { _private: loginPrivate } = require('../src/services/login_service');
|
|
|
|
function locator(matched, text = '') {
|
|
return {
|
|
or(other) {
|
|
return locator(matched || !!other.matched, matched ? text : other.text);
|
|
},
|
|
matched,
|
|
text,
|
|
count: async () => (matched ? 1 : 0),
|
|
locator: () => locator(false),
|
|
first: () => ({
|
|
isVisible: async () => matched,
|
|
textContent: async () => (matched ? text : ''),
|
|
}),
|
|
};
|
|
}
|
|
|
|
(async () => {
|
|
const message = 'Your password was changed 10 days ago';
|
|
const page = {
|
|
locator: selector => locator(selector.includes('Your\\s*password') || selector.includes('Your\\s+password'), message),
|
|
};
|
|
|
|
assert.strictEqual(await commonAuthPrivate.detectPasswordChangedRecentlyText(page), message);
|
|
assert.strictEqual(await loginPrivate.detectPasswordChangedRecentlyText(page), message);
|
|
console.log('password_changed_detection.test.js: PASS');
|
|
})().catch(error => {
|
|
console.error(error);
|
|
process.exitCode = 1;
|
|
});
|