-
Notifications
You must be signed in to change notification settings - Fork 117
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
test(DIST-136): Increase resilience for visual tests in firefox #2
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,24 @@ | ||
window.messages = [] | ||
window.addEventListener('message', function (event) { | ||
console.log(`${event.data.type} event has been triggered`) | ||
// Changes the document title when the form is ready | ||
if (event.data.type === 'form-ready') { | ||
window.document.title = event.data.type | ||
} | ||
Comment on lines
+4
to
+7
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Once the form is loaded, the page will receive a |
||
}) | ||
|
||
var queryString = window.location.search | ||
|
||
var EMBED_DOM_CLASSES = [ | ||
{ | ||
selector: '.typeform-widget', | ||
attribute: 'data-url', | ||
attribute: 'data-url' | ||
}, { | ||
selector: '.typeform-share', | ||
attribute: 'href', | ||
attribute: 'href' | ||
}, { | ||
selector: '.typeform-full', | ||
attribute: 'src', | ||
}, | ||
attribute: 'src' | ||
} | ||
antoniofull marked this conversation as resolved.
Show resolved
Hide resolved
|
||
] | ||
|
||
window.addEventListener('DOMContentLoaded', function () { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,7 +27,7 @@ | |
width="100%" | ||
height="100%" | ||
frameborder="0" | ||
src="https://admin.typeform.com/to/pDgR2Z" | ||
src="https://admin.typeform.com/to/mzy0hT?disable-tracking=true" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We use a static form without initial animation, since this seems to be the main issue |
||
></iframe> | ||
|
||
<script type="text/javascript" src="embed.js"></script> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,6 +26,16 @@ module.exports = function () { | |
// For Visual Tests requires more waiting time | ||
waitForVisualElement (cssLocator) { | ||
this.waitForVisible({ css: cssLocator }, 10) | ||
}, | ||
async waitForIFrameMessage () { | ||
this.executeAsyncScript(function (done) { | ||
const interval = setInterval(function () { | ||
if (window.document.title === 'form-ready') { | ||
clearInterval(interval) | ||
done() | ||
} | ||
}, 100) | ||
}) | ||
Comment on lines
+29
to
+38
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We cannot use directly window object with codeceptjs and webdriver, so we use |
||
} | ||
}) | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,7 +33,7 @@ export const setupIframeTesting = (iframe) => { | |
// We can only use it inside Chrome disabling web security --> see config | ||
// Won't work in popups | ||
if (Cypress.isBrowser('chrome')) { | ||
getIframeBody(iframe).find('[data-qa="fixed-footer-progress"]').should('be.visible') | ||
getIframeBody(iframe).find('[data-qa="start-button"]').should('be.visible') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. NIT: Since we changed form, we still want to have some resilience to make sure the form is loaded internally, the new form has a start button so we check for it. This is for functional tests |
||
} else { | ||
cy.get(iframe).should('be.visible') | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,74 +1,85 @@ | ||
const { resizeWindow } = require('../codeceptjs-utils') | ||
|
||
const clickOnLink = (I, n = 1) => { | ||
const clickOnLink = async (I, n = 1) => { | ||
const cssLinkSelector = `[data-mode="${n}"]` | ||
I.click({ css: cssLinkSelector }) | ||
await I.click({ css: cssLinkSelector }) | ||
} | ||
|
||
const waitForIFrame = async (I) => { | ||
await I.waitForVisible({ css: 'iframe' }, WAITING_TIME) | ||
await I.waitForIFrameMessage() | ||
} | ||
const WAITING_TIME = 5 | ||
|
||
antoniofull marked this conversation as resolved.
Show resolved
Hide resolved
|
||
Feature('Embed Widget') | ||
|
||
Scenario('Basic Widget', async (I) => { | ||
I.amOnPage('widget.html') | ||
I.waitForVisible({ css: 'iframe' }, 5) | ||
Scenario('Basic Widget @desktop', async (I) => { | ||
await I.amOnPage('widget.html') | ||
await waitForIFrame(I) | ||
antoniofull marked this conversation as resolved.
Show resolved
Hide resolved
|
||
await I.eyesCheck('Embed Basic Widget') | ||
}) | ||
|
||
Scenario('Full Page Widget', async (I) => { | ||
I.amOnPage('full.html') | ||
I.waitForVisible({ css: 'iframe' }, 5) | ||
Scenario('Full Page Widget @desktop', async (I) => { | ||
await I.amOnPage('full.html') | ||
await waitForIFrame(I) | ||
await I.eyesCheck('Embed Full Page Widget') | ||
}) | ||
|
||
Scenario('Basic Widget on Mobile', async (I) => { | ||
resizeWindow(I) | ||
I.amOnPage('widget.html') | ||
Scenario('Basic Widget @mobile', async (I) => { | ||
await resizeWindow(I) | ||
await I.amOnPage('widget.html') | ||
await waitForIFrame(I) | ||
await I.eyesCheck('Embed Basic Widget - Mobile') | ||
}) | ||
|
||
Scenario('Full Page Widget on Mobile', async (I) => { | ||
resizeWindow(I) | ||
I.amOnPage('full.html') | ||
Scenario('Full Page Widget @mobile', async (I) => { | ||
await resizeWindow(I) | ||
await I.amOnPage('full.html') | ||
await waitForIFrame(I) | ||
await I.eyesCheck('Embed Full Page Widget - Mobile') | ||
}) | ||
|
||
Scenario('Popup Widget', async (I) => { | ||
I.amOnPage('popup.html') | ||
clickOnLink(I, 1) | ||
I.waitForVisible({ css: 'iframe' }, 10) | ||
Scenario('Popup Widget @desktop', async (I) => { | ||
await I.amOnPage('popup.html') | ||
await clickOnLink(I, 1) | ||
await waitForIFrame(I) | ||
await I.eyesCheck('Popup Widget') | ||
}) | ||
|
||
Scenario('Popup Widget on Mobile', async (I) => { | ||
resizeWindow(I) | ||
I.amOnPage('popup.html') | ||
clickOnLink(I, 1) | ||
Scenario('Popup Widget @mobile', async (I) => { | ||
await resizeWindow(I) | ||
await I.amOnPage('popup.html') | ||
await clickOnLink(I, 1) | ||
await waitForIFrame(I) | ||
await I.eyesCheck('Popup Widget') | ||
}) | ||
|
||
Scenario('Drawer Widget', async (I) => { | ||
I.amOnPage('popup.html') | ||
clickOnLink(I, 2) | ||
I.waitForVisible({ css: 'iframe' }, 10) | ||
Scenario('Drawer Widget @desktop', async (I) => { | ||
await I.amOnPage('popup.html') | ||
await clickOnLink(I, 2) | ||
await waitForIFrame(I) | ||
await I.eyesCheck('Drawer Widget') | ||
}) | ||
|
||
Scenario('Drawer Widget on Mobile', async (I) => { | ||
resizeWindow(I) | ||
I.amOnPage('popup.html') | ||
clickOnLink(I, 2) | ||
Scenario('Drawer Widget @mobile', async (I) => { | ||
await resizeWindow(I) | ||
await I.amOnPage('popup.html') | ||
await clickOnLink(I, 2) | ||
await waitForIFrame(I) | ||
await I.eyesCheck('Drawer Widget - Mobile') | ||
}) | ||
|
||
Scenario('Right Drawer Widget', async (I) => { | ||
I.amOnPage('popup.html') | ||
clickOnLink(I, 3) | ||
I.waitForVisible({ css: 'iframe' }, 10) | ||
Scenario('Right Drawer Widget @desktop', async (I) => { | ||
await I.amOnPage('popup.html') | ||
await clickOnLink(I, 3) | ||
await waitForIFrame(I) | ||
await I.eyesCheck('Popup Widget') | ||
}) | ||
|
||
Scenario('Right Drawer Widget on Mobile', async (I) => { | ||
resizeWindow(I) | ||
I.amOnPage('popup.html') | ||
clickOnLink(I, 3) | ||
Scenario('Right Drawer Widget @mobile', async (I) => { | ||
await resizeWindow(I) | ||
await I.amOnPage('popup.html') | ||
await clickOnLink(I, 3) | ||
await waitForIFrame(I) | ||
await I.eyesCheck('Right Drawer Widget - Mobile') | ||
}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Runs firefox visual tests in parallel on travis (speed up tests)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, we can run tests in parallel for each browser 👍 I suggest you run
yarn test:visual:mobile
separately as well.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good I wasn't sure if creating many jobs in parallel would cause issues, thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I dont think it would. Each job needs to clone the repo and install dependencies - if the task is short it usually should not have a separate job. If it takes longer than cloning and installing and has no dependencies it can be a separate job.
I think I would also split functional tests per browser to make it faster.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 give me 10 minutes and I'll push the changes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One build failed because both tests were running in parallel, I wonder if makes more sense to run one job with both tests in parallel (as @Gotusso set it up) or separated? I am not sure about it. Thoughts @mathio ? (right now I split them and removed the parallel flag)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe try without the
--parallel
flag for cypress? But I would check with Franco first. So for now feel free to keep this as is.Edit: I re-run the tests and they passed 🤷♂️ When run in separate Travis jobs it saves ~30 seconds of total run time.