From b91a990ef701a6f5f4e8949ab14968506612c06a Mon Sep 17 00:00:00 2001 From: Clara Youdale Date: Mon, 24 Jun 2024 14:46:38 -0300 Subject: [PATCH 1/8] Migrate rss.cy and signup.cy to Playwright --- .../cypress/e2e/integration/rss.cy.js | 56 ------- .../cypress/e2e/integration/signup.cy.js | 137 ------------------ site/gatsby-site/playwright/e2e/rss.spec.ts | 50 +++++++ .../gatsby-site/playwright/e2e/signup.spec.ts | 123 ++++++++++++++++ 4 files changed, 173 insertions(+), 193 deletions(-) delete mode 100644 site/gatsby-site/cypress/e2e/integration/rss.cy.js delete mode 100644 site/gatsby-site/cypress/e2e/integration/signup.cy.js create mode 100644 site/gatsby-site/playwright/e2e/rss.spec.ts create mode 100644 site/gatsby-site/playwright/e2e/signup.spec.ts diff --git a/site/gatsby-site/cypress/e2e/integration/rss.cy.js b/site/gatsby-site/cypress/e2e/integration/rss.cy.js deleted file mode 100644 index eb9ca27c31..0000000000 --- a/site/gatsby-site/cypress/e2e/integration/rss.cy.js +++ /dev/null @@ -1,56 +0,0 @@ -import { conditionalIt } from '../../support/utils'; - -describe('RSS', () => { - it('Should generate a valid RSS feed', () => { - cy.request('/rss.xml').then((response) => { - expect(response.status).to.eq(200); - expect(response.headers['content-type']).to.include('application/xml'); - - const xml = response.body; - - const parsedXml = Cypress.$.parseXML(xml); - - const hasChannelTag = Cypress.$(parsedXml).find('channel').length > 0; - - expect(hasChannelTag).to.be.true; - - const items = Cypress.$(parsedXml).find('channel > item').slice(0, 20); - - expect(items.length).to.be.greaterThan(0); - }); - }); - - conditionalIt(!Cypress.env('isEmptyEnvironment'), 'Should generate a valid RSS feed data', () => { - cy.request('/rss.xml').then((response) => { - expect(response.status).to.eq(200); - expect(response.headers['content-type']).to.include('application/xml'); - - const xml = response.body; - - const parsedXml = Cypress.$.parseXML(xml); - - const hasChannelTag = Cypress.$(parsedXml).find('channel').length > 0; - - expect(hasChannelTag).to.be.true; - - const items = Cypress.$(parsedXml).find('channel > item').slice(0, 20); - - expect(items.length).to.be.greaterThan(0); - - items.each((_index, item) => { - const description = Cypress.$(item).find('description'); - - const title = Cypress.$(item).find('title'); - - const pubDate = Cypress.$(item).find('pubDate'); - - const guid = Cypress.$(item).find('guid'); - - expect(description.length).to.equal(1); - expect(title.length).to.equal(1); - expect(pubDate.length).to.equal(1); - expect(guid.length).to.equal(1); - }); - }); - }); -}); diff --git a/site/gatsby-site/cypress/e2e/integration/signup.cy.js b/site/gatsby-site/cypress/e2e/integration/signup.cy.js deleted file mode 100644 index 4baeb16ba5..0000000000 --- a/site/gatsby-site/cypress/e2e/integration/signup.cy.js +++ /dev/null @@ -1,137 +0,0 @@ -import { conditionalIt } from '../../support/utils'; - -describe('Signup', () => { - const url = '/signup'; - - it('Should successfully load sign up page', () => { - cy.visit(url); - }); - - it('Should display success a toast message after a sign up', () => { - cy.visit(url); - - const email = 'newUser@test.com'; - - const password = 'newUserPassword'; - - cy.get('[data-cy="signup-btn"]').click(); - - cy.get('input[name=email]').type(email); - cy.get('input[name=password]').type(password); - cy.get('input[name=passwordConfirm]').type(password); - - cy.conditionalIntercept( - '**/register', - (req) => req.body.email == email && req.body.password == password, - 'Register', - { - statusCode: 201, - } - ); - - cy.get('[data-cy="signup-btn"]').click(); - cy.wait('@Register'); - - cy.getAllLocalStorage().then((result) => { - expect(result[Cypress.config().baseUrl.replace(/\/$/, '')].signup).to.not.be.undefined; - }); - - cy.get('[data-cy="toast"]').contains(`Verification email sent to ${email}`).should('exist'); - }); - - conditionalIt( - !Cypress.env('isEmptyEnvironment') && Cypress.env('e2eUsername') && Cypress.env('e2ePassword'), - 'Should display the error toast message if the user already exists', - () => { - cy.visit(url); - - cy.get('[data-cy="signup-btn"]').click(); - - cy.get('input[name=email]').type(Cypress.env('e2eUsername')); - cy.get('input[name=password]').type('anyPassword'); - cy.get('input[name=passwordConfirm]').type('anyPassword'); - cy.get('[data-cy="signup-btn"]').click(); - cy.get('[data-cy="toast"]').contains('name already in use').should('exist'); - } - ); - - it('Should display the error toast message if any other sign up error occur', () => { - cy.visit(url); - - cy.get('[data-cy="signup-btn"]').click(); - - cy.get('input[name=email]').type('test@test.com'); - cy.get('input[name=password]').type('anyPassword'); - cy.get('input[name=passwordConfirm]').type('anyPassword'); - - cy.intercept('POST', '**/register', { - statusCode: 500, - body: { - error: 'Something bad happened :(', - }, - }); - - cy.get('[data-cy="signup-btn"]').click(); - cy.get('[data-cy="toast"]').contains('Something bad happened :(').should('exist'); - }); - - it('Should redirect to specific page after sign up if redirectTo is provided', () => { - const redirectTo = '/cite/10/'; - - cy.visit(`${url}?redirectTo=${redirectTo}`); - - cy.get('[data-cy="signup-btn"]').click(); - - const email = 'newUser@test.com'; - - const password = 'newUserPassword'; - - cy.get('input[name=email]').type(email); - cy.get('input[name=password]').type(password); - cy.get('input[name=passwordConfirm]').type(password); - - cy.intercept('POST', '**/register', { - statusCode: 201, - }); - - cy.conditionalIntercept( - '**/register', - (req) => req.body.email == email && req.body.password == password, - 'Register', - { - statusCode: 201, - } - ); - - cy.get('[data-cy="signup-btn"]').click(); - cy.wait('@Register'); - cy.location('pathname', { timeout: 8000 }).should('eq', redirectTo); - }); - - it('Should display success a toast message after a subscription to Major updates', () => { - cy.visit(url); - - const email = 'newUser@test.com'; - - cy.get('input[name=emailSubscription]').type(email); - - cy.intercept('POST', '**/register', { - statusCode: 201, - }); - - cy.conditionalIntercept( - '**/register', - (req) => req.body.email == email && req.body.password == '123456', - 'Register', - { - statusCode: 201, - } - ); - - cy.get('[data-cy="subscribe-to-updates-btn"]').click(); - cy.wait('@Register'); - cy.get('[data-cy="toast"]') - .contains(`Thanks for subscribing to our Newsletter!`) - .should('exist'); - }); -}); diff --git a/site/gatsby-site/playwright/e2e/rss.spec.ts b/site/gatsby-site/playwright/e2e/rss.spec.ts new file mode 100644 index 0000000000..d692e20c2a --- /dev/null +++ b/site/gatsby-site/playwright/e2e/rss.spec.ts @@ -0,0 +1,50 @@ +import { expect } from '@playwright/test'; +import { test } from '../utils'; + +test.describe('RSS', () => { + test('Should generate a valid RSS feed', async ({ page }) => { + const response = await page.request.get('/rss.xml'); + expect(response.status()).toBe(200); + expect(response.headers()['content-type']).toContain('application/xml'); + + const xml = await response.text(); + + const parser = new DOMParser(); + const parsedXml = parser.parseFromString(xml, 'application/xml'); + + const hasChannelTag = parsedXml.querySelectorAll('channel').length > 0; + expect(hasChannelTag).toBe(true); + + const items = Array.from(parsedXml.querySelectorAll('channel > item')).slice(0, 20); + expect(items.length).toBeGreaterThan(0); + }); + + test('Should generate a valid RSS feed data', async ({ page, skipOnEmptyEnvironment }) => { + const response = await page.request.get('/rss.xml'); + expect(response.status()).toBe(200); + expect(response.headers()['content-type']).toContain('application/xml'); + + const xml = await response.text(); + + const parser = new DOMParser(); + const parsedXml = parser.parseFromString(xml, 'application/xml'); + + const hasChannelTag = parsedXml.querySelectorAll('channel').length > 0; + expect(hasChannelTag).toBe(true); + + const items = Array.from(parsedXml.querySelectorAll('channel > item')).slice(0, 20); + expect(items.length).toBeGreaterThan(0); + + items.forEach((item) => { + const description = item.querySelector('description'); + const title = item.querySelector('title'); + const pubDate = item.querySelector('pubDate'); + const guid = item.querySelector('guid'); + + expect(description).not.toBeNull(); + expect(title).not.toBeNull(); + expect(pubDate).not.toBeNull(); + expect(guid).not.toBeNull(); + }); + }); +}); diff --git a/site/gatsby-site/playwright/e2e/signup.spec.ts b/site/gatsby-site/playwright/e2e/signup.spec.ts new file mode 100644 index 0000000000..cafa1d65f6 --- /dev/null +++ b/site/gatsby-site/playwright/e2e/signup.spec.ts @@ -0,0 +1,123 @@ +import { expect } from '@playwright/test'; +import { test, conditionalIntercept, waitForRequest } from '../utils'; + +test.describe('Signup', () => { + const url = '/signup'; + + test('Should successfully load sign up page', async ({ page }) => { + await page.goto(url); + }); + + test('Should display success toast message after a sign up', async ({ page }) => { + await page.goto(url); + + const email = 'newUser@test.com'; + const password = 'newUserPassword'; + + await page.locator('[data-cy="signup-btn"]').click(); + + await page.locator('input[name=email]').fill(email); + await page.locator('input[name=password]').fill(password); + await page.locator('input[name=passwordConfirm]').fill(password); + + await conditionalIntercept( + page, + '**/register', + (req) => req.postDataJSON().email == email && req.postDataJSON().password == password, + { statusCode: 201 }, + 'Register' + ); + + await page.locator('[data-cy="signup-btn"]').click(); + await waitForRequest('Register'); + + const result = await page.evaluate(() => JSON.parse(JSON.stringify(localStorage))); + expect(result).toHaveProperty('signup'); + await expect(page.locator('[data-cy="toast"]')).toBeVisible({ timeout: 30000 }); + await expect(page.locator('[data-cy="toast"]').getByText(`Verification email sent to ${email}`)).toBeVisible(); + }); + + test('Should display the error toast message if the user already exists', async ({ page, skipOnEmptyEnvironment }) => { + if (!skipOnEmptyEnvironment) return; + + await page.goto(url); + + await page.locator('[data-cy="signup-btn"]').click(); + + await page.locator('input[name=email]').fill(process.env.e2eUsername); + await page.locator('input[name=password]').fill('anyPassword'); + await page.locator('input[name=passwordConfirm]').fill('anyPassword'); + await page.locator('[data-cy="signup-btn"]').click(); + await expect(page.locator('[data-cy="toast"]').getByText('name already in use')).toBeVisible(); + }); + + test('Should display the error toast message if any other sign up error occurs', async ({ page }) => { + await page.goto(url); + + await page.locator('[data-cy="signup-btn"]').click(); + + await page.locator('input[name=email]').fill('test@test.com'); + await page.locator('input[name=password]').fill('anyPassword'); + await page.locator('input[name=passwordConfirm]').fill('anyPassword'); + + await conditionalIntercept( + page, + '**/register', + (req) => req.method() === 'POST', + { error: 'Something bad happened :(' }, + 'Register', + 500 + ); + + await page.locator('[data-cy="signup-btn"]').click(); + await waitForRequest('Register'); + await expect(page.locator('[data-cy="toast"]')).toBeVisible({ timeout: 30000 }); + await expect(page.locator('[data-cy="toast"]').getByText('Something bad happened :(')).toBeVisible(); + }); + + test('Should redirect to specific page after sign up if redirectTo is provided', async ({ page }) => { + const redirectTo = '/cite/10/'; + await page.goto(`${url}?redirectTo=${redirectTo}`); + + await page.locator('[data-cy="signup-btn"]').click(); + + const email = 'newUser@test.com'; + const password = 'newUserPassword'; + + await page.locator('input[name=email]').fill(email); + await page.locator('input[name=password]').fill(password); + await page.locator('input[name=passwordConfirm]').fill(password); + + await conditionalIntercept( + page, + '**/register', + (req) => req.postDataJSON().email == email && req.postDataJSON().password == password, + { statusCode: 201 }, + 'Register' + ); + + await page.locator('[data-cy="signup-btn"]').click(); + await waitForRequest('Register'); + await page.waitForURL(redirectTo); + }); + + test('Should display success toast message after a subscription to Major updates', async ({ page }) => { + await page.goto(url); + + const email = 'newUser@test.com'; + + await page.locator('input[name=emailSubscription]').fill(email); + + await conditionalIntercept( + page, + '**/register', + (req) => req.postDataJSON().email == email && req.postDataJSON().password == '123456', + { statusCode: 201 }, + 'Register' + ); + + await page.locator('[data-cy="subscribe-to-updates-btn"]').click(); + await waitForRequest('Register'); + await expect(page.locator('[data-cy="toast"]').getByText(`Thanks for subscribing to our Newsletter!`)).toBeVisible(); + }); +}); From 0f856a9256626612f5a42cd020a335f25d8573ff Mon Sep 17 00:00:00 2001 From: Clara Youdale Date: Tue, 25 Jun 2024 15:16:58 -0300 Subject: [PATCH 2/8] Update rss.spec.ts --- site/gatsby-site/playwright/e2e/rss.spec.ts | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/site/gatsby-site/playwright/e2e/rss.spec.ts b/site/gatsby-site/playwright/e2e/rss.spec.ts index d692e20c2a..3202a0f9f7 100644 --- a/site/gatsby-site/playwright/e2e/rss.spec.ts +++ b/site/gatsby-site/playwright/e2e/rss.spec.ts @@ -1,5 +1,5 @@ -import { expect } from '@playwright/test'; import { test } from '../utils'; +import { parse } from 'node-html-parser'; test.describe('RSS', () => { test('Should generate a valid RSS feed', async ({ page }) => { @@ -8,9 +8,7 @@ test.describe('RSS', () => { expect(response.headers()['content-type']).toContain('application/xml'); const xml = await response.text(); - - const parser = new DOMParser(); - const parsedXml = parser.parseFromString(xml, 'application/xml'); + const parsedXml = parse(xml); const hasChannelTag = parsedXml.querySelectorAll('channel').length > 0; expect(hasChannelTag).toBe(true); @@ -25,9 +23,7 @@ test.describe('RSS', () => { expect(response.headers()['content-type']).toContain('application/xml'); const xml = await response.text(); - - const parser = new DOMParser(); - const parsedXml = parser.parseFromString(xml, 'application/xml'); + const parsedXml = parse(xml); const hasChannelTag = parsedXml.querySelectorAll('channel').length > 0; expect(hasChannelTag).toBe(true); From 1aa0909b642b2da1013b8a240a59b2bba5a4ba9a Mon Sep 17 00:00:00 2001 From: Clara Youdale Date: Wed, 26 Jun 2024 13:24:32 -0300 Subject: [PATCH 3/8] Add expect to rss spec --- site/gatsby-site/playwright/e2e/rss.spec.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/site/gatsby-site/playwright/e2e/rss.spec.ts b/site/gatsby-site/playwright/e2e/rss.spec.ts index 3202a0f9f7..8469d3c27c 100644 --- a/site/gatsby-site/playwright/e2e/rss.spec.ts +++ b/site/gatsby-site/playwright/e2e/rss.spec.ts @@ -1,3 +1,4 @@ +import { expect } from '@playwright/test'; import { test } from '../utils'; import { parse } from 'node-html-parser'; From 7342df9d2e48e5cb7005b5f26716c699aff28163 Mon Sep 17 00:00:00 2001 From: Clara Youdale Date: Thu, 11 Jul 2024 12:38:41 -0300 Subject: [PATCH 4/8] Add console log --- site/gatsby-site/playwright/e2e/rss.spec.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/site/gatsby-site/playwright/e2e/rss.spec.ts b/site/gatsby-site/playwright/e2e/rss.spec.ts index 8469d3c27c..bc160fd74d 100644 --- a/site/gatsby-site/playwright/e2e/rss.spec.ts +++ b/site/gatsby-site/playwright/e2e/rss.spec.ts @@ -40,6 +40,7 @@ test.describe('RSS', () => { expect(description).not.toBeNull(); expect(title).not.toBeNull(); + console.log(pubDate, description) expect(pubDate).not.toBeNull(); expect(guid).not.toBeNull(); }); From 3cb44f2c6a5faefbadeeda22e1eaa81030091258 Mon Sep 17 00:00:00 2001 From: Clara Youdale Date: Thu, 11 Jul 2024 15:41:35 -0300 Subject: [PATCH 5/8] Use fast-xml-parser instead --- site/gatsby-site/playwright/e2e/rss.spec.ts | 64 +++++++++++---------- 1 file changed, 34 insertions(+), 30 deletions(-) diff --git a/site/gatsby-site/playwright/e2e/rss.spec.ts b/site/gatsby-site/playwright/e2e/rss.spec.ts index bc160fd74d..cb4cd6d4eb 100644 --- a/site/gatsby-site/playwright/e2e/rss.spec.ts +++ b/site/gatsby-site/playwright/e2e/rss.spec.ts @@ -1,6 +1,7 @@ import { expect } from '@playwright/test'; +import config from '../config'; import { test } from '../utils'; -import { parse } from 'node-html-parser'; +import { XMLParser } from 'fast-xml-parser'; test.describe('RSS', () => { test('Should generate a valid RSS feed', async ({ page }) => { @@ -9,40 +10,43 @@ test.describe('RSS', () => { expect(response.headers()['content-type']).toContain('application/xml'); const xml = await response.text(); - const parsedXml = parse(xml); + const parser = new XMLParser(); + const parsedXml = parser.parse(xml); - const hasChannelTag = parsedXml.querySelectorAll('channel').length > 0; + const hasChannelTag = parsedXml.rss.channel !== undefined; expect(hasChannelTag).toBe(true); - const items = Array.from(parsedXml.querySelectorAll('channel > item')).slice(0, 20); + const items = parsedXml.rss.channel.item.slice(0, 20); expect(items.length).toBeGreaterThan(0); }); - test('Should generate a valid RSS feed data', async ({ page, skipOnEmptyEnvironment }) => { - const response = await page.request.get('/rss.xml'); - expect(response.status()).toBe(200); - expect(response.headers()['content-type']).toContain('application/xml'); - - const xml = await response.text(); - const parsedXml = parse(xml); - - const hasChannelTag = parsedXml.querySelectorAll('channel').length > 0; - expect(hasChannelTag).toBe(true); - - const items = Array.from(parsedXml.querySelectorAll('channel > item')).slice(0, 20); - expect(items.length).toBeGreaterThan(0); - - items.forEach((item) => { - const description = item.querySelector('description'); - const title = item.querySelector('title'); - const pubDate = item.querySelector('pubDate'); - const guid = item.querySelector('guid'); - - expect(description).not.toBeNull(); - expect(title).not.toBeNull(); - console.log(pubDate, description) - expect(pubDate).not.toBeNull(); - expect(guid).not.toBeNull(); + if (!config.isEmptyEnvironment) { + test('Should generate a valid RSS feed data', async ({ page }) => { + const response = await page.request.get('/rss.xml'); + expect(response.status()).toBe(200); + expect(response.headers()['content-type']).toContain('application/xml'); + + const xml = await response.text(); + const parser = new XMLParser(); + const parsedXml = parser.parse(xml); + + const hasChannelTag = parsedXml.rss.channel !== undefined; + expect(hasChannelTag).toBe(true); + + const items = parsedXml.rss.channel.item.slice(0, 20); + expect(items.length).toBeGreaterThan(0); + + items.forEach((item) => { + const description = item.description; + const title = item.title; + const pubDate = item.pubDate; + const guid = item.guid; + + expect(description).not.toBeNull(); + expect(title).not.toBeNull(); + expect(pubDate).not.toBeNull(); + expect(guid).not.toBeNull(); + }); }); - }); + } }); From ed2dcba42f96e64f5f458355983403e64db8268e Mon Sep 17 00:00:00 2001 From: Clara Youdale Date: Mon, 2 Sep 2024 11:10:29 -0300 Subject: [PATCH 6/8] Move rss.spec and signup.spec to e2e-full --- site/gatsby-site/playwright/{e2e => e2e-full}/rss.spec.ts | 3 +++ site/gatsby-site/playwright/{e2e => e2e-full}/signup.spec.ts | 0 2 files changed, 3 insertions(+) rename site/gatsby-site/playwright/{e2e => e2e-full}/rss.spec.ts (95%) rename site/gatsby-site/playwright/{e2e => e2e-full}/signup.spec.ts (100%) diff --git a/site/gatsby-site/playwright/e2e/rss.spec.ts b/site/gatsby-site/playwright/e2e-full/rss.spec.ts similarity index 95% rename from site/gatsby-site/playwright/e2e/rss.spec.ts rename to site/gatsby-site/playwright/e2e-full/rss.spec.ts index cb4cd6d4eb..2c4eda0ff8 100644 --- a/site/gatsby-site/playwright/e2e/rss.spec.ts +++ b/site/gatsby-site/playwright/e2e-full/rss.spec.ts @@ -2,9 +2,11 @@ import { expect } from '@playwright/test'; import config from '../config'; import { test } from '../utils'; import { XMLParser } from 'fast-xml-parser'; +import { init } from '../memory-mongo'; test.describe('RSS', () => { test('Should generate a valid RSS feed', async ({ page }) => { + await init(); const response = await page.request.get('/rss.xml'); expect(response.status()).toBe(200); expect(response.headers()['content-type']).toContain('application/xml'); @@ -22,6 +24,7 @@ test.describe('RSS', () => { if (!config.isEmptyEnvironment) { test('Should generate a valid RSS feed data', async ({ page }) => { + await init(); const response = await page.request.get('/rss.xml'); expect(response.status()).toBe(200); expect(response.headers()['content-type']).toContain('application/xml'); diff --git a/site/gatsby-site/playwright/e2e/signup.spec.ts b/site/gatsby-site/playwright/e2e-full/signup.spec.ts similarity index 100% rename from site/gatsby-site/playwright/e2e/signup.spec.ts rename to site/gatsby-site/playwright/e2e-full/signup.spec.ts From 217b1e3e778ce83d724b4c9c8ba2e72a5ed18417 Mon Sep 17 00:00:00 2001 From: Clara Youdale Date: Mon, 2 Sep 2024 12:16:58 -0300 Subject: [PATCH 7/8] use skipOnEmptyEnvironment --- .../playwright/e2e-full/rss.spec.ts | 57 +++++++++---------- 1 file changed, 27 insertions(+), 30 deletions(-) diff --git a/site/gatsby-site/playwright/e2e-full/rss.spec.ts b/site/gatsby-site/playwright/e2e-full/rss.spec.ts index 2c4eda0ff8..bd9454201b 100644 --- a/site/gatsby-site/playwright/e2e-full/rss.spec.ts +++ b/site/gatsby-site/playwright/e2e-full/rss.spec.ts @@ -1,5 +1,4 @@ import { expect } from '@playwright/test'; -import config from '../config'; import { test } from '../utils'; import { XMLParser } from 'fast-xml-parser'; import { init } from '../memory-mongo'; @@ -22,34 +21,32 @@ test.describe('RSS', () => { expect(items.length).toBeGreaterThan(0); }); - if (!config.isEmptyEnvironment) { - test('Should generate a valid RSS feed data', async ({ page }) => { - await init(); - const response = await page.request.get('/rss.xml'); - expect(response.status()).toBe(200); - expect(response.headers()['content-type']).toContain('application/xml'); - - const xml = await response.text(); - const parser = new XMLParser(); - const parsedXml = parser.parse(xml); - - const hasChannelTag = parsedXml.rss.channel !== undefined; - expect(hasChannelTag).toBe(true); - - const items = parsedXml.rss.channel.item.slice(0, 20); - expect(items.length).toBeGreaterThan(0); - - items.forEach((item) => { - const description = item.description; - const title = item.title; - const pubDate = item.pubDate; - const guid = item.guid; - - expect(description).not.toBeNull(); - expect(title).not.toBeNull(); - expect(pubDate).not.toBeNull(); - expect(guid).not.toBeNull(); - }); + test('Should generate a valid RSS feed data', async ({ page, skipOnEmptyEnvironment }) => { + await init(); + const response = await page.request.get('/rss.xml'); + expect(response.status()).toBe(200); + expect(response.headers()['content-type']).toContain('application/xml'); + + const xml = await response.text(); + const parser = new XMLParser(); + const parsedXml = parser.parse(xml); + + const hasChannelTag = parsedXml.rss.channel !== undefined; + expect(hasChannelTag).toBe(true); + + const items = parsedXml.rss.channel.item.slice(0, 20); + expect(items.length).toBeGreaterThan(0); + + items.forEach((item: any) => { + const description = item.description; + const title = item.title; + const pubDate = item.pubDate; + const guid = item.guid; + + expect(description).not.toBeNull(); + expect(title).not.toBeNull(); + expect(pubDate).not.toBeNull(); + expect(guid).not.toBeNull(); }); - } + }); }); From a8045ebe4fe6b5c036410221b65334d59bc3697a Mon Sep 17 00:00:00 2001 From: Clara Youdale Date: Fri, 27 Sep 2024 14:29:24 -0300 Subject: [PATCH 8/8] Fix signup when user exists test --- site/gatsby-site/playwright/e2e-full/signup.spec.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/site/gatsby-site/playwright/e2e-full/signup.spec.ts b/site/gatsby-site/playwright/e2e-full/signup.spec.ts index cafa1d65f6..a80d36a34b 100644 --- a/site/gatsby-site/playwright/e2e-full/signup.spec.ts +++ b/site/gatsby-site/playwright/e2e-full/signup.spec.ts @@ -1,5 +1,6 @@ import { expect } from '@playwright/test'; import { test, conditionalIntercept, waitForRequest } from '../utils'; +import config from '../config'; test.describe('Signup', () => { const url = '/signup'; @@ -38,13 +39,11 @@ test.describe('Signup', () => { }); test('Should display the error toast message if the user already exists', async ({ page, skipOnEmptyEnvironment }) => { - if (!skipOnEmptyEnvironment) return; - await page.goto(url); await page.locator('[data-cy="signup-btn"]').click(); - await page.locator('input[name=email]').fill(process.env.e2eUsername); + await page.locator('input[name=email]').fill(config.E2E_ADMIN_USERNAME); await page.locator('input[name=password]').fill('anyPassword'); await page.locator('input[name=passwordConfirm]').fill('anyPassword'); await page.locator('[data-cy="signup-btn"]').click();