test(e2e, playwright): learn page, added random quote test for authenticated user (#52449)

This commit is contained in:
Rahul Suresh
2023-12-06 10:49:24 -06:00
committed by GitHub
parent 97e1420367
commit dc806ef0a4
+21
View File
@@ -1,5 +1,6 @@
import { test, expect, type Page } from '@playwright/test';
import translations from '../client/i18n/locales/english/translations.json';
import words from '../client/i18n/locales/english/motivation.json';
let page: Page;
@@ -63,3 +64,23 @@ test('the page renders all curriculum certifications', async () => {
await expect(btn).toContainText(superBlocks[i]);
}
});
test.describe('Learn (authenticated user)', () => {
test.use({ storageState: 'playwright/.auth/certified-user.json' });
test('the page shows a random quote for an authenticated user', async () => {
const shownQuote = await page.getByTestId('random-quote').textContent();
const shownAuthorText = await page
.getByTestId('random-author')
.textContent();
const shownAuthor = shownAuthorText?.replace('- ', '');
const allMotivationalQuotes = words.motivationalQuotes.map(mq => mq.quote);
const allAuthors = words.motivationalQuotes.map(mq => mq.author);
expect(allMotivationalQuotes).toContain(shownQuote);
expect(allAuthors).toContain(shownAuthor);
});
});