Fix: Embed Tests - Handle superfast switching to next month bug (#2929)
* Wait for more time for next month dates to fully render * Add comments * Wait for rendering of current month as well * Fix retries * Fix speed issue with non embed tests asw ell
This commit is contained in:
1 parent
7d2c0ab405
commit
514cff7b3c
4 files changed
+33
-10
No files matched your search
@@ -1,7 +1,5 @@
|
|||||||
name: E2E test - embed
|
name: E2E test
|
||||||
on:
|
on:
|
||||||
push:
|
|
||||||
branches: [ tests/ci-embed ]
|
|
||||||
pull_request_target: # So we can test on forks
|
pull_request_target: # So we can test on forks
|
||||||
branches:
|
branches:
|
||||||
- main
|
- main
|
||||||
@@ -18,7 +16,7 @@ on:
|
|||||||
jobs:
|
jobs:
|
||||||
test:
|
test:
|
||||||
timeout-minutes: 20
|
timeout-minutes: 20
|
||||||
name: Testing Embeds
|
name: Embed and booking flow(for non-embed as well)
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
node: ["14.x"]
|
node: ["14.x"]
|
||||||
|
|||||||
@@ -70,6 +70,12 @@ export async function waitFor(fn: () => Promise<unknown> | unknown, opts: { time
|
|||||||
}
|
}
|
||||||
|
|
||||||
export async function selectFirstAvailableTimeSlotNextMonth(page: Page) {
|
export async function selectFirstAvailableTimeSlotNextMonth(page: Page) {
|
||||||
|
// Let current month dates fully render.
|
||||||
|
// There is a bug where if we don't let current month fully render and quickly click go to next month, current month get's rendered
|
||||||
|
// This doesn't seem to be replicable with the speed of a person, only during automation.
|
||||||
|
// It would also allow correct snapshot to be taken for current month.
|
||||||
|
// eslint-disable-next-line playwright/no-wait-for-timeout
|
||||||
|
await page.waitForTimeout(1000);
|
||||||
await page.click('[data-testid="incrementMonth"]');
|
await page.click('[data-testid="incrementMonth"]');
|
||||||
// @TODO: Find a better way to make test wait for full month change render to end
|
// @TODO: Find a better way to make test wait for full month change render to end
|
||||||
// so it can click up on the right day, also when resolve remove other todos
|
// so it can click up on the right day, also when resolve remove other todos
|
||||||
@@ -82,6 +88,12 @@ export async function selectFirstAvailableTimeSlotNextMonth(page: Page) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export async function selectSecondAvailableTimeSlotNextMonth(page: Page) {
|
export async function selectSecondAvailableTimeSlotNextMonth(page: Page) {
|
||||||
|
// Let current month dates fully render.
|
||||||
|
// There is a bug where if we don't let current month fully render and quickly click go to next month, current month get's rendered
|
||||||
|
// This doesn't seem to be replicable with the speed of a person, only during automation.
|
||||||
|
// It would also allow correct snapshot to be taken for current month.
|
||||||
|
// eslint-disable-next-line playwright/no-wait-for-timeout
|
||||||
|
await page.waitForTimeout(1000);
|
||||||
await page.click('[data-testid="incrementMonth"]');
|
await page.click('[data-testid="incrementMonth"]');
|
||||||
// @TODO: Find a better way to make test wait for full month change render to end
|
// @TODO: Find a better way to make test wait for full month change render to end
|
||||||
// so it can click up on the right day, also when resolve remove other todos
|
// so it can click up on the right day, also when resolve remove other todos
|
||||||
@@ -95,7 +107,9 @@ export async function selectSecondAvailableTimeSlotNextMonth(page: Page) {
|
|||||||
|
|
||||||
export async function bookFirstEvent(page: Page) {
|
export async function bookFirstEvent(page: Page) {
|
||||||
// Click first event type
|
// Click first event type
|
||||||
|
|
||||||
await page.click('[data-testid="event-type-link"]');
|
await page.click('[data-testid="event-type-link"]');
|
||||||
|
|
||||||
await selectFirstAvailableTimeSlotNextMonth(page);
|
await selectFirstAvailableTimeSlotNextMonth(page);
|
||||||
await bookTimeSlot(page);
|
await bookTimeSlot(page);
|
||||||
|
|
||||||
|
|||||||
@@ -6,13 +6,14 @@ require("dotenv").config({ path: "../../../../../.env" });
|
|||||||
const outputDir = path.join("../results");
|
const outputDir = path.join("../results");
|
||||||
const testDir = path.join("../tests");
|
const testDir = path.join("../tests");
|
||||||
const quickMode = process.env.QUICK === "true";
|
const quickMode = process.env.QUICK === "true";
|
||||||
|
const CI = process.env.CI;
|
||||||
const config: PlaywrightTestConfig = {
|
const config: PlaywrightTestConfig = {
|
||||||
forbidOnly: !!process.env.CI,
|
forbidOnly: !!CI,
|
||||||
retries: quickMode ? 0 : 1,
|
retries: quickMode && !CI ? 0 : 1,
|
||||||
workers: 1,
|
workers: 1,
|
||||||
timeout: 60_000,
|
timeout: 60_000,
|
||||||
reporter: [
|
reporter: [
|
||||||
[process.env.CI ? "github" : "list"],
|
[CI ? "github" : "list"],
|
||||||
[
|
[
|
||||||
"html",
|
"html",
|
||||||
{ outputFolder: path.join(__dirname, "..", "reports", "playwright-html-report"), open: "never" },
|
{ outputFolder: path.join(__dirname, "..", "reports", "playwright-html-report"), open: "never" },
|
||||||
@@ -33,13 +34,13 @@ const config: PlaywrightTestConfig = {
|
|||||||
command: "yarn run-p 'embed-dev' 'embed-web-start'",
|
command: "yarn run-p 'embed-dev' 'embed-web-start'",
|
||||||
port: 3100,
|
port: 3100,
|
||||||
timeout: 60_000,
|
timeout: 60_000,
|
||||||
reuseExistingServer: !process.env.CI,
|
reuseExistingServer: !CI,
|
||||||
},
|
},
|
||||||
use: {
|
use: {
|
||||||
baseURL: "http://localhost:3100",
|
baseURL: "http://localhost:3100",
|
||||||
locale: "en-US",
|
locale: "en-US",
|
||||||
trace: "retain-on-failure",
|
trace: "retain-on-failure",
|
||||||
headless: !!process.env.CI || !!process.env.PLAYWRIGHT_HEADLESS,
|
headless: !!CI || !!process.env.PLAYWRIGHT_HEADLESS,
|
||||||
},
|
},
|
||||||
projects: [
|
projects: [
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -60,8 +60,11 @@ export const getEmbedIframe = async ({ page, pathname }: { page: Page; pathname:
|
|||||||
|
|
||||||
async function selectFirstAvailableTimeSlotNextMonth(frame: Frame, page: Page) {
|
async function selectFirstAvailableTimeSlotNextMonth(frame: Frame, page: Page) {
|
||||||
await frame.click('[data-testid="incrementMonth"]');
|
await frame.click('[data-testid="incrementMonth"]');
|
||||||
|
|
||||||
// @TODO: Find a better way to make test wait for full month change render to end
|
// @TODO: Find a better way to make test wait for full month change render to end
|
||||||
// so it can click up on the right day, also when resolve remove other todos
|
// so it can click up on the right day, also when done, resolve other todos as well
|
||||||
|
// The problem is that the Month Text changes instantly but we don't know when the corresponding dates are visible
|
||||||
|
|
||||||
// Waiting for full month increment
|
// Waiting for full month increment
|
||||||
await frame.waitForTimeout(1000);
|
await frame.waitForTimeout(1000);
|
||||||
expect(await page.screenshot()).toMatchSnapshot("availability-page-2.png");
|
expect(await page.screenshot()).toMatchSnapshot("availability-page-2.png");
|
||||||
@@ -78,7 +81,14 @@ export async function bookFirstEvent(username: string, frame: Frame, page: Page)
|
|||||||
return !!url.pathname.match(new RegExp(`/${username}/.*$`));
|
return !!url.pathname.match(new RegExp(`/${username}/.*$`));
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Let current month dates fully render.
|
||||||
|
// There is a bug where if we don't let current month fully render and quickly click go to next month, current month get's rendered
|
||||||
|
// This doesn't seem to be replicable with the speed of a person, only during automation.
|
||||||
|
// It would also allow correct snapshot to be taken for current month.
|
||||||
|
await frame.waitForTimeout(1000);
|
||||||
expect(await page.screenshot()).toMatchSnapshot("availability-page-1.png");
|
expect(await page.screenshot()).toMatchSnapshot("availability-page-1.png");
|
||||||
|
|
||||||
await selectFirstAvailableTimeSlotNextMonth(frame, page);
|
await selectFirstAvailableTimeSlotNextMonth(frame, page);
|
||||||
await frame.waitForNavigation({
|
await frame.waitForNavigation({
|
||||||
url(url) {
|
url(url) {
|
||||||
|
|||||||
Reference in new issue
Block a user