-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Make admin proposals page work.
- Loading branch information
1 parent
223700d
commit 8f3f5c0
Showing
4 changed files
with
124 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,12 @@ | ||
import {shortRecordToken} from "../../utils"; | ||
import { shortRecordToken } from "../../utils"; | ||
|
||
const statusByTab = { | ||
"Under Review": ["started", "authorized", "unauthorized"], | ||
Approved: ["approved"], | ||
Rejected: ["rejected"], | ||
Abandoned: ["ineligible"] | ||
Abandoned: ["ineligible"], | ||
Unreviewed: ["unreviewed"], | ||
Censored: ["censored"] | ||
}; | ||
|
||
const RECORDS_PAGE_SIZE = 5; | ||
|
@@ -18,7 +20,7 @@ const getTokensByStatusTab = (inventory, currentTab) => | |
: []; | ||
|
||
describe("Records list", () => { | ||
describe("proposal list", () => { | ||
describe("proposals list", () => { | ||
beforeEach(() => { | ||
cy.middleware("ticketvote.inventory", { | ||
approved: 4, | ||
|
@@ -70,7 +72,6 @@ describe("Records list", () => { | |
cy.wait(1000); | ||
cy.assertListLengthByTestId("record-title", 28); | ||
}); | ||
|
||
it("can switch tabs and load proposals correctly", () => { | ||
cy.visit("/?tab=approved"); | ||
cy.wait("@ticketvote.inventory"); | ||
|
@@ -106,7 +107,6 @@ describe("Records list", () => { | |
cy.viewport(1001, 500); | ||
cy.findByTestId("sidebar").should("be.visible"); | ||
}); | ||
|
||
it("can render loading placeholders properly", () => { | ||
cy.visit(`/`); | ||
cy.get('[data-testid="loading-placeholders"] > div').should( | ||
|
@@ -115,4 +115,67 @@ describe("Records list", () => { | |
); | ||
}); | ||
}); | ||
|
||
describe("admin proposals list", () => { | ||
beforeEach(() => { | ||
const admin = { | ||
email: "[email protected]", | ||
username: "adminuser", | ||
password: "password" | ||
}; | ||
cy.middleware("records.inventory", { | ||
unreviewed: 22, | ||
censored: 8 | ||
}); | ||
cy.middleware("records.records"); | ||
cy.login(admin); | ||
}); | ||
it("can render records list according to inventory order", () => { | ||
let inventory; | ||
cy.visit("/admin/records"); | ||
cy.wait("@records.inventory").then(({ response: { body } }) => { | ||
inventory = body.unvetted; | ||
}); | ||
cy.wait("@records.records"); | ||
cy.assertListLengthByTestId("record-title", RECORDS_PAGE_SIZE) // first records batch | ||
.each(([{ id }], position) => { | ||
const tokens = getTokensByStatusTab(inventory, "Unreviewed"); | ||
const expectedToken = shortRecordToken(tokens[position]); | ||
expect(id).to.have.string(expectedToken); | ||
}); | ||
}); | ||
it("can render records and inventory pagination correctly", () => { | ||
cy.visit("/admin/records"); | ||
cy.wait("@records.inventory"); | ||
cy.wait("@records.records"); | ||
cy.assertListLengthByTestId("record-title", 5); | ||
cy.scrollTo("bottom"); | ||
cy.wait("@records.records"); | ||
cy.assertListLengthByTestId("record-title", 10); | ||
cy.scrollTo("bottom"); | ||
cy.wait("@records.records"); | ||
cy.assertListLengthByTestId("record-title", 15); | ||
cy.scrollTo("bottom"); | ||
cy.wait("@records.records"); | ||
cy.assertListLengthByTestId("record-title", 20); | ||
cy.scrollTo("bottom"); | ||
cy.wait("@records.records"); | ||
cy.assertListLengthByTestId("record-title", 22); | ||
cy.scrollTo("bottom"); | ||
cy.wait(1000); | ||
cy.assertListLengthByTestId("record-title", 22); | ||
}); | ||
it("can switch tabs and load proposals correctly", () => { | ||
cy.visit("/admin/records?tab=unreviewed"); | ||
cy.wait("@records.inventory"); | ||
cy.wait("@records.records"); | ||
cy.assertListLengthByTestId("record-title", 5); | ||
cy.findByTestId("tab-1").click(); | ||
cy.wait("@records.records"); | ||
cy.assertListLengthByTestId("record-title", 5); | ||
cy.findByTestId("tab-0").click(); | ||
cy.wait("@records.records"); | ||
cy.assertListLengthByTestId("record-title", 10); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters