2021-11-10 10:54:38 -05:00
|
|
|
// these tests do not sign in as a user
|
|
|
|
|
|
|
|
const SeleniumHelper = require('./selenium-helpers.js');
|
|
|
|
|
|
|
|
const {
|
|
|
|
buildDriver,
|
|
|
|
clickText,
|
|
|
|
containsClass,
|
2023-09-25 11:34:30 -04:00
|
|
|
findByXpath,
|
|
|
|
navigate
|
2021-11-10 10:54:38 -05:00
|
|
|
} = new SeleniumHelper();
|
|
|
|
|
2023-10-24 14:22:28 -04:00
|
|
|
const rootUrl = process.env.ROOT_URL || 'https://scratch.ly';
|
|
|
|
const statisticsPage = `${rootUrl}/statistics`;
|
2021-11-10 10:54:38 -05:00
|
|
|
|
2021-12-03 09:14:25 -05:00
|
|
|
jest.setTimeout(60000);
|
2021-11-10 10:54:38 -05:00
|
|
|
|
|
|
|
let driver;
|
|
|
|
|
2023-10-24 14:22:28 -04:00
|
|
|
describe('www-integration statistics page', () => {
|
2021-11-10 10:54:38 -05:00
|
|
|
beforeAll(async () => {
|
|
|
|
driver = await buildDriver('www-integration statistics page');
|
|
|
|
});
|
|
|
|
|
|
|
|
beforeEach(async () => {
|
2023-09-25 11:34:30 -04:00
|
|
|
await navigate(statisticsPage);
|
2021-11-10 10:54:38 -05:00
|
|
|
});
|
|
|
|
|
2023-10-24 14:22:28 -04:00
|
|
|
afterAll(() => driver.quit());
|
2021-11-10 10:54:38 -05:00
|
|
|
|
|
|
|
test('check Monthly Activity Trends title', async () => {
|
2023-10-24 14:22:28 -04:00
|
|
|
const chartTitle = await findByXpath('//div[contains(@class, "box0")]//h3');
|
|
|
|
const chartTitleText = await chartTitle.getText();
|
|
|
|
expect(chartTitleText).toBe('Monthly Activity Trends');
|
2021-11-10 10:54:38 -05:00
|
|
|
});
|
|
|
|
|
|
|
|
test('New Projects label on first chart defaults to selected', async () => {
|
2023-10-24 14:22:28 -04:00
|
|
|
const toggleXpath = `(//div[@id="activity_chart"]/*[name()='svg']/*[name()='g']/*[name()='g']/*` +
|
2021-11-10 10:54:38 -05:00
|
|
|
`[name()='g'])[4]/*[name()='g']/*[name()='g']/*[name()='g']`;
|
2023-10-24 14:22:28 -04:00
|
|
|
const newProjectsToggle = await findByXpath(toggleXpath);
|
|
|
|
const toggleState = await containsClass(newProjectsToggle, 'nv-disabled');
|
|
|
|
expect(toggleState).toBe(false);
|
2021-11-10 10:54:38 -05:00
|
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
test('New Projects label on first chart can be toggled', async () => {
|
2023-10-24 14:22:28 -04:00
|
|
|
const toggleXpath = `(//div[@id="activity_chart"]/*[name()='svg']/*[name()='g']/*[name()='g']/*` +
|
2021-11-10 10:54:38 -05:00
|
|
|
`[name()='g'])[4]/*[name()='g']/*[name()='g']/*[name()='g']`;
|
2023-10-24 14:22:28 -04:00
|
|
|
const newProjectsToggle = await findByXpath(toggleXpath);
|
2021-11-10 10:54:38 -05:00
|
|
|
|
|
|
|
// toggle off New Projects
|
|
|
|
await clickText('New Projects');
|
|
|
|
let toggleState = await containsClass(newProjectsToggle, 'nv-disabled');
|
2023-10-24 14:22:28 -04:00
|
|
|
expect(toggleState).toBe(true);
|
2021-11-10 10:54:38 -05:00
|
|
|
|
|
|
|
// toggle New Projects on again
|
|
|
|
await clickText('New Projects');
|
|
|
|
toggleState = await containsClass(newProjectsToggle, 'nv-disabled');
|
2023-10-24 14:22:28 -04:00
|
|
|
expect(toggleState).toBe(false);
|
2021-11-10 10:54:38 -05:00
|
|
|
});
|
|
|
|
});
|